///**************************************************************************** //* Filename: hal_lcd.c //* Author: Andy https://aldsz.taobao.com //* Date: 2015-06-16 //* Version: 1.0 //* Description: OLED driver //****************************************************************************/ //#include "hal_types.h" //#include "hal_lcd.h" //#include "OSAL.h" //#include "OnBoard.h" //#include "hal_assert.h" //#include // //#if defined (ZTOOL_P1) || defined (ZTOOL_P2) // #include "DebugTrace.h" //#endif // // ////------------------------------------------------------------------------------ //#define LCD_COMMAND 0x00 //#define LCD_DATA 0x01 // //#define LCD_MAX_BUF 25 // //#define SOFTWARE_SPI ////#define HARDWARE_SPI //采用硬件SPI通讯 // //#define COL_SPACE 2 //字符间距 //#define ROW_SPACE 4 //行间距 //#define ALL_CNS 128 //#define X_MAX_PIXEL 128 //#define Y_MAX_PIXEL 128 // //// SPI TFT LCD端口定义 //#define LCD_DC P0_0 // 数据/命令选择 //#define LCD_SDA P1_3 // 双向数据 //#define LCD_SCL P1_2 // 时钟 ////#define LCD_CS P1_2 // 片选, L_S 将片选接地 //#define LCD_RST P1_7 // 控制lcd复位 // ////液晶控制口置1操作语句宏定义 ////#define LCD_CS_SET (LCD_CS_CLRx01) //#define LCD_DC_SET (LCD_DC = 0x01) //#define LCD_SDA_SET (LCD_SDA = 0x01) //#define LCD_SCL_SET (LCD_SCL = 0x01) //#define LCD_RST_SET (LCD_RST = 0x01) // ////液晶控制口置0操作语句宏定义 ////#define LCD_CS_CLR (LCD_CS_CLRx00) //#define LCD_DC_CLR (LCD_DC = 0x00) //#define LCD_SDA_CLR (LCD_SDA = 0x00) //#define LCD_SCL_CLR (LCD_SCL = 0x00) //#define LCD_RST_CLR (LCD_RST = 0x00) // // //void SPI_Init(void); //void LCD_clear(unsigned int color); //void LCD_write_EN_string(unsigned char X,unsigned char Y,uint8 *s); //static void LCD_set_window(unsigned int X, unsigned int Y, // unsigned Width,unsigned int Height); //static void LCD_write_EN(unsigned int X, unsigned int Y, unsigned char c); //static void LCD_write_CN(unsigned int X, unsigned int Y, unsigned char c); // //unsigned int Color = BLUE; //默认前景颜色 //unsigned int Color_BK = GREEN;//默认背景颜色 ////------------------------------------------------------------------------------ // //#define XLevelL 0x00 //#define XLevelH 0x10 //#define XLevel ((XLevelH&0x0F)*16+XLevelL) //#define Max_Column 128 //#define Max_Row 64 //#define Brightness 0xCF //#define X_WIDTH 128 //#define Y_WIDTH 64 // //#define LCD_MAX_BUF 25 //#define HAL_LCD_MAX_CHARS 16 // Max number of chars on a single LCD line // // //#if (HAL_LCD == TRUE) //void HalLcd_HW_Init(void); //void HalLcd_HW_WaitUs(uint16 i); //void HalLcd_HW_Clear(void); //void HalLcd_HW_Control(uint8 cmd); //void HalLcd_HW_Write(uint8 data); //void HalLcd_HW_SetContrast(uint8 value); //void HalLcd_HW_WriteChar(uint8 line, uint8 col, char text); //void HalLcd_HW_WriteLine(uint8 line, const char *pText); // //void DelayMS(unsigned int msec); //void LCD_WrDat(unsigned char dat); //void LCD_WrCmd(unsigned char cmd); //void LCD_Set_Pos(unsigned char x, unsigned char y); //void LCD_Fill(unsigned char bmp_dat) ; //void LCD_CLS(void); // ////----------------------------------------------------------------------------- //void DrawRect(unsigned int Xpos, unsigned int Ypos, unsigned int Width, // unsigned int Height,unsigned Color); //void DrawRectFill(unsigned int Xpos , unsigned int Ypos, unsigned int Width, // unsigned int Height, unsigned Color); //void SendByte(unsigned char Data); //void SPI_WriteData(unsigned char Data); //void LCD_write_byte(unsigned char data, unsigned char command); //void LCD_WriteData_16Bit(unsigned short Data); //void LCD_write_CN_string(unsigned char X,unsigned char Y,uint8 *s); //void ShowImage(const unsigned char *p); // //void DrawPixel(unsigned int x, unsigned int y, unsigned int color); //void DrawVerticalLine(unsigned int x, unsigned int y, // unsigned int Length,unsigned int Color); //void DrawHorizonLine(unsigned int x, unsigned int y, // unsigned int Length,unsigned int Color); //void Lcd_Reset(void); // // ////中文14x14点阵字符索引 ALD //__code const unsigned char CN14x14_Index[] = //{ // "科技用户登录帐号密码确定取消专业专注无线通讯诚信立足创新致远强大原:" //}; // ////中文14x14点阵字符 ald // const unsigned char CN14x14[][28] = //{ //0x00,0x20,0x0D,0x20,0x70,0xA0,0x10,0xA0,0x12,0x20,0xFD,0x20,0x11,0x20,0x30,0x38, //0x3B,0xE0,0x54,0x20,0x90,0x20,0x10,0x20,0x10,0x20,0x10,0x20,/*"科",6*/ // //0x20,0x80,0x20,0x80,0x20,0x80,0xF7,0xF0,0x20,0x80,0x20,0x80,0x27,0xE0,0x32,0x20, //0xE2,0x20,0x21,0x40,0x20,0x80,0x21,0x40,0x22,0x20,0xEC,0x18,/*"技",7*/ // //0x00,0x00,0x3F,0xF8,0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x21,0x08, //0x3F,0xF8,0x21,0x08,0x21,0x08,0x41,0x08,0x41,0x08,0x80,0x38,/*"用",8*/ // //0x02,0x00,0x01,0x00,0x3F,0xF8,0x20,0x08,0x20,0x08,0x20,0x08,0x3F,0xF8,0x20,0x08, //0x20,0x00,0x20,0x00,0x20,0x00,0x40,0x00,0x40,0x00,0x80,0x00,/*"户",9*/ // //0x01,0x20,0x7D,0x40,0x04,0x90,0x28,0xA0,0x10,0x40,0x2F,0xA0,0x40,0x18,0x9F,0xC0, //0x10,0x40,0x10,0x40,0x1F,0xC0,0x10,0x40,0x08,0x80,0xFF,0xF8,/*"登",10*/ // //0x00,0x00,0x7F,0xE0,0x00,0x20,0x3F,0xE0,0x00,0x20,0xFF,0xF8,0x02,0x00,0x22,0x20, //0x13,0x40,0x0A,0x80,0x12,0x40,0x22,0x20,0xC2,0x18,0x0E,0x00,/*"录",11*/ // //0x21,0x00,0x21,0x10,0x21,0x10,0xF9,0x20,0xA9,0x40,0xA9,0x00,0xAB,0xF8,0xA9,0x40, //0xA9,0x40,0xA9,0x20,0xB9,0x20,0x21,0x50,0x21,0x88,0x21,0x00,/*"帐",12*/ // //0x3F,0xE0,0x20,0x20,0x20,0x20,0x3F,0xE0,0x00,0x00,0x00,0x00,0xFF,0xF8,0x08,0x00, //0x10,0x00,0x3F,0xE0,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0xC0,/*"号",13*/ // //0x02,0x00,0xFF,0xF8,0x80,0x08,0x04,0x40,0x52,0x90,0x51,0x08,0x92,0x28,0x0F,0xE0, //0x30,0x00,0xC2,0x00,0x22,0x20,0x22,0x20,0x3F,0xE0,0x00,0x20,/*"密",14*/ // //0x00,0x00,0x07,0xE0,0xF8,0x20,0x22,0x20,0x22,0x20,0x42,0x20,0x7B,0xF8,0xC8,0x08, //0x48,0x08,0x4F,0xE8,0x48,0x08,0x78,0x08,0x48,0x08,0x00,0x30,/*"码",15*/ // //0x01,0x00,0x01,0xF0,0xFA,0x10,0x24,0x20,0x23,0xF8,0x42,0x48,0x7A,0x48,0xCB,0xF8, //0x4A,0x48,0x4A,0x48,0x4B,0xF8,0x7A,0x48,0x42,0x48,0x04,0x18,/*"确",16*/ // //0x04,0x00,0x02,0x00,0xFF,0xF8,0x80,0x08,0x00,0x00,0x3F,0xE0,0x02,0x00,0x02,0x00, //0x22,0x00,0x23,0xE0,0x22,0x00,0x22,0x00,0x52,0x00,0x8F,0xF8,/*"定",17*/ // //0x00,0x00,0xFC,0x00,0x4B,0xF0,0x49,0x10,0x79,0x10,0x49,0x10,0x49,0x10,0x78,0xA0, //0x48,0xA0,0x4E,0x40,0xF8,0x40,0x08,0xA0,0x09,0x10,0x0A,0x08,/*"取",18*/ // //0x00,0x80,0x44,0x90,0x22,0xA0,0x10,0x80,0x07,0xF0,0x84,0x10,0x44,0x10,0x17,0xF0, //0x14,0x10,0x24,0x10,0x27,0xF0,0x44,0x10,0x44,0x10,0x04,0x70,/*"消",19*/ // //0x02,0x00,0x02,0x00,0x7F,0xF0,0x04,0x00,0x04,0x00,0xFF,0xF8,0x08,0x00,0x10,0x00, //0x3F,0xE0,0x00,0x20,0x00,0x40,0x1C,0x80,0x03,0x00,0x00,0x80,/*"专",20*/ // //0x08,0x80,0x08,0x80,0x08,0x80,0x88,0x90,0x48,0x90,0x48,0x90,0x28,0xA0,0x28,0xA0, //0x28,0xC0,0x08,0x80,0x08,0x80,0x08,0x80,0x08,0x80,0xFF,0xF8,/*"业",21*/ // //0x02,0x00,0x02,0x00,0x7F,0xF0,0x04,0x00,0x04,0x00,0xFF,0xF8,0x08,0x00,0x10,0x00, //0x3F,0xE0,0x00,0x20,0x00,0x40,0x1C,0x80,0x03,0x00,0x00,0x80,/*"专",22*/ // //0x01,0x00,0x40,0x80,0x20,0x00,0x17,0xF0,0x00,0x80,0x80,0x80,0x40,0x80,0x00,0x80, //0x17,0xF0,0x10,0x80,0x20,0x80,0x20,0x80,0x40,0x80,0x4F,0xF8,/*"注",23*/ // //0x00,0x00,0x7F,0xF0,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0xFF,0xF8,0x05,0x00, //0x05,0x00,0x09,0x00,0x11,0x00,0x21,0x08,0x41,0x08,0x80,0xF8,/*"无",24*/ // //0x20,0xA0,0x20,0x90,0x48,0x80,0x48,0xF0,0xF3,0x80,0x10,0x80,0x20,0xB8,0x43,0xC0, //0xF8,0x90,0x00,0xA0,0x00,0x48,0x18,0xA8,0xE3,0x18,0x00,0x08,/*"线",25*/ // //0x47,0xF0,0x21,0x20,0x20,0xC0,0x07,0xF0,0x04,0x90,0xE4,0x90,0x27,0xF0,0x24,0x90, //0x24,0x90,0x27,0xF0,0x24,0x90,0x24,0xB0,0x50,0x00,0x8F,0xF8,/*"通",26*/ // //0x40,0x00,0x2F,0xE0,0x22,0x20,0x02,0x20,0x02,0x20,0xE2,0x20,0x2F,0xE0,0x22,0x20, //0x22,0x20,0x22,0x28,0x2A,0x28,0x32,0x28,0x22,0x18,0x02,0x08,/*"讯",27*/ // //0x40,0x50,0x20,0x48,0x20,0x40,0x07,0xF8,0xE4,0x40,0x24,0x48,0x27,0x48,0x25,0x50, //0x25,0x50,0x2D,0x20,0x35,0x28,0x2B,0x68,0x08,0x98,0x11,0x08,/*"诚",28*/ // //0x11,0x00,0x10,0x80,0x2F,0xF8,0x20,0x00,0x67,0xF0,0xA0,0x00,0x27,0xF0,0x20,0x00, //0x27,0xF0,0x24,0x10,0x24,0x10,0x24,0x10,0x27,0xF0,0x24,0x10,/*"信",29*/ // //0x04,0x00,0x02,0x00,0x00,0x00,0x7F,0xF0,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20, //0x10,0x40,0x10,0x40,0x08,0x80,0x08,0x80,0x01,0x00,0xFF,0xF8,/*"立",30*/ // //0x00,0x00,0x3F,0xE0,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0xE0,0x02,0x00,0x02,0x00, //0x22,0x00,0x23,0xF0,0x22,0x00,0x22,0x00,0x52,0x00,0x8F,0xF8,/*"足",31*/ // //0x10,0x10,0x10,0x10,0x28,0x10,0x24,0x90,0x42,0x90,0x80,0x90,0x7C,0x90,0x44,0x90, //0x44,0x90,0x44,0x90,0x58,0x10,0x42,0x10,0x42,0x10,0x3E,0x70,/*"创",32*/ // //0x20,0x18,0x10,0xE0,0xFE,0x80,0x44,0x80,0x28,0x80,0xFE,0xF8,0x00,0x90,0x10,0x90, //0xFE,0x90,0x10,0x90,0x54,0x90,0x92,0x90,0x11,0x10,0x72,0x10,/*"新",33*/ // //0x00,0x80,0xFE,0x80,0x10,0x80,0x24,0xF8,0x43,0x10,0xFE,0x90,0x12,0x90,0x10,0x90, //0xFE,0xA0,0x10,0xA0,0x10,0x40,0x1E,0xA0,0xF1,0x10,0x02,0x08,/*"致",34*/ // //0x00,0x00,0x47,0xE0,0x20,0x00,0x20,0x00,0x00,0x00,0x0F,0xF0,0xE2,0x40,0x22,0x40, //0x22,0x40,0x22,0x48,0x24,0x48,0x28,0x38,0x50,0x00,0x8F,0xF8,/*"远",35*/ // //0x00,0x00,0xF3,0xE0,0x12,0x20,0x12,0x20,0xF3,0xE0,0x80,0x80,0x87,0xF0,0x84,0x90, //0xF4,0x90,0x17,0xF0,0x10,0x80,0x10,0x90,0x1F,0xF8,0x60,0x08,/*"强",36*/ // //0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0xFF,0xF8,0x02,0x00,0x05,0x00,0x05,0x00, //0x05,0x00,0x08,0x80,0x08,0x80,0x10,0x40,0x20,0x20,0xC0,0x18,/*"大",37*/ // //0x3F,0xF8,0x20,0x80,0x21,0x00,0x27,0xF0,0x24,0x10,0x27,0xF0,0x24,0x10,0x27,0xF0, //0x20,0x80,0x24,0x90,0x24,0x88,0x48,0x88,0x40,0x80,0x83,0x80,/*"原",38*/ // //0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x18,0x00, //0x00,0x00,0x00,0x00,0x18,0x00,0x18,0x00,0x00,0x00,0x00,0x00,/*":",41*/ // //}; // ////英文7x14点阵字符 andy //__code const unsigned char ASCII7x14[][14] = //{ //{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//" ",0// //{0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x30,0x30,0x00,0x00},//"!",1// //{0x00,0x14,0x28,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//""",2// //{0x00,0x00,0x00,0x28,0x28,0xFC,0x28,0x48,0x50,0xFC,0x50,0x50,0x00,0x00},//"#",3// //{0x00,0x00,0x10,0x38,0x54,0x54,0x30,0x18,0x14,0x54,0x54,0x38,0x10,0x00},//"$",4// //{0x00,0x00,0x00,0x44,0xA8,0xA8,0xB0,0x54,0x1A,0x2A,0x2A,0x44,0x00,0x00},//"%",5// //{0x00,0x00,0x00,0x20,0x50,0x50,0x60,0xAC,0xA8,0x98,0x92,0x7C,0x00,0x00},//"&",6// //{0x00,0x60,0x60,0x20,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//"'",7// //{0x00,0x04,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x08,0x04,0x00},//"(",8// //{0x00,0x00,0x40,0x20,0x10,0x08,0x04,0x08,0x10,0x20,0x40,0x00,0x00,0x00},//">",9// //{0x00,0x00,0x00,0x10,0x10,0xD6,0x38,0x38,0xD6,0x10,0x10,0x00,0x00,0x00},//"*",10// //{0x00,0x00,0x00,0x10,0x10,0x10,0xFE,0x10,0x10,0x10,0x00,0x00,0x00,0x00},//"+",11// //{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x20,0xC0},//",",12// //{0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//"-",13// //{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00},//".",14// //{0x00,0x02,0x04,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x40,0x00},//"/",15// //{0x00,0x00,0x00,0x30,0x48,0x84,0x84,0x84,0x84,0x84,0x48,0x30,0x00,0x00},//"0",16// //{0x00,0x00,0x00,0x10,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},//"1",17// //{0x00,0x00,0x00,0x38,0x44,0x44,0x04,0x08,0x10,0x20,0x44,0x7C,0x00,0x00},//"2",18// //{0x00,0x00,0x00,0x38,0x44,0x44,0x18,0x04,0x04,0x44,0x44,0x38,0x00,0x00},//"3",19// //{0x00,0x00,0x08,0x08,0x18,0x28,0x48,0x48,0x88,0x7C,0x08,0x1C,0x00,0x00},//"4",20// //{0x00,0x00,0x00,0x7C,0x40,0x40,0x78,0x44,0x04,0x44,0x44,0x38,0x00,0x00},//"5",21// //{0x00,0x00,0x00,0x3C,0x44,0x80,0xB8,0xC4,0x84,0x84,0x84,0x78,0x00,0x00},//"6",22// //{0x00,0x00,0x00,0x7C,0x44,0x48,0x08,0x10,0x10,0x10,0x10,0x10,0x00,0x00},//"7",23// //{0x00,0x00,0x00,0x78,0x84,0x84,0x48,0x78,0x84,0x84,0x84,0x78,0x00,0x00},//"8",24// //{0x00,0x00,0x00,0x78,0x84,0x84,0x84,0x8C,0x74,0x04,0x88,0xF0,0x00,0x00},//"9",25// //{0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x30,0x30,0x00,0x00},//":",26// //{0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x10,0x20},//";",27// //{0x00,0x00,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x00,0x00,0x00},//"<",28// //{0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0x00},//"=",29// //{0x00,0x00,0x40,0x20,0x10,0x08,0x04,0x08,0x10,0x20,0x40,0x00,0x00,0x00},//">",30// //{0x00,0x00,0x78,0x84,0x84,0x84,0x08,0x10,0x10,0x00,0x30,0x30,0x00,0x00},//"?",31// //{0x00,0x00,0x00,0x38,0x44,0x9A,0xAA,0xAA,0xAA,0xB4,0x42,0x3C,0x00,0x00},//"@",32// //{0x00,0x00,0x00,0x10,0x10,0x28,0x28,0x28,0x38,0x44,0x44,0xEE,0x00,0x00},//"A",33// //{0x00,0x00,0x00,0xF8,0x44,0x44,0x78,0x44,0x44,0x44,0x44,0xF8,0x00,0x00},//"B",34// //{0x00,0x00,0x00,0x3C,0x44,0x84,0x80,0x80,0x80,0x80,0x44,0x38,0x00,0x00},//"C",35// //{0x00,0x00,0x00,0xF0,0x48,0x44,0x44,0x44,0x44,0x44,0x48,0xF0,0x00,0x00},//"D",36// //{0x00,0x00,0x00,0xFC,0x44,0x40,0x48,0x78,0x48,0x40,0x44,0xFC,0x00,0x00},//"E",37// //{0x00,0x00,0x00,0xFC,0x42,0x40,0x48,0x78,0x48,0x40,0x40,0xE0,0x00,0x00},//"F",38// //{0x00,0x00,0x00,0x3C,0x44,0x84,0x80,0x80,0x8E,0x84,0x44,0x38,0x00,0x00},//"G",39// //{0x00,0x00,0x00,0xEE,0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0xEE,0x00,0x00},//"H",40// //{0x00,0x00,0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},//"I",41// //{0x00,0x00,0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x90,0xE0},//"J",42// //{0x00,0x00,0x00,0xEE,0x44,0x48,0x50,0x70,0x48,0x48,0x44,0xEE,0x00,0x00},//"K",43// //{0x00,0x00,0x00,0xE0,0x40,0x40,0x40,0x40,0x40,0x40,0x44,0xFC,0x00,0x00},//"L",44// //{0x00,0x00,0x00,0xEE,0x6C,0x6C,0x6C,0x54,0x54,0x54,0x54,0xD6,0x00,0x00},//"M",45// //{0x00,0x00,0x00,0xEE,0x64,0x64,0x54,0x54,0x54,0x4C,0x4C,0xE4,0x00,0x00},//"N",46// //{0x00,0x00,0x00,0x30,0x48,0x84,0x84,0x84,0x84,0x84,0x48,0x30,0x00,0x00},//"O",47// //{0x00,0x00,0x00,0xF8,0x44,0x44,0x44,0x78,0x40,0x40,0x40,0xE0,0x00,0x00},//"P",48// //{0x00,0x00,0x00,0x30,0x48,0x84,0x84,0x84,0x84,0xB4,0x48,0x38,0x0C,0x00},//"Q",49// //{0x00,0x00,0x00,0xF8,0x44,0x44,0x78,0x50,0x48,0x48,0x44,0xE6,0x00,0x00},//"R",50// //{0x00,0x00,0x00,0x3C,0x44,0x40,0x20,0x18,0x04,0x04,0x44,0x78,0x00,0x00},//"S",51// //{0x00,0x00,0x00,0xFE,0x92,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00},//"T",52// //{0x00,0x00,0x00,0xEE,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00},//"U",53// //{0x00,0x00,0x00,0xEE,0x44,0x44,0x28,0x28,0x28,0x28,0x10,0x10,0x00,0x00},//"V",54// //{0x00,0x00,0x00,0xD6,0x54,0x54,0x54,0x54,0x6C,0x28,0x28,0x28,0x00,0x00},//"W",55// //{0x00,0x00,0x00,0xEE,0x44,0x28,0x28,0x10,0x28,0x28,0x44,0xEE,0x00,0x00},//"X",56// //{0x00,0x00,0x00,0xEE,0x44,0x28,0x28,0x10,0x10,0x10,0x10,0x38,0x00,0x00},//"Y",57// //{0x00,0x00,0x00,0x7C,0x88,0x08,0x10,0x20,0x20,0x40,0x44,0xFC,0x00,0x00},//"Z",58// //{0x00,0x1C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1C,0x00},//"[",59// //{0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x70,0x00},//"]",60// //{0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x70,0x00},//"]",61// //{0x00,0x10,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//"^",62// //{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE},//"_",63// //{0x00,0x60,0x60,0x20,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//"'",64// //{0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x44,0x1C,0x24,0x44,0x3E,0x00,0x00},//"a",65// //{0x00,0x00,0x00,0xC0,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x78,0x00,0x00},//"b",66// //{0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x44,0x40,0x40,0x44,0x38,0x00,0x00},//"c",67// //{0x00,0x00,0x00,0x0C,0x04,0x04,0x3C,0x44,0x44,0x44,0x44,0x3E,0x00,0x00},//"d",68// //{0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x44,0x7C,0x40,0x44,0x38,0x00,0x00},//"e",69// //{0x00,0x00,0x00,0x1C,0x24,0x20,0xF8,0x20,0x20,0x20,0x20,0x78,0x00,0x00},//"f",70// //{0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x48,0x48,0x30,0x40,0x78,0x44,0x38},//"g",71// //{0x00,0x00,0x00,0xC0,0x40,0x40,0x58,0x64,0x44,0x44,0x44,0xEE,0x00,0x00},//"h",72// //{0x00,0x00,0x00,0x10,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},//"i",73// //{0x00,0x00,0x00,0x08,0x00,0x00,0x38,0x08,0x08,0x08,0x08,0x08,0x08,0x70},//"j",74// //{0x00,0x00,0x00,0xC0,0x40,0x40,0x5C,0x48,0x50,0x70,0x48,0xEC,0x00,0x00},//"k",75// //{0x00,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},//"l",76// //{0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x54,0x54,0x54,0x54,0xD6,0x00,0x00},//"m",77// //{0x00,0x00,0x00,0x00,0x00,0x00,0xD8,0x64,0x44,0x44,0x44,0xEE,0x00,0x00},//"n",78// //{0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x38,0x00,0x00},//"o",79// //{0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x44,0x44,0x44,0x44,0x78,0x40,0xE0},//"p",80// //{0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x44,0x44,0x44,0x44,0x3C,0x04,0x0E},//"q",81// //{0x00,0x00,0x00,0x00,0x00,0x00,0xEC,0x30,0x20,0x20,0x20,0xF8,0x00,0x00},//"r",82// //{0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x44,0x30,0x08,0x44,0x78,0x00,0x00},//"s",83// //{0x00,0x00,0x00,0x00,0x10,0x10,0x7C,0x10,0x10,0x10,0x10,0x0C,0x00,0x00},//"t",84// //{0x00,0x00,0x00,0x00,0x00,0x00,0xCC,0x44,0x44,0x44,0x44,0x3E,0x00,0x00},//"u",85// //{0x00,0x00,0x00,0x00,0x00,0x00,0xEE,0x44,0x28,0x28,0x28,0x10,0x00,0x00},//"v",86// //{0x00,0x00,0x00,0x00,0x00,0x00,0xD6,0x54,0x54,0x54,0x28,0x28,0x00,0x00},//"w",87// //{0x00,0x00,0x00,0x00,0x00,0x00,0xDC,0x48,0x30,0x30,0x48,0xEC,0x00,0x00},//"x",88// //{0x00,0x00,0x00,0x00,0x00,0x00,0xEE,0x44,0x28,0x28,0x10,0x10,0x20,0xE0},//"y",89// //{0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x48,0x10,0x10,0x24,0x7C,0x00,0x00},//"z",90// //{0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10},//"|",91// //}; ////----------------------------------------------------------------------------- //#endif //LCD // // ///************************************************************************************************** // * @fn HalLcdInit // * // * @brief Initilize LCD Service // * // * @param init - pointer to void that contains the initialized value // * // * @return None // **************************************************************************************************/ //void HalLcdInit(void) //{ //#if (HAL_LCD == TRUE) // HalLcd_HW_Init(); //#endif //} // ///************************************************************************************************** // * @fn HalLcdWriteValue // * // * @brief Write a value to the LCD // * // * @param value - value that will be displayed // * radix - 8, 10, 16 // * option - display options // * // * @return None // **************************************************************************************************/ //void HalLcdWriteValue ( uint32 value, const uint8 radix, uint8 option) //{ //#if (HAL_LCD == TRUE) // uint8 buf[LCD_MAX_BUF]; // // _ltoa( value, &buf[0], radix ); // HalLcdWriteString( (char*)buf, option ); //#endif //} // ///************************************************************************************************** // * @fn HalLcdWriteScreen // * // * @brief Write a value to the LCD // * // * @param line1 - string that will be displayed on line 1 // * line2 - string that will be displayed on line 2 // * // * @return None // **************************************************************************************************/ //void HalLcdWriteScreen( char *line1, char *line2 ) //{ //#if (HAL_LCD == TRUE) // HalLcdWriteString( line1, 0 );//andy // HalLcdWriteString( line2, 1 ); //#endif //} // ///************************************************************************************************** // * @fn HalLcdWriteStringValue // * // * @brief Write a string followed by a value to the LCD // * // * @param title - Title that will be displayed before the value // * value - value // * format - redix // * line - line number // * // * @return None // **************************************************************************************************/ //void HalLcdWriteStringValue( char *title, uint16 value, uint8 format, uint8 line ) //{ //#if (HAL_LCD == TRUE) // uint8 tmpLen; // uint8 buf[LCD_MAX_BUF]; // uint32 err; // // tmpLen = (uint8)osal_strlen( (char*)title ); // osal_memcpy( buf, title, tmpLen ); // //buf[tmpLen] = ' '; // err = (uint32)(value); // _ltoa( err, &buf[tmpLen], format ); // HalLcdWriteString( (char*)buf, line ); //#endif //} // ///************************************************************************************************** // * @fn HalLcdWriteStringValue // * // * @brief Write a string followed by a value to the LCD // * // * @param title - Title that will be displayed before the value // * value1 - value #1 // * format1 - redix of value #1 // * value2 - value #2 // * format2 - redix of value #2 // * line - line number // * // * @return None // **************************************************************************************************/ //void HalLcdWriteStringValueValue( char *title, uint16 value1, uint8 format1, // uint16 value2, uint8 format2, uint8 line ) //{ //#if (HAL_LCD == TRUE) // // uint8 tmpLen; // uint8 buf[LCD_MAX_BUF]; // uint32 err; // // tmpLen = (uint8)osal_strlen( (char*)title ); // if ( tmpLen ) // { // osal_memcpy( buf, title, tmpLen ); // //buf[tmpLen++] = ' '; // } // // err = (uint32)(value1); // _ltoa( err, &buf[tmpLen], format1 ); // tmpLen = (uint8)osal_strlen( (char*)buf ); // // buf[tmpLen++] = ','; // buf[tmpLen++] = ' '; // err = (uint32)(value2); // _ltoa( err, &buf[tmpLen], format2 ); // // HalLcdWriteString( (char *)buf, line ); // //#endif //} // //#if (HAL_LCD == TRUE) //void DelayMS(unsigned int msec) //{ // unsigned int i; // while(msec >0) // { // for (i=0; i<8000; i++) asm("NOP"); //1ms // msec--; // } //} // ////option 1=第1行 2=第2行 其它类推 //void HalLcdWriteString (char *s, uint8 option) //{ // Color = BLUE; // Color_BK = WHITE; // DrawRectFill(7,option*15+20,118,15,WHITE); // LCD_write_EN_string(7,option*15+20,(unsigned char *)s); //} // ////向SPI总线传输一个8位数据 //void SendByte(unsigned char Data) //{ // unsigned char i=0; // // for(i=8;i>0;i--) // { // if(Data&0x80) // LCD_SDA_SET;//输出数据 // else // LCD_SDA_CLR; // // LCD_SCL_CLR; // LCD_SCL_SET; // Data<<=1; // } //} // ////向SPI总线传输一个8位数据 //void SPI_WriteData(unsigned char Data) //{ // unsigned char i=0; // // for(i=8;i>0;i--) // { // if(Data&0x80) // LCD_SDA_SET;//输出数据 // else // LCD_SDA_CLR; // // LCD_SCL_CLR; // LCD_SCL_SET; // Data<<=1; // } //} // ////向液晶屏写一个8位指令 //void LCD_WrCmd(unsigned char Index) //{ // //LCD_CS_CLR; //ALD del SPI写命令时序开始 // LCD_DC_CLR; // SPI_WriteData(Index); // //LCD_CS_SET; //ALD del //} // ////向液晶屏写一个8位数据 //void LCD_WrDat(unsigned char Data) //{ // //LCD_CS_CLR; //ALD del // LCD_DC_SET; // SPI_WriteData(Data); // //LCD_CS_SET; //ALD del //} // ////向液晶屏写一个16位数据 //void LCD_WriteData_16Bit(unsigned short Data) //{ // //LCD_CS_CLR; //ALD del // LCD_DC_SET; // SPI_WriteData(Data>>8); //写入高8位数据 // SPI_WriteData(Data); //写入低8位数据 // //LCD_CS_SET; //ALD del //} // ///**************************************************************************** //* 名 称: LCD_write_byte() //* 功 能: 数据到LCD //* 入口参数: data —写入的数据 //* command —写数据/命令选择 //* 出口参数: 无 //****************************************************************************/ //static void LCD_write_byte(unsigned char data, unsigned char command) //{ // ////LCD_CS_CLR ;// 使能LCD // if (command == 0) // LCD_WrCmd(data); // 传送命令 // else // LCD_WrDat(data) ; // 传送数据 // //SendByte(data); // //LCD_CS_SET; // 关闭LCD // //LCD_DC_SET; //} // //// 复位lcd //void Lcd_Reset(void) //{ // LCD_RST_CLR; // DelayMS(110); // LCD_RST_SET; // DelayMS(50); //} // ///**************************************************************************** //* 名 称: LCD_set_window() //* 功 能: 设置显示窗口 //* 入口参数: X - 显示窗口左上角横坐标 Y —显示窗口左上角纵坐标 //* Width —显示窗口宽度 Height —显示窗口高度 //* 出口参数: 无 //****************************************************************************/ //static void LCD_set_window(unsigned int X , unsigned int Y, // unsigned int Width, unsigned int Height) //{ // LCD_write_byte(0x2A,LCD_COMMAND); //列地址设置命令 // LCD_write_byte(X>>8,LCD_DATA) ; //设置显示窗口左上角横坐标高位 // LCD_write_byte((X+2)&0xFF,LCD_DATA); //设置显示窗口左上角横坐标低位 // LCD_write_byte((X+Width+1)>>8,LCD_DATA); //设置宽度高位 // LCD_write_byte((X+Width+1)&0xFF,LCD_DATA);// 设置宽度低位 // // LCD_write_byte(0x2B,LCD_COMMAND); //行地址设置命令 // LCD_write_byte(Y>>8,LCD_DATA) ; //设置显示窗口左上角纵坐标高位 // LCD_write_byte((Y+3)&0xFF,LCD_DATA); //设置显示窗口左上角纵坐标低位 // LCD_write_byte((Y+Height+2)>>8,LCD_DATA); // 设置显示窗口高度高位 // LCD_write_byte((Y+Height+2)&0xFF,LCD_DATA);// 设置显示窗口高度低位 // LCD_write_byte(0x2C,LCD_COMMAND) ; //} // ///**************************************************************************** //* 名 称: DrawPixel() //* 功 能: 在指定位置以指定颜色显示像素 //****************************************************************************/ //void DrawPixel(unsigned int x, unsigned int y, unsigned int color) //{ // //LCD_set_XY(x,y); //设定显示位置 andy // LCD_write_byte(color>>8,LCD_DATA); //发送显示颜色数据高位字节 // LCD_write_byte(color&0xFF,LCD_DATA);//发送显示颜色数据低位字节 //} // ///**************************************************************************** //* 名 称: DrawVerticalLine() //* 功 能: 在指定位置以指定颜色画垂直线 //* 入口参数: X - 垂直线起始位置横坐标 Y —垂直线起始位置纵坐标 //* Length —垂直线长度 Color —垂直线颜色 //* 出口参数: 无 //****************************************************************************/ //void DrawVerticalLine(unsigned int x, unsigned int y, // unsigned int Length,unsigned int Color) //{ // register int index = 0; // register char ch,cl; // // ch = (unsigned char)(Color>>8); // cl = (unsigned char)(Color); // LCD_set_window(x,y,1,Length); // for(index=0;index>8); // cl = (unsigned char)(Color); // LCD_set_window(x,y,Length,1); // for(index=0;index>8); // cl = (unsigned char)(Color); // LCD_set_window(Xpos,Ypos,Width,Height); // LCD_write_byte(0x2C,LCD_COMMAND); // //LCD_CS_CLR ; andy // LCD_DC_SET ; // for(i=0;i>8; // cl = color&0xFF; // LCD_write_byte(0x2C,LCD_COMMAND); // //LCD_CS_CLR; // LCD_DC_SET; // for (i=0;i>8); // SendByte(Color) ; // } // else // { // SendByte(Color_BK>>8) ; // SendByte(Color_BK); // } // temp <<= 1 ; // } // } // //LCD_CS_SET ; andy // LCD_DC_SET ; //} // ///**************************************************************************** //* 名 称: LCD_write_EN_string() //* 功 能: 在指定位置显示 7 ×14 点阵ASCII字符串 //* 入口参数: X - 显示位置左上角横坐标 Y —显示位置左上角纵坐标 //* s —字符串指针 //* 出口参数: 无 //****************************************************************************/ //void LCD_write_EN_string(unsigned char X,unsigned char Y,uint8 *s) //{ // unsigned char i=0; // // while (*s) // { // LCD_write_EN(X+i*7,Y,*s); // s++; // i++; // if(i>=HAL_LCD_MAX_CHARS)return; // } // return; //} // ///**************************************************************************** //* 名 称: LCD_write_CN() //* 功 能: 在指定位置显示 14 ×14 点阵汉字字符 //* 入口参数: X - 显示位置左上角横坐标 Y —显示位置左上角纵坐标 //* c —显示字符指针 //* 出口参数: 无 //****************************************************************************/ //static void LCD_write_CN(unsigned int X, unsigned int Y, unsigned char c) //{ // unsigned char i,j,temp; // // LCD_set_window(X,Y,14,14); //按字符点阵大小设置显示窗口 // //LCD_CS_CLR; //液晶SPI使能andy // LCD_DC_SET; //发送数据信号使能 // for(i=0;i<28;i++) // 14x14字符点阵数据大小为2x14=28字节 // { // temp = CN14x14[c][i] ; //读字模数组 // for(j=0;j<8;j++) // 按位显示 // { // if(temp&0x80) //如果位值为1,显示字符色 // { // SendByte(Color>>8); // SendByte(Color) ; // } // else //如果位值为0,显示背景色 // { // SendByte(Color_BK>>8) ; // SendByte(Color_BK); // } // temp <<= 1 ; // } // i++ ; //指向下一字节 // temp = CN14x14[c][i]; // for(j=0;j<6;j++) // 按位显示,点阵横向为14像素, // { // 所以每行第2字节最后2位抛弃 // if(temp&0x80) // 如果位值为1,显示字符色 // { // SendByte(Color>>8); // SendByte(Color) ; // } // else // 如果位值为0,显示背景色 // { // SendByte(Color_BK>>8) ; // SendByte(Color_BK); // } // temp <<= 1 ; // } // } // //LCD_CS_SET; //液晶SPI禁止 // LCD_DC_SET; //数据控制信号禁止 //} // ///**************************************************************************** //* 名 称: LCD_write_CN_string() //* 功 能: 在指定位置显示 14 ×14 点阵中文字符串 //* 入口参数: X - 显示位置左上角横坐标 Y —显示位置左上角纵坐标 //* s —字符串指针 //* 出口参数: 无 //****************************************************************************/ //void LCD_write_CN_string(unsigned char X,unsigned char Y,uint8 *s) //{ // unsigned char i=0; // static unsigned char j=0; // // while (*s) // { // for(j=0;j=ALL_CNS) //无此字的点阵字模 // { // DrawRectFill(X+i*14,Y,14,14,Color_BK);//显示空格 // } // s++; s++ ; //字符指针移位 // i++; // if(i>=HAL_LCD_MAX_CHARS/2) // return; //超过最大显示字符数,返回 // } // return ; //} // ///**************************************************************************** //* 名 称: ShowImage() //* 功 能: 显示图片 //* 入口参数: p - 图片点阵数据 取模方式 水平扫描 从左到右 低位在前 //* 出口参数: 无 //****************************************************************************/ //void ShowImage(const unsigned char *p) //{ // int i; // unsigned char picH,picL; // // LCD_set_window(24,5,80,40); //坐标设置 // for(i=0;i<80*40;i++) // { // picL=*(p+i*2); //数据低位在前 // picH=*(p+i*2+1); // LCD_WriteData_16Bit(picH<<8|picL); // } //} // ////初始化LCD //void HalLcd_HW_Init(void) //{ // P0SEL &= 0xFE; //设置P00为普通IO口, // P0DIR |= 0x01; //设置P00为输出 // P1SEL &= 0x73; //设置P12,P13,P17为普通IO口 // P1DIR |= 0x8c; //设置P12,P13,P17为输出 // // Lcd_Reset(); // //#ifdef HARDWARE_SPI // P1DIR &= 0x9F; // SPI_Init(); //初始化SPI端口 //#endif // // LCD_write_byte(0x11,LCD_COMMAND); //退出睡眠模式 // DelayMS(1); // // ///ST7735R Frame Rate // LCD_write_byte(0xB1,LCD_COMMAND); // LCD_write_byte(0x01,LCD_DATA); // LCD_write_byte(0x2C,LCD_DATA); // LCD_write_byte(0x2D,LCD_DATA); // LCD_write_byte(0xB2,LCD_COMMAND); // LCD_write_byte(0x01,LCD_DATA); // LCD_write_byte(0x2C,LCD_DATA); // LCD_write_byte(0x2D,LCD_DATA); // LCD_write_byte(0xB3,LCD_COMMAND); // LCD_write_byte(0x01,LCD_DATA); // LCD_write_byte(0x2C,LCD_DATA); // LCD_write_byte(0x2D,LCD_DATA); // LCD_write_byte(0x01,LCD_DATA); // LCD_write_byte(0x2C,LCD_DATA); // LCD_write_byte(0x2D,LCD_DATA); // // LCD_write_byte(0xB4,LCD_COMMAND);//列对调 // LCD_write_byte(0x07,LCD_DATA); // //ST7735R加电序列 // LCD_write_byte(0xC0,LCD_COMMAND); // LCD_write_byte(0xA2,LCD_DATA); // LCD_write_byte(0x02,LCD_DATA); // LCD_write_byte(0x84,LCD_DATA); // LCD_write_byte(0xC1,LCD_COMMAND); // LCD_write_byte(0xC5,LCD_DATA); // LCD_write_byte(0xC2,LCD_COMMAND); // LCD_write_byte(0x0A,LCD_DATA); // LCD_write_byte(0x00,LCD_DATA); // LCD_write_byte(0xC3,LCD_COMMAND); // LCD_write_byte(0x8A,LCD_DATA); // LCD_write_byte(0x2A,LCD_DATA); // LCD_write_byte(0xC4,LCD_COMMAND); // LCD_write_byte(0x8A,LCD_DATA); // LCD_write_byte(0xEE,LCD_DATA); // // LCD_write_byte(0xC5,LCD_COMMAND); //加VCOM // LCD_write_byte(0x0E,LCD_DATA); // // LCD_write_byte(0x36,LCD_COMMAND); //RGB模式 // LCD_write_byte(0xC8,LCD_DATA); // // // ST7735R Gamma 校正序列 // LCD_write_byte(0xe0,LCD_COMMAND); // LCD_write_byte(0x0f,LCD_DATA); // LCD_write_byte(0x1a,LCD_DATA); // LCD_write_byte(0x0f,LCD_DATA); // LCD_write_byte(0x18,LCD_DATA); // LCD_write_byte(0x2f,LCD_DATA); // LCD_write_byte(0x28,LCD_DATA); // LCD_write_byte(0x20,LCD_DATA); // LCD_write_byte(0x22,LCD_DATA); // LCD_write_byte(0x1f,LCD_DATA); // LCD_write_byte(0x1b,LCD_DATA); // LCD_write_byte(0x23,LCD_DATA); // LCD_write_byte(0x37,LCD_DATA); // LCD_write_byte(0x00,LCD_DATA); // // LCD_write_byte(0x07,LCD_DATA); // LCD_write_byte(0x02,LCD_DATA); // LCD_write_byte(0x10,LCD_DATA); // LCD_write_byte(0xe1,LCD_COMMAND); // LCD_write_byte(0x0f,LCD_DATA); // LCD_write_byte(0x1b,LCD_DATA); // LCD_write_byte(0x0f,LCD_DATA); // LCD_write_byte(0x17,LCD_DATA); // LCD_write_byte(0x33,LCD_DATA); // LCD_write_byte(0x2c,LCD_DATA); // LCD_write_byte(0x29,LCD_DATA); // LCD_write_byte(0x2e,LCD_DATA); // LCD_write_byte(0x30,LCD_DATA); // LCD_write_byte(0x30,LCD_DATA); // LCD_write_byte(0x39,LCD_DATA); // LCD_write_byte(0x3f,LCD_DATA); // LCD_write_byte(0x00,LCD_DATA); // LCD_write_byte(0x07,LCD_DATA); // LCD_write_byte(0x03,LCD_DATA); // LCD_write_byte(0x10,LCD_DATA); // // LCD_write_byte(0x2a,LCD_COMMAND); // LCD_write_byte(0x00,LCD_DATA); // LCD_write_byte(0x00,LCD_DATA); // LCD_write_byte(0x00,LCD_DATA); // LCD_write_byte(0x7f,LCD_DATA); // LCD_write_byte(0x2b,LCD_COMMAND); // LCD_write_byte(0x00,LCD_DATA); // LCD_write_byte(0x00,LCD_DATA); // LCD_write_byte(0x00,LCD_DATA); // LCD_write_byte(0x9f,LCD_DATA); // // LCD_write_byte(0xF0,LCD_COMMAND); //使能测试命令 // LCD_write_byte(0x01,LCD_DATA); // LCD_write_byte(0xF6,LCD_COMMAND); //关闭ram省电模式 // LCD_write_byte(0x00,LCD_DATA); // // LCD_write_byte(0x3A,LCD_COMMAND); //色深16bit // LCD_write_byte(0x05,LCD_DATA); // // LCD_write_byte(0x29,LCD_COMMAND); //开显示 // LCD_clear(GREEN); //清屏 //} //#endif