前言:因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文章
4979浏览量
97272 -
迪文屏
+关注
关注
3文章
76浏览量
5378 -
小凌派
+关注
关注
0文章
27浏览量
1195
原文标题:如何用小凌派鸿蒙开发板轻松控制迪文智能屏?
文章出处:【微信号:HarmonyOS_Community,微信公众号:电子发烧友开源社区】欢迎添加关注!文章转载请注明出处。
发布评论请先 登录
相关推荐
评论