/******************************************************************************* * Function Name : LCD_PowerOff * Description : Power off the LCD. * Input : None * Output : None * Return : None *******************************************************************************/ void LCD_Power_Off(void) { LCD_WriteCmd(Display_Off); // Power saver Delay(); LCD_WriteCmd(Display_All_On); // commands(compound) Delay(); }
void LCD_Update(void) { uint8_t i; LCD_WriteCmd(LCDCMD_SET_DDRAM_ADDRESS | LCD_FIRSTLINE_ADDRESS); for(i = 0; i < 16; i++) { if( LCDText[i] == 0 ) { LCD_WriteData(' '); } else { LCD_WriteData(LCDText[i]); } } LCD_WriteCmd(LCDCMD_SET_DDRAM_ADDRESS | LCD_SECONDLINE_ADDRESS); for(i = 16; i < 32; i++) { if( LCDText[i] == 0 ) { LCD_WriteData(' '); } else { LCD_WriteData(LCDText[i]); } } }
void LCD_SetStatus(unsigned char id,unsigned char status) { LCD_WriteCmd(0xee); LCD_WriteCmd(0xb8); LCD_WriteCmd(0x10|(id>>4)); LCD_WriteCmd(0x00|(id&0x0f)); LCD_WriteCmd(0xe0); LCD_WriteDat(status); }
/******************************************************************************* * Function Name : LCD_Sleep_Enter * Description : Enter the sleep mode. * Input : None * Output : None * Return : None *******************************************************************************/ void LCD_Sleep_Enter(void) { // Sleep Mode Setting (Sleep Mode) LCD_WriteCmd(Sleep_Mode_Enable); // preceding Command Delay(); LCD_WriteCmd(Sleep_Mode_Deliver); // pollowing Command Delay(); LCD_WriteCmd(Display_Off); // power saver Delay(); }
/*=====================================================================================================*/ void LCD_SetCursor( u16 CoordiX, u16 CoordiY ) { LCD_WriteCmd(0x2A); LCD_WriteData(Byte8H(CoordiX)); LCD_WriteData(Byte8L(CoordiX)); LCD_WriteCmd(0x2B); LCD_WriteData(Byte8H(CoordiY)); LCD_WriteData(Byte8L(CoordiY)); LCD_WriteCmd(0x2C); }
/*====================================================================================================*/ void LCD_SetCursor( uint16_t coordiX, uint16_t coordiY ) { LCD_WriteCmd(0x2A); LCD_WriteData(Byte8H(coordiX)); LCD_WriteData(Byte8L(coordiX)); LCD_WriteCmd(0x2B); LCD_WriteData(Byte8H(coordiY)); LCD_WriteData(Byte8L(coordiY)); LCD_WriteCmd(0x2C); }
void LCD_RealUpdate(uint8_t CursorState)//Do not call! { unsigned char i,j,rx; for (i=0;i<4;i++) { LCD_WriteCmd(0xee); LCD_WriteCmd(0xb0|(3-i)); LCD_WriteCmd(0x12); LCD_WriteCmd(0x04); LCD_WriteCmd(0xe0); for (j=0;j<96;j++) LCD_WriteDat(LCD_FB[i*96+j]); } LCD_FB_Touched = 0; if ((CursorEn)&&(CursorState)) { rx=CursorX+36; LCD_WriteCmd(0xee); LCD_WriteCmd(0xb0|(3-CursorY)); LCD_WriteCmd(0x10|(rx>>4)); LCD_WriteCmd(0x00|(rx&0x0f)); LCD_WriteCmd(0xe0); LCD_WriteDat(0xFF); LCD_WriteDat(0xFF); }
void LCD_LowLevelRefresh(uint8_t CursorState) { uint8_t i,j,rx; for (i=0;i<4;i++) { LCD_WriteCmd(0xee); LCD_WriteCmd(0xb0|(3-i)); LCD_WriteCmd(0x10); LCD_WriteCmd(0x00); LCD_WriteCmd(0xe0); for (j=0;j<96;j++) LCD_WriteDat(LCD_Screen[4+i*96+j]); } LCD_RefreshFlag = 0; if ((LCD_CursorEn)&&(CursorState)) { rx=LCD_CursorX; LCD_WriteCmd(0xee); LCD_WriteCmd(0xb0|(3-LCD_CursorY)); LCD_WriteCmd(0x10|(rx>>4)); LCD_WriteCmd(0x00|(rx&0x0f)); LCD_WriteCmd(0xe0); LCD_WriteDat(0xFF); LCD_WriteDat(0xFF); }
/******************************************************************************* * Function Name : LCD_PowerOn * Description : Power on the LCD. * Input : None * Output : None * Return : None *******************************************************************************/ void LCD_Power_On(void) { LCD_WriteCmd(Display_On); Delay(); LCD_WriteCmd(Power_Booster_On); Delay(); LCD_WriteCmd(Power_Regulator_On); Delay(); LCD_WriteCmd(Power_Follower_On); Delay(); }
void LCD_ClearStatus(void) { unsigned char i; LCD_WriteCmd(0xee); LCD_WriteCmd(0xb8); LCD_WriteCmd(0x10); LCD_WriteCmd(0x00); LCD_WriteCmd(0xe0); for (i=0;i<96;i++) LCD_WriteDat(0x00); }
/**************************************************************************** * Function Name : LCD_UpdatePoint * Description : refresh the point in screen * Input : x X-coordinate y Y-coordinate * Output : None * Return : None ****************************************************************************/ void LCD_UpdatePoint(unsigned int x, unsigned int y) { unsigned char coll, colh, page; page = y / 8; coll = x & 0x0f; colh = x >> 4; LCD_WriteCmd(Set_Page_Addr_0 | page); // page no. LCD_WriteCmd(Set_ColH_Addr_0 | colh); // fixed col first addr LCD_WriteCmd(Set_ColL_Addr_0 | coll); LCD_WriteData(gui_disp_buf[page][x]); }
/******************************************************************************* * Function Name : LCD_Sleep_Exit * Description : Exit the sleep mode. * Input : None * Output : None * Return : None *******************************************************************************/ void LCD_Sleep_Exit(void) { LCD_WriteCmd(Display_All_Normal); // display all points OFF Delay(); // Sleep Mode Setting (Normal Mode) LCD_WriteCmd(Sleep_Mode_Disable); // preceding Command Delay(); LCD_WriteCmd(Sleep_Mode_Deliver); // pollowing Command Delay(); LCD_WriteCmd(Display_On); Delay(); }
void UP_LCD_Init(void) { u16 i; Lcds_Config(); //初始化LCD管脚 RSTLCDS_L; for(i=0;i<65530;i++); RSTLCDS_H; for(i=0;i<15;i++) LCD_WriteCmd(LCD_Tab[i]); UP_LCD_ClearScreen(); //清屏 LCD_WriteCmd(0xaf); //开显示 }
/*====================================================================================================*/ void LCD_SetWindow( uint16_t startX, uint16_t startY, uint16_t endX, uint16_t endY ) { LCD_WriteCmd(0x2A); LCD_WriteData(Byte8H(startX)); LCD_WriteData(Byte8L(startX)); LCD_WriteData(Byte8H(endX)); LCD_WriteData(Byte8L(endX)); LCD_WriteCmd(0x2B); LCD_WriteData(Byte8H(startY)); LCD_WriteData(Byte8L(startY)); LCD_WriteData(Byte8H(endY)); LCD_WriteData(Byte8L(endY)); LCD_WriteCmd(0x2C); }
/*=====================================================================================================*/ void LCD_SetWindow( u16 StartX, u16 StartY, u16 EndX, u16 EndY ) { LCD_WriteCmd(0x2A); LCD_WriteData(Byte8H(StartX)); LCD_WriteData(Byte8L(StartX)); LCD_WriteData(Byte8H(EndX)); LCD_WriteData(Byte8L(EndX)); LCD_WriteCmd(0x2B); LCD_WriteData(Byte8H(StartY)); LCD_WriteData(Byte8L(StartY)); LCD_WriteData(Byte8H(EndY)); LCD_WriteData(Byte8L(EndY)); LCD_WriteCmd(0x2C); }
/** * 函数名称:LCD_ShowString * 函数参数:坐标值 、字符串 * 函数功能:lcd1602 设置坐标 * 日期:2016-1-20 */ void LCD_ShowString(uint8 x, uint8 y, uint8 *str) { LCD_WriteCmd((((y & 1) << 6) + x) | 0x80); /* 设置光标的位置 */ while(*str) { LCD_WriteData(*str++); } }
unsigned short LCD_ReadReg(unsigned char reg_addr) { unsigned short val=0; LCD_WriteCmd(reg_addr); //val = *(__IO u16 *)(Bank1_LCD_D); val = LCD_D; return (val); }
/****************************************************************************** * Function: void LCDErase(void) * * PreCondition: LCDInit() must have been called once * * Input: None * * Output: None * * Side Effects: None * * Overview: Clears LCDText[] and the LCD's internal display buffer * * Note: None *****************************************************************************/ void LCD_Erase(void) { // Clear display LCD_WriteCmd(LCDCMD_CLEARDISPLAY);; DELAY_ms(2); // Clear local copy memset(LCDText, ' ', 32); }
/******************************************************************************* * Function Name : Chk_DMA_Busy * Description : Check whether the DMA is busy * Input : None * Output : None * Return : None * Attention : None *******************************************************************************/ void Chk_DMA_Busy(void) { uint8_t temp; do { LCD_WriteCmd(0xbf); temp = LCD_ReadData(); }while((temp&0x01)==0x01); }
/******************************************************************************* * Function Name : LCD_FillAll * Description : Fill the whole LCD. * Input : None * Output : None * Return : None *******************************************************************************/ void LCD_FillAll(unsigned char* data) { unsigned char i,j = GUI_LCM_XMAX; unsigned char* p = data; for(i=0; i<GUI_LCM_PAGE; i++) { LCD_WriteCmd(Set_Page_Addr_0|i); LCD_WriteCmd(Set_ColH_Addr_0); LCD_WriteCmd(Set_ColL_Addr_0); j = GUI_LCM_XMAX; while(j--) { LCD_WriteData(*p++); Delay(); Delay(); } } }
/************************************************* 函数: void UP_LCD_ClearLine(u8 y) 功能: 清除指定行内容 参数: 无 返回: 无 **************************************************/ void UP_LCD_ClearLine(u8 y) { u8 i; u8 seg; u8 page; if (y > 3) return; for(i=0; i<2; i++) //写页地址,一行有2页 { page = 0xb0 + (y<<1) + i; LCD_WriteCmd(page); LCD_WriteCmd(0x10); //列地址,高低字节两次写入,从第0 列开始 LCD_WriteCmd(0x00); for(seg=0; seg<128; seg++)//写128 列 { LCD_WriteData(0x00); } } }// */
static void LCD_SetCursor(uint16_t x, uint16_t y) { //竖屏 // LCD_WriteCmd (0x2A);//设定x坐标 // LCD_WriteData(x>>8); // LCD_WriteData(0xFF&x); // LCD_WriteCmd (0x2B);//设定y坐标 // LCD_WriteData(y>>8); // LCD_WriteData(0xFF&y); //横屏 LCD_WriteCmd(0x2B); //设定x坐标 LCD_WriteData((LCD_WIDTH - x) >> 8); LCD_WriteData(0xFF & (LCD_WIDTH - x)); LCD_WriteCmd(0x2A); //设定y坐标 LCD_WriteData(y >> 8); LCD_WriteData(0xFF & y); }
/************************************************* 函数: void UP_LCD_ShowLetter(u8 x, u8 y, u8 ch) 功能: 显示单个字符 参数: 无 返回: 无 **************************************************/ void UP_LCD_ShowLetter(u8 x, u8 y, u8 ch) { u8 i; if(y > 3 || x > 16) return; x <<=3; if(ch >= 32 && ch <= 125) { LCD_WriteCmd(0xb0+(y<<1)); //page地址 LCD_WriteCmd(0x10+(x>>4)); //列地址,高低字节两次写入,从第0列开始 LCD_WriteCmd(0x00+(x&0x0f)); for(i=0; i<8; i++) //上八列 { LCD_WriteData(LCD_Letters[((ch-32)<<4)+i]); } LCD_WriteCmd(0xb1+(y<<1)); //page地址 LCD_WriteCmd(0x10+(x>>4)); //列地址,高低字节两次写入,从第0列开始 LCD_WriteCmd(0x00+(x&0x0f)); for(i=0; i<8; i++) //下八列 { LCD_WriteData(LCD_Letters[((ch-32)<<4)+8+i]); } }
/** * 函数名称:LCD_Init * 函数参数:无 * 函数功能:lcd1602 初始化 * 日期:2016-1-20 */ void LCD_Init(void) { LCD_WriteCmd(0x38); //16*2显示,5*7点阵,8位数据接口 delay_ms(5); LCD_WriteCmd(0x38); //16*2显示,5*7点阵,8位数据接口 delay_ms(5); LCD_WriteCmd(0x38); //16*2显示,5*7点阵,8位数据接口 delay_ms(5); LCD_WriteCmd(0x0C); //显示器开,光标关闭 LCD_WriteCmd(0x06); //文字不动,地址自动+1 LCD_WriteCmd(0x01); //清屏 }
/******************************************************************************* * Function Name : LCD_Init * Description : initialize lcd * Input : None. * Return : None. *******************************************************************************/ void LCD_Initialize(void) { Power_Delay(); LCD_WriteCmd(Display_Off); Reset_Delay(); // Resetting circuit LCD_WriteCmd(Reset_LCD); Reset_Delay(); // LCD bias setting LCD_WriteCmd(Set_LCD_Bias_9); Reset_Delay(); // ADC selection: display from left to right LCD_WriteCmd(Set_ADC_Normal); Reset_Delay(); // Common output state selection: display from up to down LCD_WriteCmd(COM_Scan_Dir_Reverse); Reset_Delay(); LCD_WriteCmd(Power_Booster_On); Power_Delay(); // 50ms requried LCD_WriteCmd(Power_Regulator_On); Power_Delay(); // 50ms LCD_WriteCmd(Power_Follower_On); Power_Delay(); // 50ms // Setting the built-in resistance radio for regulation of the V0 voltage // Electronic volume control // Power control setting LCD_WriteCmd(Set_ElecVol_Reg|0x05); Delay(); LCD_WriteCmd(Set_ElecVol_Mode); Delay(); LCD_WriteCmd(Set_ElecVol_Reg); Delay(); LCD_WriteCmd(Set_Page_Addr_0); Delay(); LCD_WriteCmd(Set_ColH_Addr_0); Delay(); LCD_WriteCmd(Set_ColL_Addr_0); Delay(); LCD_WriteCmd(Display_On); Delay(); LCD_WriteCmd(Display_All_On); Delay(); LCD_WriteCmd(Display_Off); Delay(); LCD_WriteCmd(Display_On); Delay(); LCD_WriteCmd(Display_All_Normal); Delay(); LCD_ClearSCR(); }
void LCD_SetBrightness(uint8_t percent) { LCD_WriteCmd(0x81); LCD_WriteCmd(percent); }
/*=====================================================================================================*/ void R61581_Init( void ) { // Reset LCD_RST = 0; Delay_1ms(15); LCD_RST = 1; Delay_1ms(5); Delay_1ms(50); LCD_WriteReg(0x00, 0x01); Delay_1ms(50); LCD_WriteCmd(0xB0); // {setc, [107], W, 0x000B0} LCD_WriteData(0x00); // {setp, [104], W, 0x00000} LCD_WriteCmd(0xB3); LCD_WriteData(0x02); LCD_WriteData(0x00); LCD_WriteData(0x00); LCD_WriteData(0x00); LCD_WriteCmd(0xB4); LCD_WriteData(0x00); LCD_WriteCmd(0xC0); LCD_WriteData(0x13); // LCD_WriteData(0x3B); // 480 LCD_WriteData(0x00); LCD_WriteData(0x03); // 02 LCD_WriteData(0x00); LCD_WriteData(0x01); LCD_WriteData(0x00); LCD_WriteData(0x43); LCD_WriteCmd(0xC1); LCD_WriteData(0x08); // 08 LCD_WriteData(0x10); // CLOCK//0x12 LCD_WriteData(0x08); LCD_WriteData(0x08); LCD_WriteCmd(0xC4); LCD_WriteData(0x11); LCD_WriteData(0x07); LCD_WriteData(0x03); LCD_WriteData(0x03); // Gamma For 3.5inch LCD_WriteCmd(0xC8); // Gamma setting LCD_WriteData(0x00); LCD_WriteData(0x25); LCD_WriteData(0x21); LCD_WriteData(0x05); LCD_WriteData(0x00); LCD_WriteData(0x0A); LCD_WriteData(0x65); LCD_WriteData(0x25); LCD_WriteData(0x77); LCD_WriteData(0x50); LCD_WriteData(0x0F); LCD_WriteData(0x00); LCD_WriteCmd(0x2A); LCD_WriteData(0x00); LCD_WriteData(0x00); LCD_WriteData(0x01); LCD_WriteData(0x3F); // 320 LCD_WriteCmd(0x2B); LCD_WriteData(0x00); LCD_WriteData(0x00); LCD_WriteData(0x01); LCD_WriteData(0xDF); // 480 LCD_WriteCmd(0x35); LCD_WriteData(0x00); LCD_WriteCmd(0x36); LCD_WriteData(0x31); LCD_WriteCmd(0x3A); LCD_WriteData(0x55); LCD_WriteCmd(0x44); LCD_WriteData(0x00); LCD_WriteData(0x01); LCD_WriteCmd(0x2C); LCD_WriteCmd(0x11); Delay_1ms(150); LCD_WriteCmd(0xD0); LCD_WriteData(0x07); LCD_WriteData(0x07); LCD_WriteData(0x1E); LCD_WriteData(0x03); // LCD_WriteData(0x0703); LCD_WriteCmd(0xD1); LCD_WriteData(0x03); LCD_WriteData(0x52); // VCM LCD_WriteData(0x10); // VDV LCD_WriteCmd(0xD2); LCD_WriteData(0x03); LCD_WriteData(0x24); LCD_WriteCmd(0xB0); // {setc, [107], W, 0x000B0} LCD_WriteData(0x00); // {setp, [104], W, 0x00000} LCD_WriteCmd(0x29); Delay_1ms(10); LCD_WriteReg(0x36, 0x31); LCD_Clear(BLACK); LCD_SetBackLight(BLIGHT_DEFAULT); }
void LCD_Init(void) { LCD_GPIO_Config(); printf("GPIO Initaled.\r\n"); LCD_FSMC_Config(); printf("FSMC Configed.\r\n"); LCD_Rst(); printf("LCD Reseted.\r\n"); //printf("Invalid LCD ID:%08X\r\n",LCD_ReadReg(0x00)); LCD_WriteCmd(0xe2);//system reset Delay(5); LCD_WriteCmd(0xae); LCD_WriteCmd(0xf8); LCD_WriteCmd(0x00); LCD_WriteCmd(0xa2); LCD_WriteCmd(0xa0); LCD_WriteCmd(0xc0); LCD_WriteCmd(0xa6); LCD_WriteCmd(0xa4); LCD_WriteCmd(0xe0); LCD_WriteCmd(0xac); LCD_WriteCmd(0x00); LCD_WriteCmd(0x21); LCD_WriteCmd(0x81); LCD_WriteCmd(0x1e); LCD_WriteCmd(0x2f); LCD_WriteCmd(0x40); Delay(5); LCD_WriteCmd(0xaf); }
/******************************************************************************* * Function Name : LCD_DisplayOff * Description : Disables the Display. * Input : None * Output : None * Return : None *******************************************************************************/ void LCD_DisplayOff(void) { LCD_WriteCmd(Display_Off); }
/******************************************************************************* * Function Name : LCD_DisplayOn * Description : Enables the Display. * Input : None * Output : None * Return : None *******************************************************************************/ void LCD_DisplayOn(void) { LCD_WriteCmd(Display_On); }