在线时间2402 小时
UID3327992
注册时间2018-4-5
NXP金币3178
TA的每日心情 | 慵懒 16 小时前 |
---|
签到天数: 1941 天 [LV.Master]伴坛终老
版主
- 积分
- 17301
- 最后登录
- 2024-4-26
|
极光GUI板子是上一次月亮板升级版,硬件PCB是由@xiaoshen-372360兄弟主刀画的板子。看这里:
【极光】-一个基于LPC845的GUI板子
https://www.nxpic.org.cn/module/forum/thread-630580-1-1.html
(出处: 恩智浦技术社区) 板子放了好久一直没空玩。这几天抽空把触摸,液晶屏和Flash的驱动都弄好了。下面给大家展示一下效果吧。
板上已完成:LCD驱动;lcd触摸驱动;spi flash;串口;LED灯和按键。调试时LCD的DC脚和背光控制脚使用的引脚正好是I2C0的脚,没有内部上拉,板上又没有外部上拉,没办法只好飞线加了上拉电阻才搞好。
图上飞了2个电阻。
spiflash使用上次月亮板的下载算法,可以将字体文件放入spiflash中实现各种字体显示。
字体控制显示,直接加载字体点阵文件到固件中:
- #define lcd_color_t uint16_t
- /* type define ------------------------------------------------------------*/
- typedef struct _lcd_font
- {
- uint8_t font_height; //字库通用高度
- char * pfont_buff; //字库buff
- char * pfont_filename; //字库文件
- uint8_t (* get_font_w)(uint32_t ch); //获取指定字符宽度
- void (* draw_char)(int16_t x,int16_t y,uint32_t ch); //指定字符描点
- }lcd_font_t;
- typedef struct _lcd_font_display
- {
- lcd_font_t *pfont; //字库索引
- lcd_color_t font_fore; //字体前景颜色
- lcd_color_t font_back; //字体背景颜色
- int16_t font_x; //字符显示范围起点x
- int16_t font_y; //字符显示范围起点y
- uint16_t font_w; //字符显示范围宽度
- uint16_t font_h; //字符显示范围高度
- }lcd_font_display_t;
复制代码
- #include "lcd_font.h"
- #include "drv_w25qxx.h"
- #define INCBIN_OUTPUT_SECTION "res.flash.* "
- #define INCBIN_OUTPUT_DATA_SECTION ".rodata"
- #define INCBIN_OUTPUT_SIZE_SECTION ".rodata"
- #include "incbin.h"
- //__attribute__((used))
- //__attribute__((aligned(4)))
- //__attribute__((section("res.flash.*")))
- INCBIN(ASC16x8, "../device/lcd_font/ASC16.bin"); //OK
- //INCBIN(ASC16x8, "..\\\\font\\\\ASC16.bin"); //OK
- INCBIN(HZK16x16, "../device/lcd_font/HZK16.bin"); //OK
- //INCBIN(ASC24x12, "../device/lcd_font/ASC24.bin"); //OK
- //INCBIN(HZK24x24, "../device/lcd_font/HZK24.bin"); //OK
- //INCBIN(ASC32x16, "../device/lcd_font/ASC32.bin"); //OK
- //INCBIN(HZK32x32, "../device/lcd_font/HZK32.bin"); //OK
- int GetFlashHZKCode(uint32_t addr,uint32_t ch,uint8_t * pBuffer,uint32_t lenght)
- {
- uint32_t pos;
- uint8_t H8bit = (ch >> 8) & 0x00ff; /* 取高8位数据 */
- uint8_t L8bit = ch & 0x00FF; /* 取低8位数据 */
- if(ch < 0x7f) //ASCII
- {
- pos = ch * lenght;
- }else if((H8bit > 0xa0)&&(L8bit >0xa0)) //中文字符
- {
- pos = ((H8bit - 0x000000a1) * 94 + (L8bit - 0x000000a1)) * lenght;
- }else return 1;
- W25QXX_Read(addr + pos, pBuffer, lenght);
-
- return 0;
- }
- ///////////////////////////////////////////////////////////////////////
- uint8_t ucBuffer[8*64] = {0}; //512Byte,支持64*64点阵字体缓存
- static void lcd_disp_hz(int16_t x, int16_t y, uint32_t ch)
- {
- uint32_t lenght;
- uint8_t f_width,f_height;
- uint8_t ucPage = ch >> 8; /* 取高8位数 */
- uint8_t ucColum = ch & 0x00FF; /* 取低8位数 */
- lcd_font_t *pfont;
-
- pfont = lcd_get_font();
- f_width = pfont->get_font_w(ch);
- f_height = pfont->font_height;
- lenght = ((f_width + 7)>>3) * f_height;
- if(f_height > f_width)
- GetFlashHZKCode((uint32_t)pfont->pfont_buff, ch, ucBuffer, lenght); //
- else
- GetFlashHZKCode((uint32_t)pfont->pfont_filename, ch, ucBuffer, lenght); //
- Lcd_CharDot(x,y,f_width,f_height,
- ucBuffer,
- lcd_get_font_color_fore(),
- lcd_get_font_color_back()
- );
- }
- uint8_t hz_get_font_w(uint32_t ch) //获取指定字符宽度
- {
- uint8_t ucPage = ch >> 8; /* 取高8位数 */
- uint8_t ucColum = ch & 0x00FF; /* 取低8位数 */
- lcd_font_t *pfont;
- pfont = lcd_get_font();
- if(ch < 0x7f) //ASCII
- {
- return (pfont->font_height >>1);
- }else if((ucPage > 0xa0)&&(ucColum >0xa0)) //中文字符
- {
- return pfont->font_height;
- }else
- {
- return 0;
- }
- }
- const lcd_font_t Font_HZK16x16 =
- {
- 16,
- (char *)((uint32_t)gASC16x8Data - 0x30000000),
- (char *)((uint32_t)gHZK16x16Data - 0x30000000),
- hz_get_font_w,
- lcd_disp_hz,
- };
- //const lcd_font_t Font_HZK24x24 =
- //{
- // 24,
- // (char *)((uint32_t)gASC24x12Data - 0x30000000),
- // (char *)((uint32_t)gHZK24x24Data - 0x30000000),
- // hz_get_font_w,
- // lcd_disp_hz,
- //};
- //const lcd_font_t Font_HZK32x32 =
- //{
- // 32,
- // (char *)((uint32_t)gASC32x16Data - 0x30000000),
- // (char *)((uint32_t)gHZK32x32Data - 0x30000000),
- // hz_get_font_w,
- // lcd_disp_hz,
- //};
复制代码
程序:
lpc845_moon_v2.zip
(6.21 MB, 下载次数: 2, 售价: 10 NXP金币)
|
|