在线时间721 小时
UID3469866
注册时间2018-4-19
NXP金币3946

TA的每日心情 | 慵懒 2025-5-7 08:45 |
---|
签到天数: 279 天 连续签到: 1 天 [LV.8]以坛为家I
版主
  
- 积分
- 11199

- 最后登录
- 2025-9-9
|
【GUI主题月】基于RT1062的lvgl综合界面
最近确实有点懒,摸了太久的鱼,在日天兄的再三催促下,勉勉强强赶上了这个主题月的尾巴。
这次用的板子是腾讯IOT的一块卡,主控是RT1062,带一块800*480的RGB屏。
配界面的时候,使用了GUI-Guider,不得不说,雀食好用,简单界面拖一拖就能完成,字库图库也是一键完成,比官网网页那个好用多了,就算不用它设计界面,拿来搞个中文小字库,也是超级方便。
直接拷贝出来的代码,编译会报错,要把guider_fonts.h文件里面 lv_font.h 修改成 lvgl/lvgl.h。
板子的官方没有把触摸屏的驱动放出来,这里就把我写的放下面,有需要的可以看看。
- #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); //复位
- vTaskDelay(10);
-
- GPIO_PinWrite(GPIO5, 0U, 0); //复位
- vTaskDelay(100);
- GPIO_PinWrite(GPIO5, 0U, 0); //INT
- vTaskDelay(100);
- GPIO_PinWrite(GPIO5, 0U, 1); //复位
- 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%c\r\n",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 %x\r\n",handle->touch_buf[0],handle->touch_buf[1],handle->touch_buf[2]);
- }
-
- }
- return status;
- }
复制代码
刚刚真的欲哭无泪,好不容易写的帖子,保存草稿之后直接没了,就因为打了个特殊字符,在这个字符后面的全没了。我人麻辣,刚刚写的一大坨全忘了,记住啥就写啥吧。这个符号
,千万小心 。
|
|