前言:因2個原因導致遲遲沒有出來想要的效果。原因1:迪文屏的中文字庫問題,對CFG文件及FLASH的分配不熟,導致icl文件覆蓋了字庫文件,在迪文論壇發帖解決。原因2:串口線不能2節連接,我測試一直2節杜邦線連接,導致rk2206發不出數據,用串口demo測試,只有一節杜邦線電腦才能接到數據,弄了一節將兩個板子連接終于可以了。
1
迪文屏方面
1、用dgus軟件設計的歡迎使用界面中生成0號字庫和GBK字庫,如圖1所示,點擊DGUS字庫,出現如圖2所示,生成0號ASCII字庫。
圖1 dgus字庫生成
圖2 生成0號字庫
2、下面就來生成GBK漢字庫,如圖3和圖4所示,生成的24宋體24.bin字庫。
圖3 GBK字庫
圖4 生成漢字庫gbk
3、接下來,新建GUI工程,選一張480*854的背景圖,如圖5所示,保存位置確定。
圖5 新建GUI工程
4、網上找了9張圖標,其中自己用位圖編輯了一遍,想多大自己設置即可,用DWIN ICL生成工具生成圖標icl,如圖6所示
圖6 生成圖標icl
圖7 導入生成
5、生成背景icl一樣。注意:軟件默認背景圖為32.icl,生成CFG文件時需要修改。這個根據屏的flash大小設置,我的屏只有8M,因此最大為30,32超出了出現了問題。
6、在背景圖上放置一個圖標控件和2個text控件,如圖8所示,text地址設置2000,另一個設置2064。設置TEXT的屬性,ASCII選擇0號字庫,漢字庫選24號字庫,編碼選擇GBK編碼,后面的X和Y點陣設置為24點陣。這個點陣數根據自己字庫生成的點陣設置。使用出廠的字庫,則分別為0號字庫和12漢字庫。配置為0和12即可。
圖8 放置顯示控件
圖9 text設置屬性
7、設置變量圖標顯示屬性,如圖10所示,從0開始到8共9個變量圖標。
圖10 變量圖標顯示設置
最后生成即可。
2
T5L51方面
1、因我刷過T5L51,所以串口2調試協議不通,只能重刷出廠程序或者自己寫程序。我自己寫的程序,在熊家余老師的串口程序基礎上寫自己的接收代碼,main函數如下代碼:
void main(void)
{
u16 len;
s16 ges;
u8 text_buf[32]={0};
u16 ic_sta;//存儲ICON值
sys_init();//系統初始化
sys_write_vp(0x2000,FIRST_TXT,sizeof(FIRST_TXT)/2+1);//給第一個文本顯示控件設置文本內容
uart2_init(115200);//初始化串口2
while(1)
{
IF(uart2_rx_sta&UART2_PACKET_OK)//接受到了串口數據包
{
len = uart2_rx_sta&UART2_PACKET_LEN;//得到串口數據包的長度,不包含" "或者' '結束符的長度
ges = uart2_buf[0]+uart2_buf[1]*256;
switch(ges)
{
case 1:
ic_sta = 0;
sys_write_vp(0x1000,(u8*)&ic_sta,1);
sprintf(text_buf,"GES_UP:0x%x",ges);
break;
case 2:
ic_sta = 1;
sys_write_vp(0x1000,(u8*)&ic_sta,1);
sprintf(text_buf,"GES_DOWN:0x%x",ges);
break;
case 4:
ic_sta = 2;
sys_write_vp(0x1000,(u8*)&ic_sta,1);
sprintf(text_buf,"GES_LEFT:0x%x",ges);
break;
case 8:
ic_sta = 3;
sys_write_vp(0x1000,(u8*)&ic_sta,1);
sprintf(text_buf,"GES_RIGHT:0x%x",ges);
break;
case 16:
ic_sta = 4;
sys_write_vp(0x1000,(u8*)&ic_sta,1);
sprintf(text_buf,"GES_FORWARD:0x%x",ges);
break;
case 32:
ic_sta = 5;
sys_write_vp(0x1000,(u8*)&ic_sta,1);
sprintf(text_buf,"GES_BACKWARD:0x%x",ges);
break;
case 64:
ic_sta = 6;
sys_write_vp(0x1000,(u8*)&ic_sta,1);
sprintf(text_buf,"GES_clockWISE:0x%x",ges);
break;
case 128:
ic_sta = 7;
sys_write_vp(0x1000,(u8*)&ic_sta,1);
sprintf(text_buf,"GES_COUNT_CLOCKWISE:0x%x",ges);
break;
case 256:
ic_sta = 8;
sys_write_vp(0x1000,(u8*)&ic_sta,1);
sprintf(text_buf,"GES_WAVE:0x%x",ges);
break;
default:
break;
}
len = strlen(text_buf);
text_buf[len++] = 0;
text_buf[len++] = 0;
sys_write_vp(0x2064,text_buf,len/2+1);//同時把數據包顯示到界面上
uart2_rx_sta = 0;//清0代表處理掉了此串口包
}
}
}
(左右移動查看全部內容)
3
小凌派方面
根據手勢demo將uart的demo加入到手勢demo.rar中,如下所示
/*
* Copyright (c) 2022 FuZhou Lockzhiner Electronic Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* E53模塊中
* UART0_RX_M0 -> GPIO0_B6
* UART0_TX_M0 -> GPIO0_B7
*/
unsigned short getCRC16(unsigned char *ptr,unsigned char len)
{
unsigned char i;
unsigned short crc = 0xFFFF;
if(ptr==0)
{
return 0;
}
if(len==0)
{
len = 1;
}
//if(len<=255)
{
while(len--)
{
crc ^= *ptr;
for(i=0; i<8; i++)
{
if(crc&1)
{
crc >>= 1;
crc ^= 0xA001;
}
else
crc >>= 1;
}
ptr++;
}
}
return(crc);
}
void uart0_init(void)
{
unsigned int ret;
UartAttribute attr;
LzUartDeinit(UART_ID);
attr.baudRate = 115200;
attr.dataBits = UART_DATA_BIT_8;
attr.pad = FLOW_CTRL_NONE;
attr.parity = UART_PARITY_NONE;
attr.rxBlock = UART_BLOCK_STATE_NONE_BLOCK;
attr.stopBits = UART_STOP_BIT_1;
attr.txBlock = UART_BLOCK_STATE_NONE_BLOCK;
PinctrlSet(GPIO0_PB6, MUX_FUNC2, PULL_KEEP, DRIVE_LEVEL2);
PinctrlSet(GPIO0_PB7, MUX_FUNC2, PULL_KEEP, DRIVE_LEVEL2);
ret = LzUartInit(UART_ID, &attr);
if (ret != LZ_HARDWARE_SUCCESS)
{
printf("%s, %d: LzUartInit(%d) faiLED! ", __FILE__, __LINE__, ret);
return;
}
return;
}
void e53_gs_process(void *arg)
{
unsigned int ret = 0;
unsigned int i=0;
unsigned short flag = 0;
unsigned short rc = 0;
unsigned char tubiao[16] = {0};
unsigned char tubiao_str[48] = {0};
e53_gs_init();
uart0_init();
ret = LzUartWrite(UART_ID, tubiao, 4);
if (ret != LZ_HARDWARE_SUCCESS)
{
printf("%s, %d: LzUartInit(%d) failed! ", __FILE__, __LINE__, ret);
return;
}
while (1)
{
ret = e53_gs_get_gesture_state(&flag);
if (ret != 0)
{
printf("Get Gesture Statu: 0x%x ", flag);
if (flag & GES_UP)
{
printf(" Up ");
}
if (flag & GES_DOWM)
{
printf(" Down ");
}
if (flag & GES_LEFT)
{
printf(" Left ");
}
if (flag & GES_RIGHT)
{
printf(" Right ");
}
if (flag & GES_FORWARD)
{
printf(" Forward ");
}
if (flag & GES_BACKWARD)
{
printf(" Backward ");
}
if (flag & GES_CLOCKWISE)
{
printf(" Clockwise ");
}
if (flag & GES_COUNT_CLOCKWISE)
{
printf(" Count Clockwise ");
}
if (flag & GES_WAVE)
{
printf(" Wave ");
}
e53_gs_led_up_set((flag & GES_UP) ? (1) : (0));
e53_gs_led_down_set((flag & GES_DOWM) ? (1) : (0));
e53_gs_led_left_set((flag & GES_LEFT) ? (1) : (0));
e53_gs_led_right_set((flag & GES_RIGHT) ? (1) : (0));
e53_gs_led_forward_set((flag & GES_FORWARD) ? (1) : (0));
e53_gs_led_backward_set((flag & GES_BACKWARD) ? (1) : (0));
e53_gs_led_cw_set((flag & GES_CLOCKWISE) ? (1) : (0));
e53_gs_led_ccw_set((flag & GES_COUNT_CLOCKWISE) ? (1) : (0));
e53_gs_led_wave_set((flag & GES_WAVE) ? (1) : (0));
tubiao[0] = flag;
tubiao[1] = (flag&0xff00)>>8;
tubiao[2] = ' ';
tubiao[3] = ' ';
printf("tubiao: ");
for(i=0;i<4;i++) {
sprintf(tubiao_str+i*3, "%02X ", tubiao[i] & 0xFF);
}
printf("DOWN HEX: %s", tubiao_str);
printf(" ");
ret = LzUartWrite(UART_ID, tubiao, 4);
if (ret != LZ_HARDWARE_SUCCESS)
{
printf("%s, %d: LzUartInit(%d) failed! ", __FILE__, __LINE__, ret);
return;
}
}
else
{
/* 如果沒有數據,則多等待 */
LOS_Msleep(100);
}
}
}
void e53_gs_example()
{
unsigned int thread_id;
TSK_INIT_PARAM_S task = {0};
unsigned int ret = LOS_OK;
task.pfnTaskEntry = (TSK_ENTRY_FUNC)e53_gs_process;
task.uwStackSize = 2048;
task.pcName = "e53 getsture sensor process";
task.usTaskPrio = 24;
ret = LOS_TaskCreate(&thread_id, &task);
if (ret != LOS_OK)
{
printf("Falied to create Task_One ret:0x%x ", ret);
return;
}
}
APP_FEATURE_INIT(e53_gs_example);
(左右移動查看全部內容)
測試:測試的時候總是控制不了,用小凌派的串口發給電腦串口,也沒有。不應該,人家廠家肯定沒問題。本來2節杜邦線,改成了1節杜邦線,可以了。
-
開發板
+關注
關注
25文章
4943瀏覽量
97188 -
迪文屏
+關注
關注
3文章
76瀏覽量
5373 -
小凌派
+關注
關注
0文章
27瀏覽量
1193
原文標題:如何用小凌派鴻蒙開發板輕松控制迪文智能屏?
文章出處:【微信號:HarmonyOS_Community,微信公眾號:電子發燒友開源社區】歡迎添加關注!文章轉載請注明出處。
發布評論請先 登錄
相關推薦
評論