完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
# include "LCD_GUI.h"
# include "LCD_Driver.h" # include "LCD_Font.h" const unsigned char HZtable[][32]= { {0x00,0x00,0x79,0xF8,0x09,0x08,0x09,0x08,0x79,0xF8,0x40,0x40,0x43,0xFC,0x42,0x44, 0x7A,0x44,0x0A,0x44,0x0B,0xFC,0x08,0x40,0x08,0x48,0x08,0x44,0x28,0x7E,0x13,0xC4},/*"强",0*/ {0x10,0x00,0x11,0xFE,0xFE,0x00,0x20,0xFC,0x20,0x84,0x50,0x84,0x50,0xFC,0xFE,0x00, 0x11,0xFE,0x11,0x22,0x1D,0xFE,0xF1,0x22,0x11,0x22,0x11,0xFE,0x11,0x02,0x10,0x00},/*"辐",1*/ {0x08,0x08,0x10,0x08,0x3F,0x08,0x21,0x08,0x3F,0xFE,0x21,0x08,0x3F,0x08,0x21,0x48, 0x21,0x28,0x7F,0x28,0x05,0x28,0x09,0x08,0x11,0x08,0x21,0x08,0x45,0x28,0x02,0x10},/*"射",2*/ {0x00,0x00,0x7D,0xFE,0x10,0x20,0x10,0x20,0x10,0x60,0x7C,0x60,0x10,0xB0,0x10,0xA8, 0x11,0x24,0x1D,0x26,0x62,0x22,0x04,0x22,0x08,0x20,0x00,0x20,0x00,0x20,0x00,0x20},/*"环",3*/ {0x00,0x40,0x20,0x20,0x23,0xFC,0x21,0x08,0x20,0x90,0xFB,0xFC,0x20,0x00,0x21,0xF8, 0x21,0x08,0x21,0xF8,0x21,0x08,0x39,0xF8,0xE0,0x90,0x40,0x92,0x01,0x12,0x02,0x0E},/*"境",4*/ {0x01,0x00,0x00,0x80,0x3F,0xFC,0x20,0x00,0x22,0x00,0x21,0x08,0x30,0x8C,0x28,0xC8, 0x24,0x90,0x24,0x90,0x26,0x20,0x44,0x20,0x40,0x40,0x5F,0xFE,0x80,0x00,0x00,0x00},/*"应",5*/ {0x04,0x00,0x04,0x00,0x0F,0xE0,0x08,0x40,0x10,0x80,0x2F,0xF0,0x00,0x10,0x0F,0xF0, 0x00,0x10,0x0F,0xF0,0x01,0x00,0x28,0x84,0x28,0x92,0x68,0x12,0x07,0xF0,0x00,0x00},/*"急",6*/ {0x10,0x20,0x18,0x20,0x10,0x20,0x20,0x20,0x3E,0x20,0x22,0x30,0x62,0x28,0x52,0x26, 0x94,0x24,0x14,0x20,0x08,0x20,0x14,0x20,0x23,0x20,0x40,0xC0,0x80,0x3E,0x00,0x00},/*"处",7*/ {0x3F,0xF8,0x24,0x48,0x24,0x48,0x3F,0xF8,0x01,0x00,0x7F,0xFC,0x02,0x00,0x1F,0xF0, 0x10,0x10,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x10,0xFF,0xFE},/*"置",8*/ {0x10,0x00,0x10,0xF8,0x10,0x88,0xFE,0x88,0x10,0x88,0x10,0x88,0x38,0x88,0x34,0x88, 0x54,0x88,0x50,0x88,0x91,0x08,0x11,0x0A,0x12,0x0A,0x12,0x0A,0x14,0x06,0x10,0x00},/*"机",9*/ {0x3E,0x7C,0x22,0x44,0x22,0x44,0x3E,0x7C,0x01,0x10,0x01,0x08,0xFF,0xFC,0x06,0xC0, 0x18,0x30,0xE0,0x0E,0x3E,0xFC,0x22,0x88,0x22,0x88,0x22,0x88,0x3E,0xF8,0x00,0x00},/*"器",10 :*/ {0x10,0x40,0x10,0x20,0x20,0x20,0x23,0xFE,0x48,0x40,0xF8,0x88,0x11,0x04,0x23,0xFE, 0x40,0x92,0xF8,0x90,0x40,0x90,0x00,0x90,0x19,0x12,0xE1,0x12,0x42,0x0E,0x04,0x00},/*"统",11;*/ {0x00,0x00,0x27,0xF8,0x14,0x08,0x14,0x08,0x87,0xF8,0x44,0x08,0x44,0x08,0x17,0xF8, 0x11,0x20,0x21,0x20,0xE9,0x24,0x25,0x28,0x23,0x30,0x21,0x20,0x2F,0xFE,0x00,0x00},/*"湿",12*/ {0x01,0x00,0x00,0x80,0x3F,0xFE,0x22,0x20,0x22,0x20,0x3F,0xFC,0x22,0x20,0x22,0x20, 0x23,0xE0,0x20,0x00,0x2F,0xF0,0x24,0x10,0x42,0x20,0x41,0xC0,0x86,0x30,0x38,0x0E},/*"度",13*/ {0x00,0x00,0x23,0xF8,0x12,0x08,0x12,0x08,0x83,0xF8,0x42,0x08,0x42,0x08,0x13,0xF8, 0x10,0x00,0x27,0xFC,0xE4,0xA4,0x24,0xA4,0x24,0xA4,0x24,0xA4,0x2F,0xFE,0x00,0x00},/*"温",14*/ {0x60,0x00,0x91,0xF4,0x96,0x0C,0x6C,0x04,0x08,0x04,0x18,0x00,0x18,0x00,0x18,0x00, 0x18,0x00,0x18,0x00,0x18,0x00,0x08,0x00,0x0C,0x04,0x06,0x08,0x01,0xF0,0x00,0x00},/*"℃",15*/ {0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xF8,0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8, 0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x0A,0x01,0x02,0x01,0x02,0x00,0xFE},/*"电",16*/ {0x00,0x00,0x3F,0xFE,0x20,0x00,0x20,0x80,0x20,0x80,0x20,0x80,0x20,0x80,0x2F,0xFC, 0x20,0x80,0x20,0x80,0x20,0x90,0x20,0x88,0x20,0x88,0x40,0x80,0x5F,0xFE,0x80,0x00},/*"压",17*/ {0x20,0x20,0x20,0x28,0x20,0x24,0x23,0xFE,0xF8,0x20,0x22,0xA0,0x72,0xA4,0x6A,0xA4, 0x67,0xE8,0xA2,0xA8,0xA2,0x90,0x24,0x92,0x24,0xAA,0x28,0x4A,0x20,0x86,0x20,0x02},/*"械",18 B*/ {0x3C,0x20,0x25,0xFE,0x3C,0x88,0x21,0xFE,0x7C,0x20,0xA5,0xFE,0x3C,0x20,0x00,0x20, 0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x10,0x10,0x50,0x10,0x20},/*"臂",19 C*/ {0x08,0x00,0x08,0x80,0x0B,0x3C,0x12,0x24,0x12,0x24,0x32,0x24,0x32,0x24,0x52,0x24, 0x92,0x24,0x12,0x24,0x12,0xB4,0x13,0x28,0x12,0x20,0x10,0x20,0x10,0x20,0x10,0x20},/*"仰",20 D*/ {0x10,0x40,0x10,0x20,0x17,0xFE,0x24,0x00,0x24,0x88,0x64,0x88,0x65,0x08,0xA5,0x7E, 0x27,0x08,0x25,0x48,0x25,0x28,0x25,0x28,0x29,0x08,0x29,0x08,0x31,0x28,0x21,0x10},/*"俯",21 E*/ {0x02,0x00,0x02,0x00,0x02,0x00,0xFF,0xFE,0x04,0x00,0x04,0x00,0x04,0x00,0x08,0x00, 0x0F,0xF8,0x10,0x80,0x10,0x80,0x20,0x80,0x40,0x80,0x80,0x80,0x3F,0xFE,0x00,0x00},/*"左",22 F*/ {0x20,0x20,0x20,0x20,0x20,0x20,0xFD,0xFC,0x40,0x20,0x50,0x40,0x93,0xFE,0xFC,0x40, 0x10,0x80,0x11,0xFC,0x1C,0x04,0xF0,0x88,0x50,0x50,0x10,0x20,0x10,0x10,0x10,0x10},/*"转",23 G*/ {0x02,0x00,0x02,0x00,0x02,0x00,0xFF,0xFE,0x04,0x00,0x04,0x00,0x08,0x00,0x08,0x00, 0x1F,0xF8,0x28,0x08,0x48,0x08,0x88,0x08,0x08,0x08,0x08,0x08,0x0F,0xF8,0x08,0x08},/*"右",24 H*/ {0x10,0x80,0x10,0x40,0x17,0xFC,0x20,0x00,0x23,0xF8,0x62,0x08,0x63,0xF8,0xA0,0x00, 0x2F,0xFE,0x28,0x02,0x23,0xF8,0x20,0x40,0x20,0x40,0x20,0x40,0x21,0x40,0x20,0x80},/*"停",25 I*/ {0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x11,0x00,0x11,0x00,0x11,0xF8,0x11,0x00, 0x11,0x00,0x11,0x00,0x11,0x00,0x11,0x00,0x11,0x00,0x11,0x00,0xFF,0xFE,0x00,0x00},/*"止",26 J*/ {0x10,0x00,0x13,0xFC,0x10,0x84,0x10,0x88,0xFC,0x88,0x10,0x90,0x30,0x9C,0x38,0x84, 0x55,0x44,0x55,0x44,0x91,0x28,0x11,0x28,0x12,0x10,0x12,0x28,0x14,0x44,0x11,0x82},/*"极",27 K*/ {0x00,0x00,0x7B,0xF8,0x4A,0x08,0x52,0x08,0x53,0xF8,0x62,0x08,0x52,0x08,0x4B,0xF8, 0x4A,0x44,0x4A,0x48,0x6A,0x30,0x52,0x20,0x42,0x10,0x42,0x88,0x43,0x06,0x42,0x00},/*"限",28 L*/ {0x10,0x00,0x11,0xF0,0x11,0x10,0x11,0x10,0xFD,0x10,0x11,0x10,0x31,0x10,0x39,0x10, 0x55,0x10,0x55,0x10,0x91,0x10,0x11,0x12,0x11,0x12,0x12,0x12,0x12,0x0E,0x14,0x00},/*"机",29 M*/ {0x02,0x00,0x04,0x00,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x10,0x1F,0xF2,0x10,0x14, 0x10,0x18,0x7F,0xF0,0x00,0x50,0x00,0x90,0x03,0x10,0x1C,0x10,0xE0,0x50,0x00,0x20},/*"身",30 N*/ {0x10,0x10,0x08,0x10,0x08,0x20,0xFF,0xFE,0x00,0x00,0x3E,0x08,0x22,0x48,0x22,0x48, 0x3E,0x48,0x22,0x48,0x22,0x48,0x3E,0x48,0x22,0x08,0x22,0x08,0x2A,0x28,0x24,0x10},/*"前",31 O*/ {0x00,0x90,0x20,0x90,0x10,0x90,0x13,0xFC,0x00,0x90,0x00,0x90,0xF0,0x90,0x17,0xFE, 0x10,0x90,0x10,0x90,0x11,0x10,0x11,0x10,0x12,0x10,0x28,0x00,0x47,0xFE,0x00,0x00},/*"进",32 P*/ {0x00,0x10,0x00,0xF8,0x1F,0x00,0x10,0x00,0x10,0x00,0x1F,0xFE,0x10,0x00,0x10,0x00, 0x10,0x00,0x17,0xF8,0x14,0x08,0x24,0x08,0x24,0x08,0x44,0x08,0x87,0xF8,0x04,0x08},/*"后",33 Q*/ {0x03,0xF8,0x22,0x08,0x12,0x08,0x13,0xF8,0x02,0x08,0x02,0x08,0xF3,0xF8,0x12,0x44, 0x12,0x28,0x12,0x10,0x12,0x88,0x13,0x04,0x12,0x04,0x28,0x00,0x47,0xFE,0x00,0x00},/*"退",34 R*/ {0x00,0x00,0x7F,0xFC,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xFF,0xFE, 0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x10,0x20,0x10,0x20,0x20,0x20,0x40,0x20},/*"开",35 S*/ {0x10,0x10,0x08,0x10,0x08,0x20,0x00,0x00,0x3F,0xF8,0x01,0x00,0x01,0x00,0x01,0x00, 0xFF,0xFE,0x01,0x00,0x02,0x80,0x02,0x80,0x04,0x40,0x08,0x20,0x30,0x18,0xC0,0x06},/*"关",36 T*/ {0x01,0x00,0x02,0x00,0x04,0x00,0x1F,0xF0,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0xF0, 0x10,0x10,0x10,0x10,0x1F,0xF0,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0xF0,0x10,0x10},/*"自",37 U*/ {0x00,0x40,0x00,0x40,0x7C,0x40,0x00,0x40,0x01,0xFC,0x00,0x44,0xFE,0x44,0x20,0x44, 0x20,0x44,0x20,0x84,0x48,0x84,0x44,0x84,0xFD,0x04,0x45,0x04,0x02,0x28,0x04,0x10},/*"动",38 V*/ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",39 W*/ {0x04,0x00,0x04,0x00,0x0F,0xE0,0x08,0x40,0x10,0x80,0x2F,0xF0,0x00,0x10,0x0F,0xF0, 0x00,0x10,0x0F,0xF0,0x01,0x00,0x28,0x84,0x28,0x92,0x68,0x12,0x07,0xF0,0x00,0x00},/*"急",40 X*/ {0x08,0x40,0x0C,0x20,0x0B,0xFE,0x10,0x00,0x11,0xF8,0x31,0x08,0x51,0xF8,0x90,0x00, 0x17,0xFE,0x14,0x02,0x11,0xFC,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0xA0,0x10,0x40},/*"停",41 Y*/ {0x10,0xA0,0x10,0x90,0x10,0x98,0x90,0x88,0x50,0x80,0x5F,0xFE,0x10,0xA0,0x10,0xA0, 0x31,0x20,0x51,0x20,0x91,0x10,0x12,0x10,0x12,0x08,0x14,0x0E,0x18,0x04,0x10,0x00},/*"状",42 Z*/ {0x01,0x00,0x01,0x00,0x7F,0xFC,0x01,0x00,0x02,0x80,0x02,0x40,0x05,0x20,0x08,0x98, 0x30,0x06,0x01,0x00,0x04,0x88,0x24,0x84,0x24,0x12,0x64,0x12,0x43,0xF0,0x00,0x00},/*"态",43 [*/ {0x00,0x78,0x47,0x80,0x21,0x08,0x24,0x90,0x02,0x20,0x03,0xF8,0xE4,0x40,0x20,0x40, 0x27,0xFC,0x20,0x40,0x22,0x48,0x22,0x48,0x23,0xF8,0x50,0x00,0x8F,0xFE,0x00,0x00},/*"遥",44 */ {0x10,0x00,0x10,0x20,0x10,0x10,0xFD,0xFE,0x11,0x04,0x10,0x50,0x14,0x8C,0x19,0x04, 0x30,0x00,0xD1,0xFC,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x53,0xFE,0x20,0x00},/*"控",45 ]*/ {0x10,0xA0,0x10,0x90,0x10,0x98,0x90,0x88,0x50,0x80,0x5F,0xFE,0x10,0xA0,0x10,0xA0, 0x31,0x20,0x51,0x20,0x91,0x10,0x12,0x10,0x12,0x08,0x14,0x0E,0x18,0x04,0x10,0x00},/*"状",46 ^*/ {0x01,0x00,0x01,0x00,0x7F,0xFC,0x01,0x00,0x02,0x80,0x02,0x40,0x05,0x20,0x08,0x98, 0x30,0x06,0x01,0x00,0x04,0x88,0x24,0x84,0x24,0x12,0x64,0x12,0x43,0xF0,0x00,0x00},/*"态",47 -*/ {0x01,0x00,0x01,0x80,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x02,0x80,0x02,0x80, 0x04,0x80,0x04,0x40,0x08,0x60,0x08,0x30,0x10,0x18,0x20,0x0E,0x40,0x04,0x00,0x00},/*"人",48 `*/ {0x00,0xF8,0x3F,0x00,0x04,0x00,0x08,0x20,0x10,0x40,0x3F,0x80,0x01,0x00,0x06,0x10, 0x18,0x08,0x7F,0xFC,0x01,0x04,0x09,0x20,0x11,0x10,0x21,0x08,0x45,0x04,0x02,0x00},/*"系",49 a*/ {0x01,0xFC,0x3C,0x44,0x24,0x44,0x24,0x44,0x24,0x94,0x3D,0x08,0x26,0xFC,0x24,0x84, 0x3C,0x84,0x24,0xFC,0x00,0x84,0x28,0x88,0x24,0x44,0x66,0x66,0xC2,0x22,0x00,0x00},/*"照",50 b*/ {0x00,0xFC,0x7C,0x84,0x44,0x84,0x44,0x84,0x44,0xFC,0x7C,0x84,0x44,0x84,0x44,0x84, 0x44,0xFC,0x7C,0x84,0x00,0x84,0x01,0x04,0x01,0x04,0x02,0x04,0x04,0x14,0x00,0x08},/*"明",51 c*/ }; void LCD_WriteMenuChar(unsigned int start_x, unsigned int start_y, unsigned int char_clr, unsigned int bk_clr, unsigned char char_data ) { unsigned char show_cnt = 0; unsigned char bit_cnt = 0; start_x <<= 3; //一个英文字符占区域为8*16 start_y <<= 4; char_data = Get_CharOffset(char_data); //获取字模显示的偏移量 for(show_cnt = 0; show_cnt < 16; show_cnt ++) { //-> 1010 1100 -> //-> 1100 1000 ->... for(bit_cnt = 0; bit_cnt < 8; bit_cnt ++) { if( Letter[char_data][show_cnt] & BIT(7 - bit_cnt) ) { LCD_DrawPoint(start_x + bit_cnt, start_y + show_cnt, char_clr); } else { //获取背景色,并进行半透明转换 //temp_clr = LCD_RGB565Trans(LCD_Get_Point(start_x + bit_cnt, start_y + show_cnt), // bk_clr); bk_clr = LCD_GetPoint(start_x + bit_cnt, start_y + show_cnt); LCD_DrawPoint(start_x + bit_cnt, start_y + show_cnt, bk_clr); } } } } unsigned char Get_CharOffset(unsigned char char_data) { if(char_data >= ' ' && char_data <= '}') { char_data -= ' '; //字符偏移从空格开始 } else { char_data = ' '; //如无匹配字符以空格代替 } return char_data; } /* void LCD_WriteString(unsigned char start_x, unsigned char start_y, unsigned int char_clr, unsigned int bk_clr, const unsigned char *p_str) { while(*p_str) { LCD_WriteChar(start_x, start_y, //调用显示单个字符显示函数 char_clr, bk_clr, *p_str); if(start_x < 29) { start_x ++; } else if(start_y < 19) { start_x = 0; start_y ++; } else { start_x = 0; start_y = 0; } p_str ++; //指针自加 } } */ void Set_CharWindow(unsigned int Start_X, unsigned int Start_Y) { unsigned int X_Region = 0; unsigned int Y_Region = 0; #if LCD_CHAR_HORIZONTAL > 0 Start_X <<= 3; //一个英文字符占区域为8*16 Start_Y <<= 4; X_Region = Start_X + 7; //一行可以显示30个字符 Y_Region = Start_Y + 15; //一列可以显示20个字符 #else Start_X <<= 4; //一个英文字符占区域为8*16 Start_Y <<= 3; X_Region = Start_X + 15; //一行可以显示15个字符 Y_Region = Start_Y + 7; //一列可以显示40个字符 #endif LCD_SetWindow(Start_X, Start_Y, X_Region, Y_Region); } /* void LCD_WriteChar(unsigned int Start_X, unsigned int Start_Y, unsigned int Char_Clr, unsigned int Bk_Clr, unsigned char ch_Char) { unsigned char show_cnt = 0; unsigned char bit_cnt = 0; ch_Char = Get_CharOffset(ch_Char); //获取字模显示的偏移量 Set_CharWindow(Start_X, Start_Y); //设置起始坐标,xy是8*16的方格坐标 LCD_WriteGRAM_EN(); for(show_cnt = 0; show_cnt < 16; show_cnt ++) { //-> 1010 1100 -> //-> 1100 1000 ->... for(bit_cnt = 0; bit_cnt < 8; bit_cnt ++) { if( Letter[ch_Char][show_cnt] & BIT(7 - bit_cnt) ) { LCD_DATA_OUT(Char_Clr); } else { LCD_DATA_OUT(Bk_Clr); } } } LCD_WR_END(); LCD_SetWindow(0, 0, X_END, Y_END); //恢复全屏作图区域 } */ void LCD_WriteChar(unsigned int Start_X, unsigned int Start_Y, unsigned int Char_Clr, unsigned int Bk_Clr, unsigned char ch_Char) { unsigned char show_cnt = 0; unsigned char bit_cnt = 0; ch_Char = Get_CharOffset(ch_Char); //获取字模显示的偏移量 Set_CharWindow(Start_X, Start_Y); //设置起始坐标,xy是8*16的方格坐标 LCD_WriteGRAM_EN(); for(show_cnt = 0; show_cnt < 16; show_cnt ++) { //-> 1010 1100 -> //-> 1100 1000 ->... for(bit_cnt = 0; bit_cnt < 8; bit_cnt ++) { #if LCD_CHAR_HORIZONTAL > 0 if( Letter[ch_Char][show_cnt] & BIT(7 - bit_cnt) ) { LCD_DATA_OUT(Char_Clr); } else { LCD_DATA_OUT(Bk_Clr); } #else if( Letter[ch_Char][16-show_cnt] & BIT(7 - bit_cnt) ) { LCD_DATA_OUT(Char_Clr); } else { LCD_DATA_OUT(Bk_Clr); } #endif } } LCD_WR_END(); LCD_SetWindow(0, 0, X_END, Y_END); //恢复全屏作图区域 } void Set_HZWindow(unsigned int Start_X, unsigned int Start_Y) { unsigned int X_Region = 0; unsigned int Y_Region = 0; #if LCD_CHAR_HORIZONTAL > 0 Start_X <<= 4; //一个英文字符占区域为8*16 Start_Y <<= 4; X_Region = Start_X + 15; //一行可以显示30个字符 Y_Region = Start_Y + 15; //一列可以显示20个字符 #else Start_X <<= 4; //一个英文字符占区域为8*16 Start_Y <<= 4; X_Region = Start_X + 15; //一行可以显示15个字符 Y_Region = Start_Y + 15; //一列可以显示40个字符 #endif LCD_SetWindow(Start_X, Start_Y, X_Region, Y_Region); } void LCD_WriteHZ(unsigned int Start_X, unsigned int Start_Y, unsigned int Char_Clr, unsigned int Bk_Clr, unsigned char *p_str) { unsigned char nowchar = *p_str ++; while( nowchar != 0 ) { unsigned char show_cnt = 0; unsigned char bit_cnt = 0; signed char temp = 0; nowchar -= 48; Set_HZWindow(Start_X, Start_Y); //设置起始坐标,xy是16*16的方格坐标 LCD_WriteGRAM_EN(); for(show_cnt = 0; show_cnt < 32; show_cnt ++) { //-> 1010 1100 -> //-> 1100 1000 ->... if(show_cnt & BIT(0)) { temp = 1; } else { temp = -1; } for(bit_cnt = 0; bit_cnt < 8; bit_cnt ++) { #if LCD_CHAR_HORIZONTAL > 0 if( HZtable[nowchar][show_cnt] & BIT(7 - bit_cnt) ) { LCD_DATA_OUT(Char_Clr); } else { LCD_DATA_OUT(Bk_Clr); } #else if( HZtable[nowchar][31-show_cnt + temp] & BIT(7-bit_cnt) ) { LCD_DATA_OUT(Char_Clr); } else { LCD_DATA_OUT(Bk_Clr); } #endif } } LCD_WR_END(); LCD_SetWindow(0, 0, X_END, Y_END); //恢复全屏作图区域 nowchar = *p_str ++; Start_Y += 1; } } void LCD_WriteString(unsigned char Start_X, unsigned char Start_Y, unsigned int Char_Clr, unsigned int Bk_Clr, unsigned char *p_str, unsigned char is_transp) { #if LCD_CHAR_HORIZONTAL > 0 #else Start_X = CHAR_X_NUM - Start_X - 1; Start_X = (s8)Start_X; #endif while(*p_str) { //计算坐标 if(*p_str == 'n') //换行 { Start_X = 0; Start_Y ++; p_str ++; //调过换行符,不用显示 continue; //查询下一个字符 } else //未遇到换行符则按正常显示坐标自加 { //显示字符 if(is_transp) //如果字符不为0则限制显示定长个字符 { //调用显示单个字符显示函数(较慢) LCD_WriteMenuChar(Start_X, Start_Y, Char_Clr, Bk_Clr, *p_str); } else { LCD_WriteChar(Start_X, Start_Y, //调用显示普通字符显示函数(较快) Char_Clr, Bk_Clr, *p_str); } #if LCD_CHAR_HORIZONTAL > 0 Start_X ++; if(Start_X == CHAR_X_NUM) { Start_X = 0; Start_Y ++; if(Start_Y == CHAR_Y_NUM) { Start_Y = 0; } } #else Start_Y ++; if(Start_Y == CHAR_Y_NUM) { Start_Y = 0; Start_X --; if(Start_X < 0) { Start_X = CHAR_X_NUM - 1; } } #endif } //字符串指针自加 p_str ++; } } //////////////////////////////////////////// //文本输出函数,前景色和背景色已经固定,使用块 //写,目的是达到的最快的文本显示 void LCD_Print(const unsigned char *p_str) { static unsigned char XLine = 0; static unsigned char YLine = 0; //设置画笔前景和背景色 # define CHAR_CLR 0x0000 # define BK_CLR 0x07E0 while(*p_str) { //计算坐标 if(*p_str == 'n') //换行 { XLine = 0; YLine ++; p_str ++; //调过换行符,不用显示 continue; //查询下一个字符 } else //未遇到换行符则按正常显示坐标自加 { //如果不是换行符则显示字符 LCD_WriteChar(XLine, YLine, //调用显示普通字符显示函数(较快) CHAR_CLR, BK_CLR, *p_str); #if LCD_CHAR_HORIZONTAL > 0 XLine ++; //行号加1 if(XLine == CHAR_X_NUM) { XLine = 0; //写满一行后行号清零 YLine ++; //写满一行后列号加1 if(YLine == CHAR_Y_NUM) { YLine = 0; LCD_Clear(BK_CLR); } } #else YLine ++; //行号加1 if(YLine == CHAR_Y_NUM) { YLine = 0; //写满一行后行号清零 XLine ++; //写满一行后列号加1 if(XLine == CHAR_X_NUM) { XLine = 0; LCD_Clear(BK_CLR); } } #endif } //字符串指针自加 p_str ++; } } //数字显示函数 const unsigned char Number[] = {'0', '1', '2', '3','4', '5', '6', '7','8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; void LCD_WriteNumber(unsigned long data, unsigned char ch_Dot) { # define DIGIT_SHOW 10 //最多可以显示10位 signed char digit_sum=0; signed char digit=0; static unsigned char NumberBuffer[] = "0123456789"; for(digit_sum = 0; digit_sum < DIGIT_SHOW; digit_sum ++) { digit = data%10; //求取最低位 data /= 10; //十进制左移 NumberBuffer[digit_sum]=Number[digit]; if(data == 0) { break; //如果已经移到了最高位则跳出循环 } } for(digit = 0; digit <= digit_sum; digit ++) { #if LCD_CHAR_HORIZONTAL > 0 LCD_WriteChar(digit,0,0,1234,NumberBuffer[digit_sum - digit]); #else LCD_WriteChar(0,digit,0,1234,NumberBuffer[digit_sum - digit]); #endif } } // void LCD_WriteHexNumber(u16 x, u16 y, unsigned long data, unsigned char is_cap) { # define DIGIT_SHOW 10 //最多可以显示10位 signed char digit_sum=0; signed char digit=0; static unsigned char NumberBuffer[] = "ff ff ff ff ff ff"; for(digit_sum = 0; digit_sum < DIGIT_SHOW; digit_sum ++) { digit = data%16; //求取最低位 data /= 16; //十进制左移 if(!(digit_sum % 3)) { NumberBuffer[digit_sum ++] = ' '; } NumberBuffer[digit_sum]=Number[digit]; if(data == 0) { break; //如果已经移到了最高位则跳出循环 } } if(digit_sum == 2) { NumberBuffer[digit_sum] = '0'; digit_sum += 1; } for(digit = 0; digit <= digit_sum; digit ++) { LCD_WriteChar(x, y+digit,0,1234,NumberBuffer[digit_sum - digit]); } } |
|
相关推荐
1个回答
|
|
我不懂 帮顶一下
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
飞凌嵌入式ElfBoard ELF 1板卡-CAN编程示例之开发板测试
688 浏览 0 评论
该问题是用APP给芯海科技的CST92F25芯片发指令是出现的
2316 浏览 1 评论
797 浏览 0 评论
1562 浏览 1 评论
2330 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-23 06:37 , Processed in 0.540671 second(s), Total 77, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号