成人免费无码不卡毛片,亚洲AⅤ无码精品一区二区三区,国产尤物精品视频,久久精品日本亚洲,欧美成人一区三区无码乱码A片,中文字日产幕码一区二区色哟哟,亞洲日韓中文字幕網AV

  • 正文
  • 附件下載
  • 推薦器件
  • 相關(guān)推薦
申請(qǐng)入駐 產(chǎn)業(yè)圖譜

基于LPC55S69學(xué)習(xí)GUI-Guider軟件分享三——lvgl輸入設(shè)備模擬

2024/05/14
4691
加入交流群
掃碼加入
獲取工程師必備禮包
參與熱點(diǎn)資訊討論

繼上次移植了GUI-Guider生成的GUI界面后,顯示沒(méi)什么問(wèn)題了。但是只有顯示,不能操作,看起來(lái)還是不完整。這次就分享如何移植輸入設(shè)備,可以點(diǎn)擊和移動(dòng)操作。

輸入設(shè)備移植文件主要是這個(gè)。如圖,可以看到lvgl支持觸摸指針設(shè)備,鼠標(biāo),鍵盤(pán),encoder,button。

本次是通過(guò)串口方式發(fā)送數(shù)據(jù)模擬觸摸指針設(shè)備。下面是主要修改步驟。

串口接收6個(gè)字節(jié),定義結(jié)構(gòu)體變量映射6個(gè)字節(jié)。代碼如下。

主要是初始化,獲取點(diǎn)擊狀態(tài),獲取x,y坐標(biāo)這3個(gè)函數(shù)。

extern union Indev_uart_data
{
struct
{
uint8_t flag;
uint8_t press;
uint16_t x;
uint16_t y;
}touch;
uint8_t buff[6];
}g_input;

/*------------------
* Touchpad
* -----------------*/

/*Initialize your touchpad*/
static void touchpad_init(void)
{
/*Your code comes here*/
memset(g_input.buff, 0, sizeof(g_input.buff));
}

/* Will be called by the library to read the touchpad */
static bool touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
static lv_coord_t last_x = 0;
static lv_coord_t last_y = 0;

/*Save the pressed coordinates and the state*/
if(touchpad_is_pressed()) {
touchpad_get_xy(&last_x, &last_y);
data->state = LV_INDEV_STATE_PR;
} else {
data->state = LV_INDEV_STATE_REL;
}

/*Set the last pressed coordinates*/
data->point.x = last_x;
data->point.y = last_y;

/*Return `false` because we are not buffering and no more data to read*/
return false;
}

/*Return true is the touchpad is pressed*/
static bool touchpad_is_pressed(void)
{
/*Your code comes here*/
if((g_input.touch.flag == 'T')&&(g_input.touch.press))
{
return true;
}
return false;
}

/*Get the x and y coordinates if the touchpad is pressed*/
static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y)
{
/*Your code comes here*/
if(g_input.touch.flag == 'T')
{
(*x) = g_input.touch.x;
(*y) = g_input.touch.y;
}
}

然后就是主函數(shù)中調(diào)用輸入設(shè)備初始化。

主循環(huán)通過(guò)串口接收數(shù)據(jù),模擬觸摸指針設(shè)備。注意串口接收使用非阻塞方式。

下面是通過(guò)串口助手發(fā)送數(shù)據(jù)效果,可以看到指針位置。

具體參考如下代碼:lpc55s69_lcd.rar (7.49 MB, 點(diǎn)擊下方附件下載)

  • lpc55s69_lcd.rar
    下載

推薦器件

更多器件
器件型號(hào) 數(shù)量 器件廠(chǎng)商 器件描述 數(shù)據(jù)手冊(cè) ECAD模型 風(fēng)險(xiǎn)等級(jí) 參考價(jià)格 更多信息
XB3-24Z8PT-J 1 Digi International Inc Telecom Circuit, 1-Func, MODULE-20

ECAD模型

下載ECAD模型
$20.06 查看
SN74ALVC164245DGG 1 Texas Instruments 16-Bit 2.5-V to 3.3-V/3.3-V To 5-V Level Shifting Transceiver With 3-State Outputs 48-TSSOP

ECAD模型

下載ECAD模型
$1.27 查看
HFE7000-210 1 Honeywell Sensing and Control Fiber Optic Emitter, FIBER OPTIC LED EMITTER, 50Mbps, THROUGH HOLE MOUNT, SMA CONNECTOR, PLASTIC PACKAGE-4
$21.47 查看

相關(guān)推薦

  • esp32結(jié)合LVGL,天氣,日歷氣象站制作
    方案
    2282
    2024/09/03
  • 在LPC55S69上實(shí)現(xiàn)的秘鑰系統(tǒng)
    方案
    1821
    2024/07/25
  • 基于單片機(jī)proteus仿真的設(shè)計(jì)作業(yè)3個(gè)實(shí)驗(yàn)串口、并口、定時(shí)器(仿真圖、源代碼)
    方案
    1022
    2024/07/25
  • 商水县| 阳城县| 富民县| 安溪县| 游戏| 慈利县| 德安县| 延边| 井冈山市| 望江县| 辽阳县| 井陉县| 湟源县| 安国市| 社会| 兴安县| 南开区| 古交市| 三门县| 石台县| 开阳县| 衡南县| 新宾| 黄陵县| 五指山市| 西吉县| 新蔡县| 德钦县| 随州市| 芦山县| 洛浦县| 公主岭市| 北川| 桐乡市| 平武县| 建宁县| 洞头县| 嘉义县| 嵊泗县| 高密市| 南投县|