📄 graphics.cpp
字号:
#include "def.h"
#include "lcd.h"
#include "hzk.h"
#if (ASC_FONT_W == 6 && ASC_FONT_H == 12)
#include "zm6X12.h"
#define ASCK ASCII_6x12
#elif (ASC_FONT_W == 8 && ASC_FONT_H == 12)
#include "zm8X12.h"
#define ASCK ASCII_8x12
#elif (ASC_FONT_W == 8 && ASC_FONT_H == 16)
#include "zm8X16.h"
#define ASCK ASCII_8x16
#else
#error "Font define error"
#endif
void LCD_DrawHz(u8 x,u8 y,const u8 *zm,u8 mode)
{
u8 i,temp;
for(i=0;i<32;i++)
{
temp = mode?~zm[i]:zm[i];
if(i&1)
{
LCD_PutPixel8(x + 1, y + (i >> 1), temp);
}
else
{
LCD_PutPixel8(x, y + (i >> 1), temp);
}
}
}
// 向LCD中写一个ASCII字符的点阵
void LCD_Putc(u8 x, u8 y, u8 chASC, u8 mode)
{
u8 i;
u8 zm; // 指向字母点阵数据
for(i=0;i<ASC_FONT_H;i++)
{
zm = ASCK[chASC-' '][i];
zm = mode? ~zm : zm;
LCD_PutPixel8(x, y + i + (16-ASC_FONT_H), zm);
}
}
void LCD_PutHz(u8 x, u8 y, u16 charactor, u8 mode)
{
switch(charactor)
{
case '西': LCD_DrawHz(x, y, HZ_xi, mode);break;
case '北': LCD_DrawHz(x, y, HZ_bei, mode);break;
case '工': LCD_DrawHz(x, y, HZ_gong, mode);break;
case '业': LCD_DrawHz(x, y, HZ_ye, mode);break;
case '大': LCD_DrawHz(x, y, HZ_da, mode);break;
case '学': LCD_DrawHz(x, y, HZ_xue, mode);break;
default: break;
}
}
void LCD_Puts(u8 x, u8 y, const u8 * str , u8 mode)
{
u8 i=0;
for(;*str!=0;str++)
{
if(*str<0x7F)
{
LCD_Putc(x + i, y, *str, mode); /*是ASCII字符*/
i+= 1;
}
else
{
U16 hz = *str;
hz <<= 8;
str++;
hz+=*str; /*将汉字GB码整合为int*/
LCD_PutHz(x + i, y, (u16) hz, mode); /*是汉字*/
i+=2;
}
}
}
void LCD_DrawRec(u8 x, u8 y, u8 width, u8 height )
{
u8 i;
for(i=0;i<height;i++)
{
LCD_PutPixel8(x, y + i, 0x80);
LCD_PutPixel8(x + width -1, y + i, 0x01);
}
for(i=0;i<width;i++)
{
LCD_PutPixel8(x + i, y, 0xff);
LCD_PutPixel8(x + i, y + height - 1, 0xff);
}
}
void LCD_FillRec(u8 x, u8 y, u8 width, u8 height, u8 mode )
{
u8 i,j;
u8 color;
color = mode?0xff:0x00;
for(j=0;j<height;j++)
for(i=0;i<width;i++)
{
LCD_PutPixel8(x + i, y + j, color);
}
}
void LCD_DrawCol(u8 x, u8 y, u8 height, u8 mode )
{
u8 i;
u8 color;
color = mode?0x80:0x00;
for(i=0;i<height;i++)
{
LCD_PutPixel8(x, y + i, color);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -