frederic blanc
/
sp5gfx1
Lascar Electronics SP 5-GFX1 DISPLAY, LCD GRAPHIC, 128 X 64 DOTS
SPLC501C.c@0:2052f61477b1, 2011-07-06 (annotated)
- Committer:
- fblanc
- Date:
- Wed Jul 06 12:06:40 2011 +0000
- Revision:
- 0:2052f61477b1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fblanc | 0:2052f61477b1 | 1 | #include "gfx1.h" |
fblanc | 0:2052f61477b1 | 2 | #include "SPLC501C.h" |
fblanc | 0:2052f61477b1 | 3 | #include "font5x7.h" |
fblanc | 0:2052f61477b1 | 4 | #include "font10x16.h" |
fblanc | 0:2052f61477b1 | 5 | |
fblanc | 0:2052f61477b1 | 6 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 7 | // |
fblanc | 0:2052f61477b1 | 8 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 9 | void GLCD_Initialize(void) { |
fblanc | 0:2052f61477b1 | 10 | gfx1_init(); |
fblanc | 0:2052f61477b1 | 11 | |
fblanc | 0:2052f61477b1 | 12 | gfx1_command(SPLC501C_ADC_NORMAL); |
fblanc | 0:2052f61477b1 | 13 | gfx1_command(SPLC501C_COM63); |
fblanc | 0:2052f61477b1 | 14 | |
fblanc | 0:2052f61477b1 | 15 | gfx1_command(SPLC501C_BIAS_19); |
fblanc | 0:2052f61477b1 | 16 | gfx1_command(SPLC501C_POWERON); |
fblanc | 0:2052f61477b1 | 17 | //nop |
fblanc | 0:2052f61477b1 | 18 | gfx1_command(SPLC501C_VOLUME_MODE); |
fblanc | 0:2052f61477b1 | 19 | gfx1_command(SPLC501C_VOLUME_SET | 20); |
fblanc | 0:2052f61477b1 | 20 | gfx1_command(0xA4); |
fblanc | 0:2052f61477b1 | 21 | gfx1_command(SPLC501C_DISPLAY_ON); |
fblanc | 0:2052f61477b1 | 22 | gfx1_command(SPLC501C_DISPLAY_NORMAL); |
fblanc | 0:2052f61477b1 | 23 | gfx1_command(SPLC501C_PAGE_ADDRESS | 0); |
fblanc | 0:2052f61477b1 | 24 | gfx1_command(SPLC501C_COLUMN_ADDRESS_HI | 0); |
fblanc | 0:2052f61477b1 | 25 | gfx1_command(SPLC501C_COLUMN_ADDRESS_LO | 0); |
fblanc | 0:2052f61477b1 | 26 | gfx1_command(SPLC501C_START_LINE | 0); |
fblanc | 0:2052f61477b1 | 27 | gfx1_x=0;//emulation memoire ecran |
fblanc | 0:2052f61477b1 | 28 | gfx1_y=0;//emulation memoire ecran |
fblanc | 0:2052f61477b1 | 29 | } |
fblanc | 0:2052f61477b1 | 30 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 31 | // |
fblanc | 0:2052f61477b1 | 32 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 33 | void GLCD_GoTo(unsigned char x, unsigned char y) { |
fblanc | 0:2052f61477b1 | 34 | gfx1_command(SPLC501C_COLUMN_ADDRESS_HI | (x >> 4)); |
fblanc | 0:2052f61477b1 | 35 | gfx1_command(SPLC501C_COLUMN_ADDRESS_LO | (x & 0x0F)); |
fblanc | 0:2052f61477b1 | 36 | gfx1_command(SPLC501C_PAGE_ADDRESS | y); |
fblanc | 0:2052f61477b1 | 37 | gfx1_x=x;//emulation memoire ecran |
fblanc | 0:2052f61477b1 | 38 | gfx1_y=y;//emulation memoire ecran |
fblanc | 0:2052f61477b1 | 39 | } |
fblanc | 0:2052f61477b1 | 40 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 41 | // |
fblanc | 0:2052f61477b1 | 42 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 43 | void GLCD_ClearScreen(void) { |
fblanc | 0:2052f61477b1 | 44 | unsigned char x = 0, y = 0; |
fblanc | 0:2052f61477b1 | 45 | for (y = 0; y < (SCREEN_HEIGHT/PIXELS_PER_PAGE); y++) { |
fblanc | 0:2052f61477b1 | 46 | GLCD_GoTo(0,y); |
fblanc | 0:2052f61477b1 | 47 | for (x = 0; x < SCREEN_WIDTH; x++) { |
fblanc | 0:2052f61477b1 | 48 | gfx1_data(0); |
fblanc | 0:2052f61477b1 | 49 | } |
fblanc | 0:2052f61477b1 | 50 | } |
fblanc | 0:2052f61477b1 | 51 | } |
fblanc | 0:2052f61477b1 | 52 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 53 | // Function : GLCD_WriteChar5x7 |
fblanc | 0:2052f61477b1 | 54 | // Artuments : Char ASCII code |
fblanc | 0:2052f61477b1 | 55 | // Return value : none |
fblanc | 0:2052f61477b1 | 56 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 57 | void GLCD_WriteChar5x7(char charCode) { |
fblanc | 0:2052f61477b1 | 58 | char fontCollumn; |
fblanc | 0:2052f61477b1 | 59 | |
fblanc | 0:2052f61477b1 | 60 | for (fontCollumn = 0; fontCollumn < FONT_WIDTH5x7; fontCollumn++) |
fblanc | 0:2052f61477b1 | 61 | gfx1_data(font5x7[((charCode- FONT_OFFSET5x7) * FONT_WIDTH5x7) + fontCollumn]); |
fblanc | 0:2052f61477b1 | 62 | gfx1_data(0); |
fblanc | 0:2052f61477b1 | 63 | } |
fblanc | 0:2052f61477b1 | 64 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 65 | // Function : GLCD_WriteChar10x16 |
fblanc | 0:2052f61477b1 | 66 | // Artuments : Char ASCII code |
fblanc | 0:2052f61477b1 | 67 | // Return value : none |
fblanc | 0:2052f61477b1 | 68 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 69 | void GLCD_WriteChar10x16(char charCode) { |
fblanc | 0:2052f61477b1 | 70 | unsigned int fontCollumn; |
fblanc | 0:2052f61477b1 | 71 | unsigned int x,y; |
fblanc | 0:2052f61477b1 | 72 | |
fblanc | 0:2052f61477b1 | 73 | y=gfx1_y; |
fblanc | 0:2052f61477b1 | 74 | x=gfx1_x; |
fblanc | 0:2052f61477b1 | 75 | for (fontCollumn = 0; fontCollumn < FONT_WIDTH10x16; fontCollumn+=2) { |
fblanc | 0:2052f61477b1 | 76 | GLCD_GoTo(x,y); |
fblanc | 0:2052f61477b1 | 77 | gfx1_data(font10x16[((charCode- FONT_OFFSET10x16) * FONT_WIDTH10x16) + fontCollumn]); |
fblanc | 0:2052f61477b1 | 78 | GLCD_GoTo(x,y+1); |
fblanc | 0:2052f61477b1 | 79 | gfx1_data(font10x16[((charCode- FONT_OFFSET10x16) * FONT_WIDTH10x16) + fontCollumn + 1]); |
fblanc | 0:2052f61477b1 | 80 | x++; |
fblanc | 0:2052f61477b1 | 81 | } |
fblanc | 0:2052f61477b1 | 82 | gfx1_data(0); |
fblanc | 0:2052f61477b1 | 83 | GLCD_GoTo(x,y); |
fblanc | 0:2052f61477b1 | 84 | } |
fblanc | 0:2052f61477b1 | 85 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 86 | // Function : GLCD_WriteString10x16 |
fblanc | 0:2052f61477b1 | 87 | // Arguments : pointer to null-terminated ASCII string |
fblanc | 0:2052f61477b1 | 88 | // Return value : none |
fblanc | 0:2052f61477b1 | 89 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 90 | void GLCD_WriteString10x16(char * string) { |
fblanc | 0:2052f61477b1 | 91 | while (*string) { |
fblanc | 0:2052f61477b1 | 92 | GLCD_WriteChar10x16(*string++); |
fblanc | 0:2052f61477b1 | 93 | } |
fblanc | 0:2052f61477b1 | 94 | } |
fblanc | 0:2052f61477b1 | 95 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 96 | // Function : GLCD_WriteString5x7 |
fblanc | 0:2052f61477b1 | 97 | // Arguments : pointer to null-terminated ASCII string |
fblanc | 0:2052f61477b1 | 98 | // Return value : none |
fblanc | 0:2052f61477b1 | 99 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 100 | void GLCD_WriteString5x7(char * string) { |
fblanc | 0:2052f61477b1 | 101 | while (*string) { |
fblanc | 0:2052f61477b1 | 102 | GLCD_WriteChar5x7(*string++); |
fblanc | 0:2052f61477b1 | 103 | } |
fblanc | 0:2052f61477b1 | 104 | } |
fblanc | 0:2052f61477b1 | 105 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 106 | // Function : GLCD_SetPixel |
fblanc | 0:2052f61477b1 | 107 | // Arguments : x-location, y-location, color (0 or 1) |
fblanc | 0:2052f61477b1 | 108 | // Return value : None |
fblanc | 0:2052f61477b1 | 109 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 110 | void GLCD_SetPixel(int x, int y, int color) { |
fblanc | 0:2052f61477b1 | 111 | unsigned char temp = 0; |
fblanc | 0:2052f61477b1 | 112 | if((x<SCREEN_WIDTH ) & (y<SCREEN_HEIGHT)) |
fblanc | 0:2052f61477b1 | 113 | { |
fblanc | 0:2052f61477b1 | 114 | GLCD_GoTo(x, (y/8)); |
fblanc | 0:2052f61477b1 | 115 | temp = gfx1_read(); |
fblanc | 0:2052f61477b1 | 116 | if (color) |
fblanc | 0:2052f61477b1 | 117 | temp |= (1 << (y % 8)); |
fblanc | 0:2052f61477b1 | 118 | else |
fblanc | 0:2052f61477b1 | 119 | temp &= ~(1 << (y % 8)); |
fblanc | 0:2052f61477b1 | 120 | GLCD_GoTo(x, (y/8)); |
fblanc | 0:2052f61477b1 | 121 | gfx1_data(temp); |
fblanc | 0:2052f61477b1 | 122 | } |
fblanc | 0:2052f61477b1 | 123 | } |
fblanc | 0:2052f61477b1 | 124 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 125 | // |
fblanc | 0:2052f61477b1 | 126 | //------------------------------------------------------------------------------------------------- |
fblanc | 0:2052f61477b1 | 127 | void GLCD_Bitmap(char * bitmap,unsigned char left, unsigned char top, unsigned char width, unsigned char height) { |
fblanc | 0:2052f61477b1 | 128 | unsigned char pageIndex, columnIndex; |
fblanc | 0:2052f61477b1 | 129 | for (pageIndex = 0; pageIndex < height / 8; pageIndex++) { |
fblanc | 0:2052f61477b1 | 130 | GLCD_GoTo(left, top + pageIndex); |
fblanc | 0:2052f61477b1 | 131 | for (columnIndex = 0; columnIndex < width; columnIndex++) |
fblanc | 0:2052f61477b1 | 132 | gfx1_data(*(bitmap++)); |
fblanc | 0:2052f61477b1 | 133 | } |
fblanc | 0:2052f61477b1 | 134 | } |