加入星计划,您可以享受以下权益:

  • 创作内容快速变现
  • 行业影响力扩散
  • 作品版权保护
  • 300W+ 专业用户
  • 1.5W+ 优质创作者
  • 5000+ 长期合作伙伴
立即加入

基于RT1062的lvgl综合界面-界面配置、驱动代码

05/17 09:14
1720
服务支持:
技术交流群

完成交易后在“购买成功”页面扫码入群,即可与技术大咖们分享疑惑和经验、收获成长和认同、领取优惠和红包等。

虚拟商品不可退

当前内容为数字版权作品,购买后不支持退换且无法转移使用。

加入交流群
扫码加入
获取工程师必备礼包
参与热点资讯讨论
放大
电路板图(2)
相关方案
  • 方案介绍
  • 推荐器件
  • 相关推荐
  • 电子产业图谱
申请入驻 产业图谱

最近确实有点懒,摸了太久的鱼,在日天兄的再三催促下,勉勉强强赶上了这个主题月的尾巴。

演示视频:https://player.youku.com/embed/XNTg3Mjc4MjQ0MA==

这次用的板子是腾讯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%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;
}

 

推荐器件

更多器件
器件型号 数量 器件厂商 器件描述 数据手册 ECAD模型 风险等级 参考价格 更多信息
TLP292-4(GB-TP,E 1 Toshiba America Electronic Components AC INPUT-TRANSISTOR OUTPUT OPTOCOUPLER

ECAD模型

下载ECAD模型
$1.38 查看
LTC6905HS5-100#TRMPBF 1 Linear Technology LTC6905-XXX - Fixed Frequency SOT-23 Oscillator; Package: SOT; Pins: 5; Temperature Range: -40&deg;C to 125&deg;C
$41.05 查看
AT24CM01-SSHD-B 1 Microchip Technology Inc IC EEPROM 1MBIT 1MHZ 8SOIC

ECAD模型

下载ECAD模型
$2.19 查看

相关推荐

电子产业图谱