Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SPLC501C.c
00001 #include "gfx1.h" 00002 #include "SPLC501C.h" 00003 #include "font5x7.h" 00004 #include "font10x16.h" 00005 00006 //------------------------------------------------------------------------------------------------- 00007 // 00008 //------------------------------------------------------------------------------------------------- 00009 void GLCD_Initialize(void) { 00010 gfx1_init(); 00011 00012 gfx1_command(SPLC501C_ADC_NORMAL); 00013 gfx1_command(SPLC501C_COM63); 00014 00015 gfx1_command(SPLC501C_BIAS_19); 00016 gfx1_command(SPLC501C_POWERON); 00017 //nop 00018 gfx1_command(SPLC501C_VOLUME_MODE); 00019 gfx1_command(SPLC501C_VOLUME_SET | 20); 00020 gfx1_command(0xA4); 00021 gfx1_command(SPLC501C_DISPLAY_ON); 00022 gfx1_command(SPLC501C_DISPLAY_NORMAL); 00023 gfx1_command(SPLC501C_PAGE_ADDRESS | 0); 00024 gfx1_command(SPLC501C_COLUMN_ADDRESS_HI | 0); 00025 gfx1_command(SPLC501C_COLUMN_ADDRESS_LO | 0); 00026 gfx1_command(SPLC501C_START_LINE | 0); 00027 gfx1_x=0;//emulation memoire ecran 00028 gfx1_y=0;//emulation memoire ecran 00029 } 00030 //------------------------------------------------------------------------------------------------- 00031 // 00032 //------------------------------------------------------------------------------------------------- 00033 void GLCD_GoTo(unsigned char x, unsigned char y) { 00034 gfx1_command(SPLC501C_COLUMN_ADDRESS_HI | (x >> 4)); 00035 gfx1_command(SPLC501C_COLUMN_ADDRESS_LO | (x & 0x0F)); 00036 gfx1_command(SPLC501C_PAGE_ADDRESS | y); 00037 gfx1_x=x;//emulation memoire ecran 00038 gfx1_y=y;//emulation memoire ecran 00039 } 00040 //------------------------------------------------------------------------------------------------- 00041 // 00042 //------------------------------------------------------------------------------------------------- 00043 void GLCD_ClearScreen(void) { 00044 unsigned char x = 0, y = 0; 00045 for (y = 0; y < (SCREEN_HEIGHT/PIXELS_PER_PAGE); y++) { 00046 GLCD_GoTo(0,y); 00047 for (x = 0; x < SCREEN_WIDTH; x++) { 00048 gfx1_data(0); 00049 } 00050 } 00051 } 00052 //------------------------------------------------------------------------------------------------- 00053 // Function : GLCD_WriteChar5x7 00054 // Artuments : Char ASCII code 00055 // Return value : none 00056 //------------------------------------------------------------------------------------------------- 00057 void GLCD_WriteChar5x7(char charCode) { 00058 char fontCollumn; 00059 00060 for (fontCollumn = 0; fontCollumn < FONT_WIDTH5x7; fontCollumn++) 00061 gfx1_data(font5x7[((charCode- FONT_OFFSET5x7) * FONT_WIDTH5x7) + fontCollumn]); 00062 gfx1_data(0); 00063 } 00064 //------------------------------------------------------------------------------------------------- 00065 // Function : GLCD_WriteChar10x16 00066 // Artuments : Char ASCII code 00067 // Return value : none 00068 //------------------------------------------------------------------------------------------------- 00069 void GLCD_WriteChar10x16(char charCode) { 00070 unsigned int fontCollumn; 00071 unsigned int x,y; 00072 00073 y=gfx1_y; 00074 x=gfx1_x; 00075 for (fontCollumn = 0; fontCollumn < FONT_WIDTH10x16; fontCollumn+=2) { 00076 GLCD_GoTo(x,y); 00077 gfx1_data(font10x16[((charCode- FONT_OFFSET10x16) * FONT_WIDTH10x16) + fontCollumn]); 00078 GLCD_GoTo(x,y+1); 00079 gfx1_data(font10x16[((charCode- FONT_OFFSET10x16) * FONT_WIDTH10x16) + fontCollumn + 1]); 00080 x++; 00081 } 00082 gfx1_data(0); 00083 GLCD_GoTo(x,y); 00084 } 00085 //------------------------------------------------------------------------------------------------- 00086 // Function : GLCD_WriteString10x16 00087 // Arguments : pointer to null-terminated ASCII string 00088 // Return value : none 00089 //------------------------------------------------------------------------------------------------- 00090 void GLCD_WriteString10x16(char * string) { 00091 while (*string) { 00092 GLCD_WriteChar10x16(*string++); 00093 } 00094 } 00095 //------------------------------------------------------------------------------------------------- 00096 // Function : GLCD_WriteString5x7 00097 // Arguments : pointer to null-terminated ASCII string 00098 // Return value : none 00099 //------------------------------------------------------------------------------------------------- 00100 void GLCD_WriteString5x7(char * string) { 00101 while (*string) { 00102 GLCD_WriteChar5x7(*string++); 00103 } 00104 } 00105 //------------------------------------------------------------------------------------------------- 00106 // Function : GLCD_SetPixel 00107 // Arguments : x-location, y-location, color (0 or 1) 00108 // Return value : None 00109 //------------------------------------------------------------------------------------------------- 00110 void GLCD_SetPixel(int x, int y, int color) { 00111 unsigned char temp = 0; 00112 if((x<SCREEN_WIDTH ) & (y<SCREEN_HEIGHT)) 00113 { 00114 GLCD_GoTo(x, (y/8)); 00115 temp = gfx1_read(); 00116 if (color) 00117 temp |= (1 << (y % 8)); 00118 else 00119 temp &= ~(1 << (y % 8)); 00120 GLCD_GoTo(x, (y/8)); 00121 gfx1_data(temp); 00122 } 00123 } 00124 //------------------------------------------------------------------------------------------------- 00125 // 00126 //------------------------------------------------------------------------------------------------- 00127 void GLCD_Bitmap(char * bitmap,unsigned char left, unsigned char top, unsigned char width, unsigned char height) { 00128 unsigned char pageIndex, columnIndex; 00129 for (pageIndex = 0; pageIndex < height / 8; pageIndex++) { 00130 GLCD_GoTo(left, top + pageIndex); 00131 for (columnIndex = 0; columnIndex < width; columnIndex++) 00132 gfx1_data(*(bitmap++)); 00133 } 00134 }
Generated on Wed Jul 27 2022 06:12:51 by
1.7.2