加入星計(jì)劃,您可以享受以下權(quán)益:

  • 創(chuàng)作內(nèi)容快速變現(xiàn)
  • 行業(yè)影響力擴(kuò)散
  • 作品版權(quán)保護(hù)
  • 300W+ 專業(yè)用戶
  • 1.5W+ 優(yōu)質(zhì)創(chuàng)作者
  • 5000+ 長(zhǎng)期合作伙伴
立即加入

基于RT1062的lvgl綜合界面-界面配置、驅(qū)動(dòng)代碼

05/17 09:14
2292
服務(wù)支持:
技術(shù)交流群

完成交易后在“購(gòu)買成功”頁(yè)面掃碼入群,即可與技術(shù)大咖們分享疑惑和經(jīng)驗(yàn)、收獲成長(zhǎng)和認(rèn)同、領(lǐng)取優(yōu)惠和紅包等。

虛擬商品不可退

當(dāng)前內(nèi)容為數(shù)字版權(quán)作品,購(gòu)買后不支持退換且無(wú)法轉(zhuǎn)移使用。

加入交流群
掃碼加入
獲取工程師必備禮包
參與熱點(diǎn)資訊討論
放大
電路板圖(2)
相關(guān)方案
  • 方案介紹
  • 推薦器件
  • 相關(guān)推薦
  • 電子產(chǎn)業(yè)圖譜
申請(qǐng)入駐 產(chǎn)業(yè)圖譜

最近確實(shí)有點(diǎn)懶,摸了太久的魚,在日天兄的再三催促下,勉勉強(qiáng)強(qiáng)趕上了這個(gè)主題月的尾巴。

演示視頻:https://player.youku.com/embed/XNTg3Mjc4MjQ0MA==

這次用的板子是騰訊IOT的一塊卡,主控是RT1062,帶一塊800*480的RGB屏。

配界面的時(shí)候,使用了GUI-Guider,不得不說(shuō),雀食好用,簡(jiǎn)單界面拖一拖就能完成,字庫(kù)圖庫(kù)也是一鍵完成,比官網(wǎng)網(wǎng)頁(yè)那個(gè)好用多了,就算不用它設(shè)計(jì)界面,拿來(lái)搞個(gè)中文小字庫(kù),也是超級(jí)方便。

直接拷貝出來(lái)的代碼,編譯會(huì)報(bào)錯(cuò),要把guider_fonts.h文件里面 lv_font.h 修改成 lvgl/lvgl.h。

板子的官方?jīng)]有把觸摸屏的驅(qū)動(dòng)放出來(lái),這里就把我寫的放下面,有需要的可以看看。

#include "fsl_common.h"
#include "fsl_lpi2c.h"
#include "fsl_gt911_rt.h"

#include "pin_mux.h"
#include "fsl_gpio.h"
#include "fsl_debug_console.h"
#include "FreeRTOS.h"
#include "task.h"

typedef struct _ft5406_rt_touch_point
{
    uint8_t XH;
    uint8_t XL;
    uint8_t YH;
    uint8_t YL;
    uint8_t RESERVED[2];
} ft5406_rt_touch_point_t;

typedef struct _ft5406_rt_touch_data
{
    uint8_t GEST_ID;
    uint8_t TD_STATUS;
    ft5406_rt_touch_point_t TOUCH[FT5406_RT_MAX_TOUCHES];
} ft5406_rt_touch_data_t;

#define TOUCH_POINT_GET_EVENT(T) ((touch_event_t)((T).XH >> 6))
#define TOUCH_POINT_GET_ID(T)    ((T).YH >> 4)
#define TOUCH_POINT_GET_X(T)     ((((T).XH & 0x0f) << 8) | (T).XL)
#define TOUCH_POINT_GET_Y(T)     ((((T).YH & 0x0f) << 8) | (T).YL)

