【MCXN947开发板测评】桌面化管理界面制作
[复制链接]
前面介绍了TFT屏的显示驱动,为了实现桌面化的管理,需完成其管理界面的制作,其效果如图1所示。
图1 界面效果
由于该显示屏不具备触摸功能,为此需要借助按键来辅助进行功能选择。
为进行图标的显示,所配置的图标显示函数为:
void show_tbh(unsigned int x,unsigned int y,unsigned int n)
{
unsigned int i,j,k;
unsigned int da;
k=0;
for(i=0;i<50;i++)
{
for(j=0;j<50;j++)
{
if(n==0) da=gImage_1[k*2];
if(n==1) da=gImage_2[k*2];
if(n==2) da=gImage_3[k*2];
if(n==3) da=gImage_4[k*2];
if(n==4) da=gImage_8[k*2];
if(n==5) da=gImage_7[k*2];
if(n==6) da=gImage_6[k*2];
if(n==7) da=gImage_5[k*2];
da<<=8;
if(n==0) da|=gImage_1[k*2+1];
if(n==1) da|=gImage_2[k*2+1];
if(n==2) da|=gImage_3[k*2+1];
if(n==3) da|=gImage_4[k*2+1];
if(n==4) da|=gImage_8[k*2+1];
if(n==5) da|=gImage_7[k*2+1];
if(n==6) da|=gImage_6[k*2+1];
if(n==7) da|=gImage_5[k*2+1];
POINT_COLOR=da;
LCD_DrawPoint(x+i,y+j);
k++;
}
}
}
在使用时,只需指定显示的位置和图标编号即可。
为实现中文的显示,用字库提取工具完成了小字库的构建。
图2 字模提取格式
图3 提取字模
字模的存储结构如下:
unsigned char hanzi16[]=
{
0xFF,0xFF,0x01,0xC0,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,
0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x5F,0xFF,0xBF,0xFF,
0xFF,0xFF,0x00,0x80,0xDF,0xFD,0xDF,0xFD,0x01,0xC0,0xDD,0xDD,0xDD,0xDD,0xED,0xDD,
0xF5,0xC3,0xF9,0xDF,0xFD,0xDF,0x01,0xC0,0xFD,0xDF,0xFD,0xDF,0x01,0xC0,0xFD,0xDF,
...
};
实现汉字显示的函数为:
void showhanzi16h(unsigned int x,unsigned int y,unsigned char index,unsigned char s)
{
unsigned char i,j,k;
unsigned char *temp=hanzi16;
temp+=index*32;
for(j=0;j<16;j++)
{
for(k=0;k<2;k++)
{
for(i=0;i<8;i++)
{
if((*temp&(1<<i))!=0)
{
if(s==0) POINT_COLOR=WHITE;
else POINT_COLOR=RED;
}
else
{
if(s==0) POINT_COLOR=RED;
else POINT_COLOR=WHITE;
}
LCD_DrawPoint(x+j,y-k*8-i);
}
temp++;
}
}
}
实现界面显示效果测试的主程序为:
int main(void)
{
gpio_pin_config_t led_config = {
kGPIO_DigitalOutput,
0,
};
CLOCK_SetClkDiv(kCLOCK_DivFlexcom4Clk, 1u);
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
CLOCK_EnableClock(kCLOCK_Gpio0);
CLOCK_EnableClock(kCLOCK_Gpio1);
CLOCK_EnableClock(kCLOCK_Gpio4);
BOARD_InitPins();
BOARD_InitBootClocks();
BOARD_InitDebugConsole();
GPIO_PinInit(GPIO0, 25U, &led_config);
GPIO_PinInit(GPIO0, 26U, &led_config);
GPIO_PinInit(GPIO0, 24U, &led_config);
GPIO_PinInit(GPIO0, 27U, &led_config);
GPIO_PinInit(GPIO0, 10U, &led_config);
GPIO_PinInit(GPIO0, 28U, &led_config);
delay();
LCD_LED_High();
tft_Init();
LCD_Clear(WHITE);
loop: LCD_Clear(WHITE);
show_tbh(20,240,0);
showhanzi16h(80,280,0,0);
showhanzi16h(80,264,1,0);
show_tbh(20,180,1);
BACK_COLOR=WHITE;
POINT_COLOR=RED;
LCD_ShowCharh(80,220,'P',1);
LCD_ShowCharh(80,212,'W',1);
LCD_ShowCharh(80,204,'M',1);
show_tbh(20,120,2);
BACK_COLOR=WHITE;
POINT_COLOR=RED;
LCD_ShowCharh(80,160,'R',1);
LCD_ShowCharh(80,152,'T',1);
LCD_ShowCharh(80,144,'C',1);
show_tbh(20,60,3);
showhanzi16h(80,100,5,1);
showhanzi16h(80,84,6,1);
show_tbh(120,60,4);
show_tbh(120,120,5);
show_tbh(120,180,6);
show_tbh(120,240,7);
showhanzi16h(180,280,13,1);
showhanzi16h(180,264,14,1);
showhanzi16h(180,220,11,1);
showhanzi16h(180,204,12,1);
showhanzi16h(180,160,9,1);
showhanzi16h(180,144,10,1);
showhanzi16h(180,100,7,1);
showhanzi16h(180,84,8,1);
while(1);
}
经程序的编译和下载,其具体的显示效果如图3所示。
图4 界面效果
|