void GLCDLowLevel_SwapBuffer(){ uint32_t a,b; int8_t c,d; for (a=0; a<40; a++){ GLCD_WriteCommand(0x46); GLCD_WriteData(RA8835_SAD2L + a); GLCD_WriteData(RA8835_SAD2H); GLCD_WriteCommand(RA8835_MWRITE); for (b=0; b<30; b++){ for (c=0; c<8; c++){ for (d=0; d<8; d++){ if (d-c >= 0){ GLCDLowLevel_VideoRAM_aux+= (((0x01 << c) & GLCDLowLevel_VideoRAM[(a*8)+(7-d)][b]) << (d-c)); } else { GLCDLowLevel_VideoRAM_aux+= (((0x01 << c) & GLCDLowLevel_VideoRAM[(a*8)+(7-d)][b]) >> (c-d)); } } GLCD_WriteData(GLCDLowLevel_VideoRAM_aux); GLCDLowLevel_VideoRAM_aux=0; } } } }
//------------------------------------------------------------------------------------------------- // Schow Battery_CHG //------------------------------------------------------------------------------------------------- void GLCD_bat_chg(unsigned char prc) { unsigned char i, j; GLCD_GoTo(KS0108_SCREEN_WIDTH-15,0); if(prc > 75) i = 0; else if(prc > 50 && prc <= 75) i = 15; else if(prc > 25 && prc <= 50) i = 30; else if(prc <= 25) i = 45; j = i + 12; for(; i < j; i++) GLCD_WriteData(battery[i]); GLCD_WriteData((battery[i]|0xC0)); GLCD_WriteData(battery[i+1]); GLCD_WriteData((battery[i+2]|0xC0)); }
//------------------------------------------------------------------------------------------------- // //------------------------------------------------------------------------------------------------- void GLCD_WriteChar(char charToWrite) { int i; charToWrite -= 32; for(i = 0; i < 5; i++) GLCD_WriteData(GLCD_ReadByteFromROMMemory((char *)((int)font5x8 + (5 * charToWrite) + i))); GLCD_WriteData(0x00); }
void ShowBigTime(char hten, char hone, char mten, char mone) { WriteBigChar(hten,0,0); WriteBigChar(hone,32,0); WriteBigChar(mten,64,0); WriteBigChar(mone,96,0); GLCD_GoTo(63,4); GLCD_WriteData(0b0001100); GLCD_WriteData(0b0001100); GLCD_GoTo(63,2); GLCD_WriteData(0b0001100); GLCD_WriteData(0b0001100); }
void GLCD_ClearPage(uint8_t page, uint8_t color) { for (uint8_t x = 0; x < DISPLAY_WIDTH; x++) { GLCD_GotoXY(x, page * 8); GLCD_WriteData(color); } }
//------------------------------------------------------------------------------------------------- // Writes INV char to screen memory //------------------------------------------------------------------------------------------------- void GLCD_WriteINVChar(char charToWrite) { char i; unsigned char t=0; charToWrite -= 32; for(i = 0; i < 5; i++) { t = GLCD_ReadByteFromROMMemory((char *)(font5x8 + (5 * charToWrite) + i)); GLCD_WriteData(~t); } GLCD_WriteData(0xFF); }
//----------------------- void putpixel(unsigned int x, unsigned int y) { unsigned char tmp=0; GLCD_GoTo(x, (y / 8)); tmp |= (1 << (y % 8)); GLCD_WriteData(tmp); }
//------------------------------------------------------------------------------------------------------- // GLCD_ClearText //------------------------------------------------------------------------------------------------------- void GLCD_ClearText(uint16_t x,uint16_t y,uint16_t digit) { int i; GLCD_TextGoTo(x,y); GLCD_WriteCommand(SED1335_MWRITE); for(i = 0; i < digit; i++) GLCD_WriteData(' '); }
void GLCD_ClearGraphic1(void) { unsigned int i; GLCD_SetCursorAddress(SED1335_GRAPHICSTART); GLCD_WriteCommand(SED1335_MWRITE); for(i = 0; i < (40 * 240); i++) GLCD_WriteData(0x00); }
//------------------------------------------------------------------------------------------------------- // // Clears text area of display RAM memory // //------------------------------------------------------------------------------------------------------- void GLCD_ClearText1(void) { int i; GLCD_TextGoTo(0,0); GLCD_WriteCommand(SED1335_MWRITE); for(i = 0; i < 1200; i++) GLCD_WriteData(' '); }
/* void GLCD_WriteTextP(char * tekst) { GLCD_WriteCommand(SED1335_MWRITE); while(GLCD_ReadByteFromROMMemory(tekst)) GLCD_WriteData(GLCD_ReadByteFromROMMemory(tekst++)); } */ void GLCD_WriteTextP(PGM_P str) { GLCD_WriteCommand(SED1335_MWRITE); while(pgm_read_byte(str) != 0) { GLCD_WriteData(pgm_read_byte(str)); str++; } }
void GLCD_ClearText(void) { int i; GLCD_TextGoTo(0,0); GLCD_WriteCommand(RA8835_CSRDIR_R); GLCD_WriteCommand(RA8835_MWRITE); for(i = 0; i < 50000; i++) GLCD_WriteData(0x00); GLCD_WriteCommand(RA8835_CSRDIR_D); }
//------------------------------------------------------------------------------------------------- // //------------------------------------------------------------------------------------------------- void GLCD_ClearScreen(void) { unsigned char i, j; for(j = 0; j < KS0108_SCREEN_HEIGHT/8; j++) { GLCD_GoTo(0,j); for(i = 0; i < KS0108_SCREEN_WIDTH; i++) GLCD_WriteData(0x00); } }
//------------------------------------------------------------------------------------------------- // //------------------------------------------------------------------------------------------------- void GLCD_Bitmap(char * bmp, unsigned char x, unsigned char y, unsigned char dx, unsigned char dy) { unsigned char i, j; for(j = 0; j < dy / 8; j++) { GLCD_GoTo(x,y + j); for(i = 0; i < dx; i++) GLCD_WriteData(GLCD_ReadByteFromROMMemory(bmp++)); } }
//------------------------------------------------------------------------------------------------- // //------------------------------------------------------------------------------------------------- void GLCD_SetPixel(unsigned char x, unsigned char y, unsigned char color) { unsigned char tmp; GLCD_GoTo(x, (y / 8)); tmp = GLCD_ReadData(); GLCD_GoTo(x, (y / 8)); tmp = GLCD_ReadData(); GLCD_GoTo(x, (y / 8)); tmp |= (1 << (y % 8)); GLCD_WriteData(tmp); }
//----------------------- int GLCD_Write_farsi(char charToWrite) { //charToWrite -= 32; char bit_8; int i,ii=0; for(i = 0; i < 8; i++) { bit_8=GLCD_ReadByteFromROMMemory((char *)((int)farsi + (8 * charToWrite) + i)); if(bit_8 == 0x00) ii++; GLCD_WriteData(bit_8); } return (ii); }
void drawAChar(uint16_t x, int y, int width, int height, unsigned int offset, const unsigned char *fontBitmap) { int pos = offset; unsigned char data; for(int i = 0; i < height-1 ; i++) { GLCD_GraphicGoTo(x, y+i); GLCD_WriteCommand(SED1335_MWRITE); for(int j = 0; j < width/8 ; j++) { data = pgm_read_byte(&fontBitmap[pos]); GLCD_WriteData(data); pos++; } } }
void WriteBigChar(char num, char x_start, char y_start) { for (char i = 0; i < 6; i++) { GLCD_GoTo(x_start,(y_start + i)); for (char col_marker = 0; col_marker < 32; col_marker++) { GLCD_WriteData( GLCD_ReadByteFromROMMemory( (char *)((int)big_font + ((col_marker * 6) + (5 - i) + (num * 192))) ) ); } } }
//------------------------------------------------------------------------------------------------------- // // Set (if color==1) or clear (if color==0) pixel on screen // //------------------------------------------------------------------------------------------------------- void GLCD_SetPixel(unsigned int x,unsigned int y, int color) { unsigned char tmp = 0; unsigned int address = SED1335_GRAPHICSTART + (40 * y) + (x/8); GLCD_SetCursorAddress(address); GLCD_WriteCommand(SED1335_MREAD); tmp = GLCD_ReadData(); if(color) tmp |= (1 << (SED1335_FX - (x % 8))); else tmp &= ~(1 << (SED1335_FX - (x % 8))); GLCD_SetCursorAddress(address); GLCD_WriteCommand(SED1335_MWRITE); GLCD_WriteData(tmp); }
//------------------------------------------------------------------------------------------------- // ÷иклически перезаписывает строки на дисплее //------------------------------------------------------------------------------------------------- void GLCD_PutString(char * stringToPut) { static unsigned char str=1; unsigned char i=0; if(str<8) { GLCD_GoTo(0,str); for(i = 0; i < KS0108_SCREEN_WIDTH; i++) GLCD_WriteData(0x00); GLCD_GoTo(0,str); GLCD_WriteString(stringToPut); ++str; } else { str=1; } }
//------------------------------------------------------------------------------------------------- // // Display initalization // //------------------------------------------------------------------------------------------------- void GLCD_Initalize(void) { GLCD_InitalizeInterface(); GLCD_CTRL_PORT &= ~(1 << GLCD_RESET); _delay_ms(1); GLCD_CTRL_PORT |= (1 << GLCD_RESET); #if (GLCD_FONT_WIDTH == 8) GLCD_CTRL_PORT &= ~(1 << GLCD_FS); #endif GLCD_WriteData(GLCD_GRAPHIC_HOME & 0xFF); GLCD_WriteData(GLCD_GRAPHIC_HOME >> 8); GLCD_WriteCommand(T6963_SET_GRAPHIC_HOME_ADDRESS); GLCD_WriteData(GLCD_GRAPHIC_AREA); GLCD_WriteData(0x00); GLCD_WriteCommand(T6963_SET_GRAPHIC_AREA); GLCD_WriteData(GLCD_TEXT_HOME); GLCD_WriteData(GLCD_TEXT_HOME >> 8); GLCD_WriteCommand(T6963_SET_TEXT_HOME_ADDRESS); GLCD_WriteData(GLCD_TEXT_AREA); GLCD_WriteData(0x00); GLCD_WriteCommand(T6963_SET_TEXT_AREA); GLCD_WriteData(GLCD_OFFSET_REGISTER); GLCD_WriteData(0x00); GLCD_WriteCommand(T6963_SET_OFFSET_REGISTER); GLCD_WriteCommand(T6963_DISPLAY_MODE | T6963_GRAPHIC_DISPLAY_ON | T6963_TEXT_DISPLAY_ON /*| T6963_CURSOR_DISPLAY_ON*/); GLCD_WriteCommand(T6963_MODE_SET | 0); }
void barrgraph(short xpos, short ypos, short width, short value, short step) //Affiche un ligne gradué de 0 à 24 pixel { unsigned char A; unsigned char B; unsigned char C; char tab[]; short i = 0; if(value < 8){ A = 0x00; B = 0x00; C = value2graph(value);} if(value >= 8 && value < 16){ A = 0x00; B = value2graph(value - 8); C = 0xFF;} if(value >= 16){ A = value2graph(value - 16); B = 0xFF; C = 0xFF;} for(i = 0; i < width; i++) { if(step == 0){ GLCD_GoTo(xpos+i,ypos); GLCD_WriteData(A); GLCD_GoTo(xpos+i,ypos+1); GLCD_WriteData(B); GLCD_GoTo(xpos+i,ypos+2); GLCD_WriteData(C);} if(step == 1){ GLCD_GoTo(xpos+i,ypos); GLCD_WriteData(A&0xAA); GLCD_GoTo(xpos+i,ypos+1); GLCD_WriteData(B&0xAA); GLCD_GoTo(xpos+i,ypos+2); GLCD_WriteData(C&0xAA);} } }
//------------------------------------------------------------------------------------------------- // Schow Border //------------------------------------------------------------------------------------------------- void GLCD_DrawBrd(void) { unsigned char i, j; GLCD_GoTo(0,0); GLCD_WriteData(0xFF); GLCD_WriteData(0x1); GLCD_WriteData(0xFD); for(i = 3; i < KS0108_SCREEN_WIDTH-3; i++) GLCD_WriteData(0x5); GLCD_WriteData(0xFD); GLCD_WriteData(0x1); GLCD_WriteData(0xFF); for(j = 1; j < KS0108_SCREEN_HEIGHT/8-1; j++) { GLCD_GoTo(0,j); GLCD_WriteData(0xFF); GLCD_WriteData(0x00); GLCD_WriteData(0xFF); GLCD_GoTo(KS0108_SCREEN_WIDTH-3,j); GLCD_WriteData(0xFF); GLCD_WriteData(0x00); GLCD_WriteData(0xFF); } GLCD_GoTo(0,KS0108_SCREEN_HEIGHT/8-1); GLCD_WriteData(0xFF); GLCD_WriteData(0x80); GLCD_WriteData(0xBF); for(i = 3; i < KS0108_SCREEN_WIDTH-3; i++) GLCD_WriteData(0xA0); GLCD_WriteData(0xBF); GLCD_WriteData(0x80); GLCD_WriteData(0xFF); }
//------------------------------------------------------------------------------------------------------- // // Display initalization // //------------------------------------------------------------------------------------------------------- void GLCD_Initialize(void) { GLCD_InitializePorts(); GLCD_WriteCommand(SED1335_SYSTEM_SET); GLCD_WriteData(SED1335_SYS_P1); GLCD_WriteData(SED1335_SYS_P2); GLCD_WriteData(SED1335_FY); GLCD_WriteData(SED1335_CR); GLCD_WriteData(SED1335_TCR); GLCD_WriteData(SED1335_LF); GLCD_WriteData(SED1335_APL); GLCD_WriteData(SED1335_APH); GLCD_WriteCommand(SED1335_SCROLL); GLCD_WriteData(SED1335_SAD1L); GLCD_WriteData(SED1335_SAD1H); GLCD_WriteData(SED1335_SL1); GLCD_WriteData(SED1335_SAD2L); GLCD_WriteData(SED1335_SAD2H); GLCD_WriteData(SED1335_SL2); GLCD_WriteData(SED1335_SAD3L); GLCD_WriteData(SED1335_SAD3H); GLCD_WriteData(SED1335_SAD4L); GLCD_WriteData(SED1335_SAD4H); GLCD_WriteCommand(SED1335_CSRFORM); GLCD_WriteData(SED1335_CRX); GLCD_WriteData(SED1335_CSRF_P2); GLCD_WriteCommand(SED1335_CGRAM_ADR); GLCD_WriteData(SED1335_SAGL); GLCD_WriteData(SED1335_SAGH); GLCD_WriteCommand(SED1335_CSRDIR_R); GLCD_WriteCommand(SED1335_HDOT_SCR); GLCD_WriteData(SED1335_SCRD); GLCD_WriteCommand(SED1335_OVLAY); GLCD_WriteData(SED1335_OVLAY_P1); GLCD_WriteCommand(SED1335_DISP_ON); GLCD_WriteData(SED1335_FLASH); }
//------------------------------------------------------------------------------------------------- // // Writes display data and increment address pointer // //------------------------------------------------------------------------------------------------- void GLCD_WriteDisplayData(unsigned char x) { GLCD_WriteData(x); GLCD_WriteCommand(T6963_DATA_WRITE_AND_INCREMENT); }
void GLCD_WriteText(char * tekst) { GLCD_WriteCommand(RA8835_MWRITE); while(*tekst) GLCD_WriteData(*tekst++); }
void LcdInit(void) { int i; __delay_cycles(990000); __delay_cycles(990000); __delay_cycles(990000); __delay_cycles(990000); __delay_cycles(990000); __delay_cycles(990000); A0_1; RD_1; WR_1; SED1335_CS_0 ; RST_0; __delay_cycles(990000); __delay_cycles(990000); RST_1; __delay_cycles(990000); __delay_cycles(990000); RST_0; __delay_cycles(990000); __delay_cycles(990000); __delay_cycles(990000); __delay_cycles(990000); __delay_cycles(990000); __delay_cycles(990000); GLCD_WriteCommand(SED1335_SYSTEM_SET); GLCD_WriteData(SED1335_SYS_P1); GLCD_WriteData(SED1335_SYS_P2); GLCD_WriteData(SED1335_FY); GLCD_WriteData(SED1335_CR); GLCD_WriteData(SED1335_TCR); GLCD_WriteData(SED1335_LF); GLCD_WriteData(SED1335_APL); GLCD_WriteData(SED1335_APH); GLCD_WriteCommand(SED1335_SCROLL); GLCD_WriteData(0); GLCD_WriteData(0); GLCD_WriteData(0xef); GLCD_WriteData(0xb0); GLCD_WriteData(0x04); GLCD_WriteData(0xef); GLCD_WriteData(0); GLCD_WriteData(0); GLCD_WriteData(0); GLCD_WriteData(0); GLCD_WriteCommand(SED1335_CSRFORM); GLCD_WriteData(0x04); GLCD_WriteData(0x07); GLCD_WriteCommand(SED1335_CGRAM_ADR); GLCD_WriteData(0); GLCD_WriteData(0); GLCD_WriteCommand(SED1335_CSRDIR_R); GLCD_WriteCommand(SED1335_HDOT_SCR); GLCD_WriteData(SED1335_SCRD); GLCD_WriteCommand(SED1335_OVLAY); GLCD_WriteData(0x01); GLCD_WriteCommand(SED1335_DISP_ON); GLCD_WriteData(SED1335_FLASH); //CLEAR TEXT MODE GLCD_WriteCommand(SED1335_CSRW); GLCD_WriteData(0); GLCD_WriteData(0); GLCD_WriteCommand(SED1335_MWRITE); for(i = 0; i < 1200; i++) GLCD_WriteData(' '); }
void GLCD_SetCursorAddress(unsigned int address) { GLCD_WriteCommand(RA8835_CSRW); GLCD_WriteData((unsigned char)(address & 0xFF)); GLCD_WriteData((unsigned char)(address >> 8)); }
//------------------------------------------------------------------------------------------------- // // Sets address pointer for display RAM memory // //------------------------------------------------------------------------------------------------- void GLCD_SetAddressPointer(unsigned int address) { GLCD_WriteData(address & 0xFF); GLCD_WriteData(address >> 8); GLCD_WriteCommand(T6963_SET_ADDRESS_POINTER); }
void GLCDLowLevel_Init() { MicroInterface_Init(); // Init ports ////////////////////////////////// // SYSTEM_SET // ////////////////////////////////// GLCD_WriteCommand(RA8835_SYSTEM_SET); //Writng into command register System set GLCD_WriteData(RA8835_SYS_P1); //P1 M0: Internal CG ROM // M1: CG RAM is 32 characters maximum // M2: 8-pixel character height // W/S: Two-panel drive // IV: No top-line compensation GLCD_WriteData(RA8835_SYS_P2); //P2 FX: Horizontal character size = 8 pixels // WF: Two-frame AC drive GLCD_WriteData(RA8835_FY); //P3 FY: Vertical character size = 8 pixels GLCD_WriteData(RA8835_CR); //P4 C/R: 39 display addresses per line GLCD_WriteData(RA8835_TCR); //P5 TC/R: Total address range per line GLCD_WriteData(RA8835_LF); //P6 L/F: 239 display lines GLCD_WriteData(RA8835_APL); //P7 APL: Virtual screen horizontal size is 40 addresses GLCD_WriteData(RA8835_APH); //P8 APL: Virtual screen horizontal size is 40 addresses ////////////////////////////////// // SCROLL // ////////////////////////////////// GLCD_WriteCommand(RA8835_SCROLL); //Scrolling GLCD_WriteData(RA8835_SAD1L); //P1 First screen block start address set to 0x0000 GLCD_WriteData(RA8835_SAD1H); //P2 First screen block start address set to 0x0000 GLCD_WriteData(RA8835_SL1); //P3 Display lines in first screen block = 240 GLCD_WriteData(RA8835_SAD2L); //P4 Second screen block start address set to 0x1000 GLCD_WriteData(RA8835_SAD2H); //P5 Second screen block start address set to 0x1000 GLCD_WriteData(RA8835_SL2); //P6 Display lines in second screen block = 240 GLCD_WriteData(RA8835_SAD3L); //P7 Third screen block start address set to 0x0000 GLCD_WriteData(RA8835_SAD3H); //P8 Third screen block start address set to 0x0000 GLCD_WriteData(RA8835_SAD4L); //P9 Fourth screen block start address set to 0x0000 GLCD_WriteData(RA8835_SAD4H); //P10 Fourth screen block start address set to 0x0000 ////////////////////////////////// // HDOT SCR // ////////////////////////////////// GLCD_WriteCommand(RA8835_HDOT_SCR); // HDOT GLCD_WriteData(RA8835_SCRD); // 0 pixels scroll ////////////////////////////////// // OVERLAY // ////////////////////////////////// GLCD_WriteCommand(RA8835_OVLAY); // OVERLAY GLCD_WriteData(RA8835_OVLAY_P1); // MX 1, MX 0: Inverse video superposition // DM 1: First screen block is text mode // DM 2: Third screen block is text mode ////////////////////////////////// // DISPLAY OFF // ////////////////////////////////// GLCD_WriteCommand(RA8835_DISP_OFF); //Display off GLCD_WriteData(RA8835_FLASH); //FC1, FC0: Flash cursor at 2 Hz //FP1, FP0: First screen block ON //FP3, FP2: Second and fourth screen blocks ON //FP5, FP4: Third screen block ON ////////////////////////////////// // CSRW // ////////////////////////////////// GLCD_WriteCommand(RA8835_CSRW); GLCD_WriteData(RA8835_SAD1L); GLCD_WriteData(RA8835_SAD1H); ////////////////////////////////// // CSRFORM // ////////////////////////////////// GLCD_WriteCommand(RA8835_CSRFORM); //Cursor type CSRFORM GLCD_WriteData(RA8835_CRX); //Horizontal cursor size = 6 pixels GLCD_WriteData(RA8835_CRY); //Vertical cursor size = 9 pixels ////////////////////////////////// // DISPLAY ON // ////////////////////////////////// GLCD_WriteCommand(RA8835_DISP_ON); // Display on //GLCD_WriteData(RA8835_FLASH); //FC1, FC0: Flash cursor at 2 Hz //FP1, FP0: First screen block ON //FP3, FP2: Second and fourth screen blocks ON //FP5, FP4: Third screen block ON ////////////////////////////////// // CURSOR // ////////////////////////////////// GLCD_WriteCommand(RA8835_CSRDIR_D); // Set direction of cursor movement RIGHT ////////////////////////////////// // CG RAM // ////////////////////////////////// GLCD_WriteCommand(RA8835_CGRAM_ADR); GLCD_WriteData(RA8835_SAGL); GLCD_WriteData(RA8835_SAGH); }