【HAL库每天一例】系列例程从今天开始持续更新。。。。。
我们将坚持每天至少发布一个基于YS-F1Pro开发板的HAL库例程,
该系列例程将带领大家从零开始使用HAL库,后面会持续添加模块应用例程。
同样的,我们还程序发布基于HAL库的指导文档和视频教程,欢迎持续关注,并提出改进意见。
例程下载:
资料包括程序、相关说明资料以及软件使用截图
链接:http://pan.baidu.com/s/1i574oPv
密码:r3s3
(硬石YS-F1Pro开发板HAL库例程持续更新1. 软件设计之基本裸机例程(HAL库版本)YSF1_HAL-040. LCD-显示中文(字模在内部Flash))
/**
******************************************************************************
* 硬石YS-F1Pro开发板例程功能说明
*
* 例程名称: YSF1_HAL-040. LCD-显示中文(字模在内部Flash)
*
******************************************************************************
* 说明:
* 本例程配套硬石STM32开发板YS-F1Pro使用。
*
* 淘宝:
* 论坛:http://www.ing10bbs.com
* 版权归硬石嵌入式开发团队所有,请勿商用。
******************************************************************************
*/
【1】例程简介
FSMC:可变静态存储控制器,是STM32系列采用的一种新型的存储器扩展技术。一般可以用FSMC
接口与液晶驱动IC连接,实现数据交换。YS-F1Pro预留16bit的FSMC液晶接口,我们同时提供了
3.5寸TFT液晶模组供选购,该模组的液晶驱动IC型号为ILI9488。
本例程实现液晶模组显示中文字符和字符串,提供16号和24号两种字体选择。
【2】跳线帽情况
******* 为保证例程正常运行,必须插入以下跳线帽 **********
丝印编号 IO端口 目标功能引脚 出厂默认设置
JP1 PA10 TXD(CH340G) 已接入
JP2 PA9 RXD(CH340G) 已接入
【3】操作及现象
把3.5寸TFT液晶模组插入开发板中间液晶接口上,使用开发板配套的MINI USB线连接到开发板标
示“调试串口”字样的MIMI USB接口(需要安装驱动),在电脑端打开串口调试助手工具,设置参
数为115200 8-N-1。下载完程序之后,在串口调试助手窗口可接收到液晶模组ID信息,同时液晶屏
幕亮起来,背景为黑色,显示一些中文字符。
/******************* (C) COPYRIGHT 2015-2020 硬石嵌入式开发团队 *****END OF FILE****/
中文显示函数实现
- const unsigned int ysdz_1616[][32]= /* “硬石开发板”中文字模,大小:16*16 */
- {
- {0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x0F,0x38,0x14,0x90,0x2F,0x90,0x2C,0xE8,0x14,0x38,0x1D,0xAC,0x06,0x3A,0x03,0x09,0x02,0x00,0x0D,0x00,0x38,0x00,0x00,0x00,0x00},/*"硬",0*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xE0,0x00,0x00,0x01,0x80,0x00,0x80,0x00,0x40,0x18,0xE0,0x37,0x50,0x10,0x48,0x10,0x44,0x1C,0x82,0x03,0x00,0x00,0x00,0x00},/*"石",1*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x0F,0x60,0x02,0x40,0x02,0x40,0x32,0xFE,0x0F,0x20,0x02,0x20,0x02,0x20,0x02,0x10,0x02,0x10,0x02,0x08,0x02,0x00,0x00,0x00,0x00},/*"开",2*/
- {0x00,0x00,0x80,0x00,0x00,0x0D,0x80,0x18,0xA0,0x00,0x90,0x0F,0xF0,0x00,0x40,0x00,0xC0,0x07,0xA0,0x04,0x20,0x03,0x10,0x02,0x08,0x05,0xC4,0x1C,0x00,0x70,0x00,0x00},/*"发",3*/
- {0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x0C,0x10,0x02,0x10,0x01,0x38,0x01,0x14,0x1D,0x38,0x0B,0xD8,0x0A,0x94,0x0C,0x92,0x0C,0x50,0x1A,0x30,0x70,0x10,0x00,0x00,0x00},/*"板",4*/
- };
- const unsigned int ysdz_2424[][72]= /* “硬石开发板”中文字模,大小:16*16 */
- {
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0xF3,0x00,0xF0,0x80,0x00,0xC0,0x80,0x1F,0x40,0xF8,0x18,0x40,0x88,0x08,0x60,0xF0,0x09,0xF0,0x93,0x0C,0x30,0x93,0x07,0x30,0xF1,0x00,0x38,0x89,0x00,0xE8,0xD1,0x00,0x24,0x60,0x00,0x22,0xE0,0x00,0x00,0xA0,0x01,0x00,0x18,0x07,0x00,0x00,0x1E,0x00,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00},/*"硬",0*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0xFC,0x07,0x00,0x1F,0x00,0x00,0x10,0x00,0x00,0x38,0x00,0x00,0x18,0x00,0x00,0x0C,0x00,0x00,0x04,0x00,0x00,0x06,0x04,0x00,0xC3,0x0F,0x80,0x3F,0x1E,0x80,0x06,0x0C,0x40,0x06,0x06,0x20,0x06,0x06,0x10,0x04,0x06,0x0C,0xFC,0x07,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"石",1*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x07,0xC0,0xFF,0x01,0x80,0x43,0x00,0x00,0x42,0x00,0x00,0x42,0x00,0x00,0x42,0x10,0x00,0xF2,0x3F,0xFC,0x4F,0x00,0x00,0x42,0x00,0x00,0x43,0x00,0x00,0x41,0x00,0x00,0x41,0x00,0x80,0x41,0x00,0x80,0x40,0x00,0x40,0x40,0x00,0x20,0x40,0x00,0x10,0x40,0x00,0x00,0x40,0x00,0x00,0x40,0x00,0x00,0x00,0x00},/*"开",2*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x18,0x00,0x00,0x18,0x07,0x80,0x18,0x04,0x80,0x09,0x00,0x80,0x88,0x03,0xC0,0xFC,0x00,0xC0,0x07,0x00,0x40,0x04,0x00,0x00,0xC6,0x00,0x00,0xFA,0x01,0x00,0xC7,0x00,0x00,0xCD,0x00,0x80,0x59,0x00,0x80,0x70,0x00,0x40,0x60,0x00,0x60,0xF0,0x00,0x30,0x8C,0x03,0x08,0x02,0x0F,0x00,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00},/*"发",3*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0xC0,0x00,0x03,0xC0,0x80,0x03,0xC0,0xC0,0x00,0x40,0x38,0x00,0x40,0x12,0x00,0xC0,0x13,0x00,0x7E,0x10,0x02,0x40,0xD0,0x07,0x60,0x30,0x02,0xE0,0x33,0x02,0x50,0x5A,0x03,0x50,0x88,0x01,0x48,0x88,0x01,0x44,0x84,0x03,0x42,0xC6,0x06,0x40,0x21,0x1E,0x40,0x00,0x3C,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"板",4*/
- };
- /**
- * 函数功能: 在 LCD 显示器上显示一个英文字符
- * 输入参数: usX:在特定扫描方向下字符的起始X坐标
- * usY :在特定扫描方向下该点的起始Y坐标
- * index: 显示在中文字模中第index个中文
- * usColor_Background :选择英文字符的背景色
- * usColor_Foreground :选择英文字符的前景色
- * font:字体选择
- * 可选值:USB_FONT_16 :16号字体
- * USB_FONT_24 :24号字体
- * 返 回 值: 无
- * 说 明:该函数必须与ascii.h内容对应使用
- */
- void LCD_DispCHAR_CH( uint16_t usX, uint16_t usY,uint8_t index,uint16_t usColor_Background, uint16_t usColor_Foreground,USB_FONT_Typdef font)
- {
- uint8_t ucTemp, ucPage, ucColumn;
-
- /* 检查输入参数是否合法 */
- assert_param(IS_FONT(font));
-
- if(font==USB_FONT_16)
- {
- LCD_OpenWindow(usX,usY,16,16);
- LCD_WRITE_CMD(0x2C);
-
- for(ucPage=0;ucPage<32;ucPage++)
- {
- ucTemp=ysdz_1616[index][ucPage];
- for(ucColumn=0;ucColumn<8;ucColumn++)
- {
- if(ucTemp&0x01)
- LCD_WRITE_DATA(usColor_Foreground);
- else
- LCD_WRITE_DATA(usColor_Background);
- ucTemp >>= 1;
- }
- }
- }
- else
- {
- LCD_OpenWindow(usX,usY,24,24);
- LCD_WRITE_CMD(0x2C);
- for(ucPage=0;ucPage<72;ucPage++)
- {
- ucTemp=ysdz_2424[index][ucPage];
- for(ucColumn=0;ucColumn<8;ucColumn++)
- {
- if(ucTemp&0x01)
- LCD_WRITE_DATA(usColor_Foreground);
- else
- LCD_WRITE_DATA(usColor_Background);
- ucTemp >>= 1;
- }
- }
- }
- }
- /**
- * 函数功能: 在 LCD 显示器上显示一个英文字符串
- * 输入参数: usX:在特定扫描方向下字符的起始X坐标
- * usY :在特定扫描方向下该点的起始Y坐标
- * start:在中文字模的顺序开始显示
- * number:要显示的中文个数
- * usColor_Background :选择英文字符的背景色
- * usColor_Foreground :选择英文字符的前景色
- * font:字体选择
- * 可选值:USB_FONT_16 :16号字体
- * USB_FONT_24 :24号字体
- * 返 回 值: 无
- * 说 明:该函数必须与ascii.h内容对应使用
- */
- void LCD_DispString_CH( uint16_t usX, uint16_t usY,uint8_t start,uint8_t number,uint16_t usColor_Background, uint16_t usColor_Foreground,USB_FONT_Typdef font)
- {
- uint8_t i=start;
- /* 检查输入参数是否合法 */
- assert_param(IS_FONT(font));
-
- do
- {
- if(font==USB_FONT_16)
- {
- if((usX+16)>LCD_DEFAULT_WIDTH)
- {
- usX = 0;
- usY += 16;
- }
- if((usY+16)>LCD_DEFAULT_HEIGTH)
- {
- usX=0;
- usY=0;
- }
- LCD_DispCHAR_CH(usX,usY,i,usColor_Background,usColor_Foreground,USB_FONT_16);
- usX+=16;
- }
- else
- {
- if((usX+24)>LCD_DEFAULT_WIDTH)
- {
- usX=0;
- usY+=24;
- }
- if((usY+24)>LCD_DEFAULT_HEIGTH)
- {
- usX=0;
- usY=0;
- }
- LCD_DispCHAR_CH(usX,usY,i,usColor_Background,usColor_Foreground,USB_FONT_24);
- usX+=24;
- }
- i++;
- }while(i<(start+number));
-
-
- }
复制代码
|