/* * \brief Draw a line on LCD, horizontal and vertical line are supported. * * \param x X-coordinate of line start. * \param y Y-coordinate of line start. * \param length line length. * \param direction line direction: 0 - horizontal, 1 - vertical. * \param color Pixel color. */ void LCDD_DrawLine( uint32_t x, uint32_t y, uint32_t length, uint32_t direction, uint32_t color) { uint32_t i = 0; LCD_SetCursor(x, y); if(direction == DIRECTION_HLINE) { LCD_WriteRAM_Prepare(); for(i = 0; i < length; i++) { LCD_WriteRAM(color); } } else { for(i = 0; i < length; i++) { LCD_WriteRAM_Prepare(); LCD_WriteRAM(color); y++; LCD_SetCursor(x, y); } } }
/******************************************************************************* * ?????? * *******************************************************************************/ void main() { OSCCON = 0b01110010 ; // ???????8?????? OPTION_REG = 0b00000000 ; // ????I/O??????????????? ANSELA = 0b00000000 ; // ??????????????????I/O?????? TRISA = 0b00000110 ; // ???RA1(SCL)/RA2(SDA)????(RA3?????) WPUA = 0b00000000 ; // RA1/RA2??????????????? PORTA = 0b00000000 ; // ????????(??LOW???) RA4 = 0; __delay_ms(500); RA4 = 1; __delay_ms(500); int i = 0; // ?????????(????100KHz) InitI2C_Master(1) ; // ?????????????? // ICON OFF,??????(0-63),VDD=3.3V???,LCD?8??? LCD_Init(LCD_NOT_ICON,32,LCD_VDD3V,8) ; while(1) { if(RA4 == 0) i++; LCD_SetCursor(0,0) ; // ????????? LCD_Puts("-JP7FKF-") ; LCD_SetCursor(0,1) ; // ????????? LCD_Putc(i+0x30) ; } }
/******************************************************************************* * Function Name : LCD_DrawChar * Description : Draws a character on LCD. * Input : - Xpos: the Line where to display the character shape. * This parameter can be one of the following values: * - Linex: where x can be 0..9 * - Ypos: start column address. * - c: pointer to the character data. * Output : None * Return : None *******************************************************************************/ void LCD_DrawChar(u8 Xpos, u16 Ypos, uc16 *c) { u32 index = 0, i = 0; u8 Xaddress = 0; Xaddress = Xpos; LCD_SetCursor(Xaddress, Ypos); for(index = 0; index < 24; index++) { LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ for(i = 0; i < 16; i++) { if((c[index] & (1 << i)) == 0x00) { LCD_WriteRAM(BackColor); } else { LCD_WriteRAM(TextColor); } } Xaddress++; LCD_SetCursor(Xaddress, Ypos); } }
/******************************************************************************* * Function Name : LCD_DrawLine * Description : Displays a line. * Input : - Xpos: specifies the X position. * - Ypos: specifies the Y position. * - Length: line length. * - Direction: line direction. * This parameter can be one of the following values: Vertical * or Horizontal. * Output : None * Return : None *******************************************************************************/ void LCD_DrawLine(u8 Xpos, u16 Ypos, u16 Length, u8 Direction) { u32 i = 0; LCD_SetCursor(Xpos, Ypos); if(Direction == Horizontal) { LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ for(i = 0; i < Length; i++) { LCD_WriteRAM(TextColor); } } else { for(i = 0; i < Length; i++) { LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ LCD_WriteRAM(TextColor); Xpos++; LCD_SetCursor(Xpos, Ypos); } } }
/** * @brief Draws a character on LCD. * @param Xpos: the Line where to display the character shape. * @param Ypos: start column address. * @param c: pointer to the character data. * @retval None */ void LCD_DrawChar(uint8_t Xpos, uint16_t Ypos, const uint16_t *c) { uint32_t index = 0, i = 0; uint8_t Xaddress = 0; Xaddress = Xpos; LCD_SetCursor(Xaddress, Ypos); for(index = 0; index < 24; index++) { LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ for(i = 0; i < 16; i++) { if((c[index] & (1 << i)) == 0x00) { LCD_WriteRAM(BackColor); } else { LCD_WriteRAM(TextColor); } } LCD_CtrlLinesWrite(LCD_NCS_GPIO_PORT, LCD_NCS_PIN, Bit_SET); Xaddress++; LCD_SetCursor(Xaddress, Ypos); } }
void display(void) { ss = RTC_Read(0x00); mm = RTC_Read(0x01); hh = RTC_Read(0x02); EE = RTC_Read(0x03); DD = RTC_Read(0x04); MM = RTC_Read(0x05); YY = RTC_Read(0x06); LCD_SetCursor(0, 0); // 表示位置を設定する LCD_Putc(YY / 16 + '0'); LCD_Putc(YY % 16 + '0'); LCD_Putc('/'); LCD_Putc(MM / 16 + '0'); LCD_Putc(MM % 16 + '0'); LCD_Putc('/'); LCD_Putc(DD / 16 + '0'); LCD_Putc(DD % 16 + '0'); LCD_SetCursor(0, 1); // 表示位置を設定する LCD_Putc(hh / 16 + '0'); LCD_Putc(hh % 16 + '0'); LCD_Putc(':'); LCD_Putc(mm / 16 + '0'); LCD_Putc(mm % 16 + '0'); LCD_Putc('-'); LCD_Putc(ss / 16 + '0'); LCD_Putc(ss % 16 + '0'); }
/** * @brief Clears the hole LCD. * @param Color: the color of the background. * @retval None */ void LCD_Clear(uint16_t Color) { uint32_t index = 0; if(LCDType == LCD_HX8347D) { LCD_SetCursor(0, 0); } else { LCD_SetCursor(0, 319); } /* Prepare to write GRAM */ LCD_WriteRAM_Prepare(); for(index = 0; index < (uint32_t)320*240; index++) { LCD_WriteRAM(Color); } /* Wait until a data is sent(not busy), before config /CS HIGH */ while (SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_BSY) != RESET); LCD_CtrlLinesWrite(LCD_NCS_GPIO_PORT, LCD_NCS_PIN, Bit_SET); }
void LCD_DisplayTime(unsigned char hr,unsigned char min, unsigned char sec) { uint8_t d_hour, d_min, d_sec; uint8_t digit0=0, digit1=0, digit2=0; d_hour = bcd2dec(hr); d_min = bcd2dec(min); d_sec = bcd2dec(sec); if ( Time_Format == 1 ) // 12 hour format { LCD_SetCursor(1,14); if (d_hour >12) { d_hour -= 12; LCD_Printf("PM"); } else { if ( d_hour == 0) // time is 12 AM { d_hour = 12; } LCD_Printf("AM"); } } if ( Display_Style == 1) // both date and time are displayed in this style { LCD_GoToLine(1); LCD_Printf(" %2d:%2d:%2d",d_hour,d_min,d_sec); } else // only date is displayed, so display big numbers { digit1 = d_hour/10; digit0= d_hour%10; LCD_DisplayBigNum(digit1,0); //display hour LCD_DisplayBigNum(digit0,3); // set colon LCD_SetCursor(1,6); lcd_DataWrite(0xA5); LCD_SetCursor(2,6); lcd_DataWrite(0xA5); //display min digit1 = d_min/10; digit0= d_min%10; LCD_DisplayBigNum(digit1,7); LCD_DisplayBigNum(digit0,10); //display sec LCD_SetCursor(2,14); LCD_Printf("%2x",sec); } }
/********************************************** 函数名:Lcd块选函数 功能:选定Lcd上指定的矩形区域 注意:xStart和 yStart随着屏幕的旋转而改变,位置是矩形框的四个角 入口参数:xStart x方向的起始点 ySrart y方向的终止点 xLong 要选定矩形的x方向长度 yLong 要选定矩形的y方向长度 返回值:无 ***********************************************/ void Lcd_SetBox(unsigned int xStart,unsigned int yStart,unsigned int xLong,unsigned int yLong) { #if ID_AM==000 LCD_SetCursor(xStart+xLong-1,312-yStart+yLong-1); #elif ID_AM==001 LCD_SetCursor(xStart+xLong-1,312-yStart+yLong-1); #elif ID_AM==010 LCD_SetCursor(xStart,312-yStart+yLong-1); #elif ID_AM==011 LCD_SetCursor(xStart,312-yStart+yLong-1); #elif ID_AM==100 LCD_SetCursor(xStart+xLong-1,312-yStart); #elif ID_AM==101 LCD_SetCursor(xStart+xLong-1,312-yStart); #elif ID_AM==110 LCD_SetCursor(xStart,312-yStart); #elif ID_AM==111 LCD_SetCursor(xStart,312-yStart); #endif LCD_WR_REG(0x0050,xStart);//水平 GRAM起始位置 LCD_WR_REG(0x0051,xStart+xLong-1);//水平GRAM终止位置 LCD_WR_REG(0x0052,312-yStart);//垂直GRAM起始位置 LCD_WR_REG(0x0053,312-yStart+yLong-1);//垂直GRAM终止位置 }
void LCD_DrawCircle2(u8 Xpos, u16 Ypos, u16 Radius) { s32 D;/* Decision Variable */ u32 CurX;/* Current X Value */ u32 CurY;/* Current Y Value */ D = 3 - (Radius << 1); CurX = 0; CurY = Radius; while (CurX <= CurY) { LCD_SetCursor(Xpos + CurX, Ypos + CurY); LCD_WriteRAMWord(BackColor); LCD_SetCursor(Xpos + CurX, Ypos - CurY); LCD_WriteRAMWord(BackColor); LCD_SetCursor(Xpos - CurX, Ypos + CurY); LCD_WriteRAMWord(BackColor); LCD_SetCursor(Xpos - CurX, Ypos - CurY); LCD_WriteRAMWord(BackColor); LCD_SetCursor(Xpos + CurY, Ypos + CurX); LCD_WriteRAMWord(BackColor); LCD_SetCursor(Xpos + CurY, Ypos - CurX); LCD_WriteRAMWord(BackColor); LCD_SetCursor(Xpos - CurY, Ypos + CurX); LCD_WriteRAMWord(BackColor); LCD_SetCursor(Xpos - CurY, Ypos - CurX); LCD_WriteRAMWord(BackColor); if (D < 0) { D += (CurX << 2) + 6; } else { D += ((CurX - CurY) << 2) + 10; CurY--; } CurX++; } }
//DCMI,启动传输 void DCMI_Start(void) { LCD_SetCursor(0,0); LCD_WriteRAM_Prepare(); //开始写入GRAM DMA2_Stream1->CR|=1<<0; //开启DMA2,Stream1 DCMI->CR|=1<<0; //DCMI捕获使能 }
/** * @brief Sets display window. * @param LayerIndex: layer index * @param Xpos: LCD X position * @param Ypos: LCD Y position * @param Width: LCD window width * @param Height: LCD window height * @retval None */ static void SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) { uint32_t value = 0; LCD_WriteReg(SSD2119_H_RAM_START_REG, Xpos); if ((Xpos+Width) >= LCD_PIXEL_WIDTH) { LCD_WriteReg(SSD2119_H_RAM_END_REG, LCD_PIXEL_WIDTH-1); } else { LCD_WriteReg(SSD2119_H_RAM_END_REG, Xpos+Width); } if ((Ypos+Height) >= LCD_PIXEL_HEIGHT) { value = (LCD_PIXEL_HEIGHT-1) << 8; } else { value = (Ypos+Height) << 8; } value |= Xpos; LCD_WriteReg(SSD2119_V_RAM_POS_REG, value); LCD_SetCursor(Xpos, Ypos); // /********************************************************************//** // * @brief for stm324fxG Eval EmWin // **********************************************************************/ // /* Horizontal GRAM Start Address */ // LCD_WriteReg(SSD2119_H_RAM_START_REG, (Ypos)); // /* Horizontal GRAM End Address */ // LCD_WriteReg(SSD2119_H_RAM_END_REG, (Ypos + Height - 1)); // // value = (LCD_PIXEL_WIDTH - Xpos - 1) << 8; // End addr // value |= (LCD_PIXEL_WIDTH - Xpos - Width); // Begin Addr // /* Vertical GRAM Start and End Address */ // LCD_WriteReg(SSD2119_V_RAM_POS_REG, value); }
/** * @brief Sets a display window * @param Xpos: specifies the X buttom left position. * @param Ypos: specifies the Y buttom left position. * @param Height: display window height. * @param Width: display window width. * @retval None */ void LCD_SetDisplayWindow(uint8_t Xpos, uint16_t Ypos, uint8_t Height, uint16_t Width) { /* Horizontal GRAM Start Address */ if(Xpos >= Height) { LCD_WriteReg(R80, (Xpos - Height + 1)); } else { LCD_WriteReg(R80, 0); } /* Horizontal GRAM End Address */ LCD_WriteReg(R81, Xpos); /* Vertical GRAM Start Address */ if(Ypos >= Width) { LCD_WriteReg(R82, (Ypos - Width + 1)); } else { LCD_WriteReg(R82, 0); } /* Vertical GRAM End Address */ LCD_WriteReg(R83, Ypos); LCD_SetCursor(Xpos, Ypos); }
/** * @brief Clears the hole LCD. * @param Color: the color of the background. * @retval None */ void LCD_Clear(uint16_t Color) { uint32_t index = 0; if (LCD_ID == LCD_HX8347D) { LCD_SetCursor(0x00, 0x0000); } else { LCD_SetCursor(0x00, 0x013F); } /* Prepare to write GRAM */ LCD_WriteRAM_Prepare(); for (index = 0; index < 76800; index++) { LCD->LCD_RAM = Color; } }
//在指定位置显示一个汉字(32*32大小) void showhanzi32(unsigned int x,unsigned int y,unsigned char index) { unsigned char i,j,k; const unsigned char *temp=hanzi32; temp+=index*128; for(j=0;j<32;j++) { LCD_SetCursor(x,y+j); LCD_WriteRAM_Prepare(); //开始写入GRAM for(k=0;k<4;k++) { for(i=0;i<8;i++) { if((*temp&(1<<i))!=0) { LCD_WR_DATA(POINT_COLOR); } else { LCD_WR_DATA(BACK_COLOR); } } temp++; } } }
/******************************************************************************* * Function Name : DrawClear_iLine * Description : отрисовка или очистка одной линии при линейной интерполяции * Input : X0pos, Y0pos, X1pos, Y1pos, clear * Return : None *******************************************************************************/ static __inline void DrawClear_iLine(uint16_t X0pos, uint16_t Y0pos, uint16_t Y1pos, DrawState NewDrawState) { uint16_t clrColor; uint16_t i, j; uint16_t tmpY; if(Y1pos < Y0pos){ tmpY = Y0pos; Y0pos = Y1pos; Y1pos = tmpY; } if(Y1pos - Y0pos == 0) j = 1; else j = Y1pos - Y0pos; Set_LCD_CS(); LCD_SetCursor(X0pos,Y0pos); // Установка курсора в нужную позицию if(NewDrawState == CLEAR) { for (i = 0; i < j; i++) { /* Проверяем на совпадение координат очистки с сеткой, если совпало то очищаем цветом сетки */ clrColor = Verify_Grid_Match(X0pos, Y0pos); LCD_PutPixel(clrColor); // очистить точку на установленной позиции Y0pos++; } } else // if(NewDrawState == DRAW) { for (i = 0; i < j; i++) LCD_PutPixel(pINFO->Color); // Нарисовать точку на установленной позиции } Reset_LCD_CS(); }
/******************************************************************************* * Function Name : Clear_OLD_Data_MIN_MAX * Description : очистка, режим максимумов/минимумов * Input : None * Return : None *******************************************************************************/ static void Clear_OLD_Data_MIN_MAX(uint16_t X0, uint16_t X1) { uint16_t cnt_, point = X0 - leftLimit, tmL, Length, clrColor; uint16_t num = (X1 - X0) * 2; /* Очищаем старую осциллограмму */ Set_LCD_CS(); for (cnt_ = (point * 2); cnt_ < num; cnt_ += 2) { if(pINFO->OldData_PointsFlag[point] == ENABLE) { LCD_SetCursor(point + leftLimit + 1, pINFO->visDATA[cnt_]); Length = fabs(pINFO->visDATA[cnt_+1] - pINFO->visDATA[cnt_]); if((Length < 1) || (Length > 190)) Length = 1; tmL = 0; /* очищаем линию от минимума до максимума */ while(tmL++ != Length) { /* Проверяем на совпадение координат очистки с сеткой, если совпало то очищаем цветом сетки */ clrColor = Verify_Grid_Match(point + leftLimit + 1, pINFO->visDATA[cnt_] + tmL - 1); LCD_PutPixel(clrColor); } } pINFO->OldData_PointsFlag[point] = DISABLE; point++; } Reset_LCD_CS(); }
/******************************************************************************* * Function Name : DrawClear_iLine * Description : отрисовка или очистка одной линии при линейной интерполяции * Input : X0pos, Y0pos, X1pos, Y1pos, clear * Return : None *******************************************************************************/ static __inline void DrawClear_MAXMIN_Line(uint16_t X0pos, uint16_t Y0pos, uint16_t Y1pos, DrawState NewDrawState) { uint16_t tmL = 0, tmpY; uint16_t clrColor; // цвет очистки int16_t Length; // длинна линни для отрисовки/очистки if(Y1pos < Y0pos){ tmpY = Y0pos; Y0pos = Y1pos; Y1pos = tmpY; } Set_LCD_CS(); // установить низкий уровень CS LCD // используем "низкоуровневый" доступ к ЖК для макс. скорости LCD_SetCursor(X0pos, Y0pos); Length = Y1pos - Y0pos; if((Length <= 0) || (Length > 190)) Length = 1; if(NewDrawState == CLEAR) { while(tmL++ != Length) // очищаем линию от минимума до максимума { /* Проверяем на совпадение координат очистки с сеткой, если совпало то очищаем цветом сетки */ clrColor = Verify_Grid_Match(X0pos, Y0pos + tmL - 1); LCD_PutPixel(clrColor); } } else // if(NewDrawState == DRAW) { while(tmL++ != Length) LCD_PutPixel(pINFO->Color); // Нарисовать точку на установленной позиции } Reset_LCD_CS(); }
/** * @brief Displays a bitmap picture loaded in the internal Flash. * @param BmpAddress: Bmp picture address in the internal Flash. * @retval None */ static void LCD_WriteBMP(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp) { uint32_t index = 0, size = 0; /* Read bitmap size */ size = *(__IO uint16_t *) (pbmp + 2); size |= (*(__IO uint16_t *) (pbmp + 4)) << 16; /* Get bitmap data address offset */ index = *(__IO uint16_t *) (pbmp + 10); index |= (*(__IO uint16_t *) (pbmp + 12)) << 16; size = (size - index)/2; pbmp += index; /* Set GRAM write direction and BGR = 1 */ /* I/D=00 (Horizontal : decrement, Vertical : decrement) */ /* AM=1 (address is updated in vertical writing direction) */ LCD_WriteReg(SSD2119_ENTRY_MODE_REG, ENTRY_MODE_BMP); LCD_SetCursor(Xpos, Ypos); LCD_WriteRAM_Prepare(); for(index = 0; index < size; index++) { LCD_WriteRAM(*(__IO uint16_t *)pbmp); pbmp += 2; } /* Set GRAM write direction and BGR = 1 */ /* I/D = 01 (Horizontal : increment, Vertical : decrement) */ /* AM = 1 (address is updated in vertical writing direction) */ LCD_WriteReg(SSD2119_ENTRY_MODE_REG, ENTRY_MODE_DEFAULT); }
void LCD_Clear(uint16_t color) { uint32_t index = 0; LCD_SetCursor(0x00, 0x00); LCD_WriteRAM_Prepare(); for(index = 0; index <76800; index++){ LCD_RAM = color; } }
static void clear( color c = white ){ int d = from_color( c ); LCD_SetCursor( 0x00, 0x0000 ); Write_Cmd( 0x22 ); // write RAM prepare for( int index = 0; index < 76800; index++ ){ Write_Dat( d ); } }
u16 LCD_ReadPoint(u16 x,u16 y) { LCD_SetCursor(x,y); LCD_ReadReg(0x0022); //读的第一个数据丢弃 opt_delay(2); return LCD->LCD_RAM; }
//读取个某点的颜色值 //x:0~239 //y:0~319 //返回值:此点的颜色 u16 LCD_ReadPoint(u16 x,u16 y) { u16 r,g,b; if(x>=LCD_W||y>=LCD_H)return 0; //超过了范围,直接返回 LCD_SetCursor(x,y); if(DeviceCode==0X9341)LCD_WR_REG(0X2E); //ILI9341发送读GRAM指令 else LCD_WR_REG(R34); //其他IC发送读GRAM指令 GPIOB->CRL=0X88888888; //PB0-7 上拉输入 GPIOB->CRH=0X88888888; //PB8-15 上拉输入 GPIOB->ODR=0XFFFF; //全部输出高 #if LCD_FAST_IO==1 //快速IO LCD_RS_SET; LCD_CS_CLR; //读取数据(读GRAM时,第一次为假读) LCD_RD_CLR; delay_us(1);//延时1us LCD_RD_SET; //dummy READ LCD_RD_CLR; delay_us(1);//延时1us LCD_RD_SET; r=DATAIN; if(DeviceCode==0X9341) { LCD_RD_CLR; LCD_RD_SET; b=DATAIN;//读取蓝色值 g=r&0XFF;//对于9341,第一次读取的是RG的值,R在前,G在后,各占8位 g<<=8; } LCD_CS_SET; #else LCD_RS=1; LCD_CS=0; //读取数据(读GRAM时,需要读2次) LCD_RD=0; LCD_RD=1; //dummy READ LCD_RD=0; LCD_RD=1; r=DATAIN; if(DeviceCode==0X9341) { LCD_RD=0; LCD_RD=1; b=DATAIN;//读取蓝色值 g=r&0XFF;//对于9341,第一次读取的是RG的值,R在前,G在后,各占8位 g<<=8; } LCD_CS=1; #endif GPIOB->CRL=0X33333333; //PB0-7 上拉输出 GPIOB->CRH=0X33333333; //PB8-15 上拉输出 GPIOB->ODR=0XFFFF; //全部输出高 if(DeviceCode==0X9325||DeviceCode==0X4535||DeviceCode==0X4531||DeviceCode==0X8989||DeviceCode==0XB505)return r; //这几种IC直接返回颜色值 else if(DeviceCode==0X9341)return (((r>>11)<<11)|((g>>10)<<5)|(b>>11)); //ILI9341需要公式转换一下 else return LCD_BGR2RGB(r); //其他IC
/** * \brief Draw a pixel on LCD of given color. * * \param x X-coordinate of pixel. * \param y Y-coordinate of pixel. * \param color Pixel color. */ void LCDD_DrawPixel( uint32_t x, uint32_t y, uint32_t color) { LCD_SetCursor(x, y); LCD_WriteRAM_Prepare(); LCD_WriteRAM(color); }
void LCD_SetArea(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { FSMC_LCD_Write_Command(0x44); FSMC_LCD_Write_Data((x2 << 8) | x1); // Source RAM address window FSMC_LCD_Write_Command(0x45); FSMC_LCD_Write_Data(y1); // Gate RAM address window FSMC_LCD_Write_Command(0x46); FSMC_LCD_Write_Data(y2); // Gate RAM address window LCD_SetCursor(x1, y1); }
/** * @brief Reads an LCD pixel. * @param Xpos: X position * @param Ypos: Y position * @retval RGB pixel color */ uint16_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos) { uint16_t ret=0; LCD_SetCursor(Xpos, Ypos); LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ ret = LCD_ReadRAM(); return ret; }
/***************************************************************************** ** �������: LCD_SetDisplayWindow ** ��������: ���ô��ں��� (��Width��Height����һ�£�ǰ����) ** �� ����: Dream ** �ա� ��: 2010��12��06�� *****************************************************************************/ void LCD_SetDisplayWindow(uint8_t Xpos, uint16_t Ypos, uint8_t Height, uint16_t Width) { LCD_WriteReg(R80, Xpos); //ˮƽ����GRAM��ʼ��ַ LCD_WriteReg(R81, Xpos+Height); //ˮƽ����GRAM�����ַ LCD_WriteReg(R82, Ypos); //��ֱ����GRAM��ʼ��ַ LCD_WriteReg(R83, Ypos+Width); //��ֱ����GRAM�����ַ LCD_SetCursor(Xpos, Ypos); //���ù��λ�� }
void LCD_Clear(uint16_t color) { uint32_t index = 0; LCD_SetCursor(0, 0); FSMC_LCD_Write_Command(0x22); for (index = 0; index < 240 * 320; index++) { FSMC_LCD_Write_Data(color); } FSMC_LCD_Write_Command(0x0022); }
uint8_t LCD_DisplayMenu() { int8_t keycount=0; LCD_Clear(); LCD_GoToLine(1); LCD_DisplayString(" Settings "); do { if (util_IsBitCleared(Button, cancel)) { return (-1); } if(util_IsBitCleared(Button, up)) { keycount++; _delay_ms(100); } if(util_IsBitCleared(Button, down)) { keycount--; _delay_ms(100); } if((keycount>=menusize)||(keycount <= -menusize)) { keycount=0; } if(keycount<0) { //make menu index circular. i.e decrement from first //option shows the last option on the menu keycount += menusize; } LCD_GoToLine(2); LCD_DisplayString(" "); //clear second line //set cursor at the center of of line 2 depending on string size. LCD_SetCursor(2,(14-strlen(settings[keycount]))/2); LCD_Printf("<%s>", settings[keycount]); _delay_ms(100); //make menu visible or else will overwrite at fast speed }while(util_IsBitSet(Button,select)); do { if (util_IsBitCleared(Button, cancel)) { return (-1); ; } }while(util_IsBitSet(Button, select)); return (keycount); }
/***************************************************************************** ** �������: LCD_Clear ** ��������: ����Ļ���� ** �� ����: Dream ** �ա� ��: 2010��12��06�� *****************************************************************************/ void LCD_Clear(uint16_t Color) { uint32_t index=0; LCD_SetCursor(0x00,0x0000); //���ù��λ�� LCD_WriteRAM_Prepare(); //��ʼд��GRAM for(index=0;index<76800;index++) { Write_Dat(Color); } }