status_t FT5406_RT_Init(ft5406_rt_handle_t *handle, LPI2C_Type *base)
{
    lpi2c_master_transfer_t *xfer = &(handle->xfer);
    status_t status;
    uint8_t mode;

    assert(handle);
    assert(base);

    if (!handle || !base)
    {
        return kStatus_InvalidArgument;
    }

    GPIO_PinWrite(GPIO5, 0U, 1); //復(fù)位
    vTaskDelay(10);
    
    GPIO_PinWrite(GPIO5, 0U, 0); //復(fù)位
    vTaskDelay(100);
    GPIO_PinWrite(GPIO5, 0U, 0); //INT
    vTaskDelay(100);
    GPIO_PinWrite(GPIO5, 0U, 1); //復(fù)位
    vTaskDelay(200);
    
  gpio_pin_config_t PMIC_ON_REQ_config = {
      .direction = kGPIO_DigitalInput,
      .outputLogic = 0U,
      .interruptMode = kGPIO_NoIntmode
  };
  GPIO_PinInit(GPIO5, 1U, &PMIC_ON_REQ_config);
    
    handle->base = base;

    /* clear transfer structure and buffer */
    memset(xfer, 0, sizeof(*xfer));
    memset(handle->touch_buf, 0, FT5406_RT_TOUCH_DATA_LEN);

    /* set device mode to normal operation */
    uint8_t id[4] = {0};
    
    xfer->slaveAddress   = FT5406_RT_I2C_ADDRESS;
    xfer->direction      = kLPI2C_Read;
    xfer->subaddress     = 0X8140;
    xfer->subaddressSize = 2;
    xfer->data           = id;
    xfer->dataSize       = 4;
    xfer->flags          = kLPI2C_TransferDefaultFlag;
    status = LPI2C_MasterTransferBlocking(handle->base, &handle->xfer);
    PRINTF("%c%c%c%crn",id[0],id[1],id[2],id[3]);

    return status;
}

status_t FT5406_RT_Denit(ft5406_rt_handle_t *handle)
{
    assert(handle);

    if (!handle)
    {
        return kStatus_InvalidArgument;
    }

    handle->base = NULL;
    return kStatus_Success;
}

status_t FT5406_RT_GetSingleTouch(ft5406_rt_handle_t *handle, touch_event_t *touch_event, int *touch_x, int *touch_y)
{
    status_t status;
    touch_event_t touch_event_local;
    uint8_t Clearbuf = 0; 
    *touch_event = kTouch_Reserved;
    if(GPIO_PinRead(GPIO5, 0U) == 0)
        return kStatus_Success;
        
    handle->xfer.slaveAddress   = FT5406_RT_I2C_ADDRESS;
    handle->xfer.direction      = kLPI2C_Read;
    handle->xfer.subaddress     = 0x814E;
    handle->xfer.subaddressSize = 2;
    handle->xfer.data           = handle->touch_buf;
    handle->xfer.dataSize       = FT5406_RT_TOUCH_DATA_LEN;
    handle->xfer.flags          = kLPI2C_TransferDefaultFlag;

    status = LPI2C_MasterTransferBlocking(handle->base, &handle->xfer);

    if (status == kStatus_Success)
    {
        if(handle->touch_buf[0] != 0x00)
        {
            handle->xfer.slaveAddress   = FT5406_RT_I2C_ADDRESS;
            handle->xfer.direction      = kLPI2C_Write;
            handle->xfer.subaddress     = 0x814E;
            handle->xfer.subaddressSize = 2;
            handle->xfer.data           = &Clearbuf;
            handle->xfer.dataSize       = 1;
            handle->xfer.flags          = kLPI2C_TransferDefaultFlag;
            status = LPI2C_MasterTransferBlocking(handle->base, &handle->xfer);
            
            if((handle->touch_buf[0] & 0x0f) != 0)
            {
                *touch_event = kTouch_Down;
                *touch_y = ((uint16_t)handle->touch_buf[3]<<8) + handle->touch_buf[2];
                *touch_x = ((uint16_t)handle->touch_buf[5]<<8) + handle->touch_buf[4];
            }
            //PRINTF("%x %x %xrn",handle->touch_buf[0],handle->touch_buf[1],handle->touch_buf[2]);
        }
        
    }

    return status;
}

 

推薦器件

更多器件
器件型號(hào) 數(shù)量 器件廠商 器件描述 數(shù)據(jù)手冊(cè) ECAD模型 風(fēng)險(xiǎn)等級(jí) 參考價(jià)格 更多信息
ECS-80-10-30B-CWN-TR 1 ECS International Inc Parallel - Fundamental Quartz Crystal,

ECAD模型

下載ECAD模型
$0.92 查看
ABS07-32.768KHZ-4-T 1 Abracon Corporation CRYSTAL 32.7680KHZ 12.5PF SMD

ECAD模型

下載ECAD模型
$1.36 查看
ASFL1-12.000MHZ-ERS-T 1 Abracon Corporation XTAL OSC XO 12.0000MHZ HCMOS TTL
$1.28 查看

相關(guān)推薦

電子產(chǎn)業(yè)圖譜