|
本帖最后由 qizc 于 2016-5-26 11:28 编辑
MAPS-K64四色板自带的DEMO内容十分丰富,但是有些函数只是实现了功能,并不完善。
比如LCD的驱动函数,只是能显示字符串,并不能方便的修改字体颜色,背景颜色等。
想画线画图这样的高级功能更是没有实现。
今先优化一下字符串显示函数(解决上次背景色不能设置的问题),使其能方便的更改字体与背景的颜色。
上次没有实现的问题出在函数中颜色定义的为unsigned char,而颜色参数为两个字节,所以不能有效设置。
把所有涉及的颜色的参数改为unsigned short类型后,问题得到解决,再添加字体颜色参数。
先上效果图:
再上代码:
lcdc.c:- void LCDC_DrawPixel(uint16_t x, uint16_t y, unsigned short color)
- {
- lcdc_send_cmd(0x2A);
- lcdc_send_data(x>>8);
- lcdc_send_data(x&0xFF);
- lcdc_send_cmd(0x2B);
- lcdc_send_data(y>>8);
- lcdc_send_data(y&0xFF);
- lcdc_send_cmd(0x2c);
- lcdc_send_data(color);
-
- }
复制代码- void LCDC_DrawChar_6x8(unsigned int x, unsigned int y, unsigned short bc,unsigned short fc, unsigned char c)
- {
- int k = 0, i, j;
-
- if (0x1F < c && c < 0x90)
- {
- k = (c - 0x20)*8;
- for (i = 0; i < 8; i++)
- {
- for (j = 0; j < 6; j++)
- {
- if (Font_6x8_h[k+i] & (0x01<<(7-j)))
- {
- LCDC_DrawPixel(x+j, y+i, fc);
- }
- else
- {
- if (bc)
- {
- LCDC_DrawPixel(x+j, y+i, bc);
- }
- }
- }
- }
- }
- }
复制代码- void LCDC_DrawChar_8x16(unsigned int x, unsigned int y, unsigned short backcolor,unsigned short fc, unsigned char c)
- {
- int k = 0, i, j;
-
- if (0x1F<c && c<0x90)
- {
- k = (c)*16;
- for (i=0; i<16; i++)
- {
- for (j=0; j<8; j++)
- {
- if (Font_8x16_h[k+i] & 0x01<<(7-j))
- {
- LCDC_DrawPixel(x+j, y+i, fc);
- }
- else
- {
- if (backcolor)
- {
- LCDC_DrawPixel(x+j, y+i, backcolor);
- }
- }
- }
- }
- }
- }
复制代码
代码上传失败,见下面楼层。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|