oled
I2C_SSD1306Z.cpp@0:847d62ecf52e, 2017-08-27 (annotated)
- Committer:
- mijimy
- Date:
- Sun Aug 27 06:12:47 2017 +0000
- Revision:
- 0:847d62ecf52e
oled;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mijimy | 0:847d62ecf52e | 1 | // |
mijimy | 0:847d62ecf52e | 2 | // SSD1306Z LCD Driver: 0.96" lcd LY096BG30 |
mijimy | 0:847d62ecf52e | 3 | // |
mijimy | 0:847d62ecf52e | 4 | // Interface: I2C |
mijimy | 0:847d62ecf52e | 5 | // pin1: Vcc |
mijimy | 0:847d62ecf52e | 6 | // pin2: Gnd |
mijimy | 0:847d62ecf52e | 7 | // pin3: SCL |
mijimy | 0:847d62ecf52e | 8 | // pin4: SDA |
mijimy | 0:847d62ecf52e | 9 | |
mijimy | 0:847d62ecf52e | 10 | #include "mbed.h" |
mijimy | 0:847d62ecf52e | 11 | #include "I2C_SSD1306Z.h" |
mijimy | 0:847d62ecf52e | 12 | #include "Font8x16.h" |
mijimy | 0:847d62ecf52e | 13 | #include "Font5x7.h" |
mijimy | 0:847d62ecf52e | 14 | |
mijimy | 0:847d62ecf52e | 15 | |
mijimy | 0:847d62ecf52e | 16 | //I2C i2c(I2C_SDA, I2C_SCL); |
mijimy | 0:847d62ecf52e | 17 | extern I2C i2c; |
mijimy | 0:847d62ecf52e | 18 | |
mijimy | 0:847d62ecf52e | 19 | char DisplayBuffer[128*8]; |
mijimy | 0:847d62ecf52e | 20 | |
mijimy | 0:847d62ecf52e | 21 | #if 1 |
mijimy | 0:847d62ecf52e | 22 | |
mijimy | 0:847d62ecf52e | 23 | void lcdWriteCommand(uint8_t lcd_Command) |
mijimy | 0:847d62ecf52e | 24 | { |
mijimy | 0:847d62ecf52e | 25 | |
mijimy | 0:847d62ecf52e | 26 | char data[2]; |
mijimy | 0:847d62ecf52e | 27 | data[0]=0x0; |
mijimy | 0:847d62ecf52e | 28 | data[1]=lcd_Command; |
mijimy | 0:847d62ecf52e | 29 | // I2C_writeBytes(LCD_I2C_PORT, LCD_I2C_SLA, 0x00, 1, data); |
mijimy | 0:847d62ecf52e | 30 | // i2c_write_data_block(LCD_I2C_SLA, 0x00, data,1); |
mijimy | 0:847d62ecf52e | 31 | i2c.write(LCD_I2C_SLA, data, 2, 0); |
mijimy | 0:847d62ecf52e | 32 | |
mijimy | 0:847d62ecf52e | 33 | } |
mijimy | 0:847d62ecf52e | 34 | |
mijimy | 0:847d62ecf52e | 35 | void lcdWriteData(uint8_t lcd_Data) |
mijimy | 0:847d62ecf52e | 36 | { |
mijimy | 0:847d62ecf52e | 37 | |
mijimy | 0:847d62ecf52e | 38 | char data[2]; |
mijimy | 0:847d62ecf52e | 39 | data[0]=0x40; |
mijimy | 0:847d62ecf52e | 40 | data[1]=lcd_Data; |
mijimy | 0:847d62ecf52e | 41 | // I2C_writeBytes(LCD_I2C_PORT, LCD_I2C_SLA, 0x40, 1, data); |
mijimy | 0:847d62ecf52e | 42 | //i2c_write_data_block(LCD_I2C_SLA, 0x40,data,1); |
mijimy | 0:847d62ecf52e | 43 | i2c.write(LCD_I2C_SLA, data, 2, 0); |
mijimy | 0:847d62ecf52e | 44 | } |
mijimy | 0:847d62ecf52e | 45 | |
mijimy | 0:847d62ecf52e | 46 | #else |
mijimy | 0:847d62ecf52e | 47 | |
mijimy | 0:847d62ecf52e | 48 | void lcdWriteCommand(uint8_t lcd_Command) |
mijimy | 0:847d62ecf52e | 49 | { |
mijimy | 0:847d62ecf52e | 50 | uint8_t data[1]; |
mijimy | 0:847d62ecf52e | 51 | data[0]=lcd_Command; |
mijimy | 0:847d62ecf52e | 52 | // I2C_writeBytes(LCD_I2C_PORT, LCD_I2C_SLA, 0x00, 1, data); |
mijimy | 0:847d62ecf52e | 53 | i2c_write_data_block(LCD_I2C_SLA, 0x00, data,1); |
mijimy | 0:847d62ecf52e | 54 | |
mijimy | 0:847d62ecf52e | 55 | } |
mijimy | 0:847d62ecf52e | 56 | |
mijimy | 0:847d62ecf52e | 57 | void lcdWriteData(uint8_t lcd_Data) |
mijimy | 0:847d62ecf52e | 58 | { |
mijimy | 0:847d62ecf52e | 59 | uint8_t data[1]; |
mijimy | 0:847d62ecf52e | 60 | data[0]=lcd_Data; |
mijimy | 0:847d62ecf52e | 61 | // I2C_writeBytes(LCD_I2C_PORT, LCD_I2C_SLA, 0x40, 1, data); |
mijimy | 0:847d62ecf52e | 62 | i2c_write_data_block(LCD_I2C_SLA, 0x40,data,1); |
mijimy | 0:847d62ecf52e | 63 | } |
mijimy | 0:847d62ecf52e | 64 | |
mijimy | 0:847d62ecf52e | 65 | #endif |
mijimy | 0:847d62ecf52e | 66 | |
mijimy | 0:847d62ecf52e | 67 | void lcdSetAddr(uint8_t column, uint8_t page) |
mijimy | 0:847d62ecf52e | 68 | { column+=2; |
mijimy | 0:847d62ecf52e | 69 | lcdWriteCommand(0xb0+page); // set page address |
mijimy | 0:847d62ecf52e | 70 | lcdWriteCommand(0x10 | ((column & 0xf0) >> 4)); // set column address MSB |
mijimy | 0:847d62ecf52e | 71 | lcdWriteCommand(0x00 | (column & 0x0f) ); // set column address LSB |
mijimy | 0:847d62ecf52e | 72 | } |
mijimy | 0:847d62ecf52e | 73 | |
mijimy | 0:847d62ecf52e | 74 | void Init_LCD(void) |
mijimy | 0:847d62ecf52e | 75 | { |
mijimy | 0:847d62ecf52e | 76 | lcdWriteCommand(0xae); //display off |
mijimy | 0:847d62ecf52e | 77 | lcdWriteCommand(0x20); //Set Memory Addressing Mode |
mijimy | 0:847d62ecf52e | 78 | lcdWriteCommand(0x10); //00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid |
mijimy | 0:847d62ecf52e | 79 | lcdWriteCommand(0xb0); //Set Page Start Address for Page Addressing Mode,0-7 |
mijimy | 0:847d62ecf52e | 80 | lcdWriteCommand(0xc8); //Set COM Output Scan Direction |
mijimy | 0:847d62ecf52e | 81 | lcdWriteCommand(0x04);//---set low column address |
mijimy | 0:847d62ecf52e | 82 | lcdWriteCommand(0x14);//---set high column address |
mijimy | 0:847d62ecf52e | 83 | lcdWriteCommand(0x40);//--set start line address |
mijimy | 0:847d62ecf52e | 84 | lcdWriteCommand(0x81);//--set contrast control register |
mijimy | 0:847d62ecf52e | 85 | lcdWriteCommand(0x7f); |
mijimy | 0:847d62ecf52e | 86 | lcdWriteCommand(0xa1);//--set segment re-map 0 to 127 |
mijimy | 0:847d62ecf52e | 87 | lcdWriteCommand(0xa6);//--set normal display |
mijimy | 0:847d62ecf52e | 88 | lcdWriteCommand(0xa8);//--set multiplex ratio(1 to 64) |
mijimy | 0:847d62ecf52e | 89 | lcdWriteCommand(0x3F);// |
mijimy | 0:847d62ecf52e | 90 | lcdWriteCommand(0xa4);//0xa4,Output follows RAM content;0xa5,Output ignores RAM content |
mijimy | 0:847d62ecf52e | 91 | lcdWriteCommand(0xd3);//-set display offset |
mijimy | 0:847d62ecf52e | 92 | lcdWriteCommand(0x00);//-not offset |
mijimy | 0:847d62ecf52e | 93 | lcdWriteCommand(0xd5);//--set display clock divide ratio/oscillator frequency |
mijimy | 0:847d62ecf52e | 94 | lcdWriteCommand(0xf0);//--set divide ratio |
mijimy | 0:847d62ecf52e | 95 | lcdWriteCommand(0xd9);//--set pre-charge period |
mijimy | 0:847d62ecf52e | 96 | lcdWriteCommand(0x22); // |
mijimy | 0:847d62ecf52e | 97 | lcdWriteCommand(0xda);//--set com pins hardware configuration |
mijimy | 0:847d62ecf52e | 98 | lcdWriteCommand(0x12); |
mijimy | 0:847d62ecf52e | 99 | lcdWriteCommand(0xdb);//--set vcomh |
mijimy | 0:847d62ecf52e | 100 | lcdWriteCommand(0x20);//0x20,0.77xVcc |
mijimy | 0:847d62ecf52e | 101 | lcdWriteCommand(0x8d);//--set DC-DC enable |
mijimy | 0:847d62ecf52e | 102 | lcdWriteCommand(0x14);// |
mijimy | 0:847d62ecf52e | 103 | lcdWriteCommand(0xaf);//--turn on lcd panel |
mijimy | 0:847d62ecf52e | 104 | } |
mijimy | 0:847d62ecf52e | 105 | |
mijimy | 0:847d62ecf52e | 106 | void clear_LCD(void) |
mijimy | 0:847d62ecf52e | 107 | { |
mijimy | 0:847d62ecf52e | 108 | int16_t x, Y; |
mijimy | 0:847d62ecf52e | 109 | for (Y=0;Y<LCD_Ymax/8;Y++) |
mijimy | 0:847d62ecf52e | 110 | { |
mijimy | 0:847d62ecf52e | 111 | lcdSetAddr(0, Y); |
mijimy | 0:847d62ecf52e | 112 | for (x=0;x<LCD_Xmax;x++) |
mijimy | 0:847d62ecf52e | 113 | lcdWriteData(0x00); |
mijimy | 0:847d62ecf52e | 114 | } |
mijimy | 0:847d62ecf52e | 115 | } |
mijimy | 0:847d62ecf52e | 116 | |
mijimy | 0:847d62ecf52e | 117 | // print char function using Font5x7 |
mijimy | 0:847d62ecf52e | 118 | void printC_5x7 (int16_t x, int16_t y, unsigned char ascii_code) |
mijimy | 0:847d62ecf52e | 119 | { |
mijimy | 0:847d62ecf52e | 120 | uint8_t i; |
mijimy | 0:847d62ecf52e | 121 | if (x<(LCD_Xmax-5) && y<(LCD_Ymax-7)) { |
mijimy | 0:847d62ecf52e | 122 | if (ascii_code<0x20) ascii_code=0x20; |
mijimy | 0:847d62ecf52e | 123 | else if (ascii_code>0x7F) ascii_code=0x20; |
mijimy | 0:847d62ecf52e | 124 | for (i=0;i<5;i++) { |
mijimy | 0:847d62ecf52e | 125 | lcdSetAddr((LCD_Xmax+1-x-i), (y/8)); |
mijimy | 0:847d62ecf52e | 126 | lcdWriteData(Font5x7[(ascii_code-0x20)*5+5-i]); |
mijimy | 0:847d62ecf52e | 127 | } |
mijimy | 0:847d62ecf52e | 128 | } |
mijimy | 0:847d62ecf52e | 129 | } |
mijimy | 0:847d62ecf52e | 130 | |
mijimy | 0:847d62ecf52e | 131 | void print_C(uint8_t Line, uint8_t Col, char ascii) |
mijimy | 0:847d62ecf52e | 132 | { |
mijimy | 0:847d62ecf52e | 133 | uint8_t j, i, tmp; |
mijimy | 0:847d62ecf52e | 134 | for (j=0;j<2;j++) { |
mijimy | 0:847d62ecf52e | 135 | lcdSetAddr(Col*8, Line*2+j); |
mijimy | 0:847d62ecf52e | 136 | for (i=0;i<8;i++) { |
mijimy | 0:847d62ecf52e | 137 | tmp=Font8x16[(ascii-0x20)*16+j*8+i]; |
mijimy | 0:847d62ecf52e | 138 | lcdWriteData(tmp); |
mijimy | 0:847d62ecf52e | 139 | } |
mijimy | 0:847d62ecf52e | 140 | } |
mijimy | 0:847d62ecf52e | 141 | } |
mijimy | 0:847d62ecf52e | 142 | |
mijimy | 0:847d62ecf52e | 143 | void print_Line(uint8_t line, char text[]) |
mijimy | 0:847d62ecf52e | 144 | { |
mijimy | 0:847d62ecf52e | 145 | uint8_t Col; |
mijimy | 0:847d62ecf52e | 146 | for (Col=0; Col<strlen(text); Col++) |
mijimy | 0:847d62ecf52e | 147 | print_C(line, Col, text[Col]); |
mijimy | 0:847d62ecf52e | 148 | } |
mijimy | 0:847d62ecf52e | 149 | |
mijimy | 0:847d62ecf52e | 150 | void printS(int16_t x, int16_t y, char text[]) |
mijimy | 0:847d62ecf52e | 151 | { |
mijimy | 0:847d62ecf52e | 152 | int8_t i; |
mijimy | 0:847d62ecf52e | 153 | for (i=0;i<strlen(text);i++) |
mijimy | 0:847d62ecf52e | 154 | print_C(x+i*8, y,text[i]); |
mijimy | 0:847d62ecf52e | 155 | } |
mijimy | 0:847d62ecf52e | 156 | |
mijimy | 0:847d62ecf52e | 157 | void printS_5x7(int16_t x, int16_t y, char text[]) |
mijimy | 0:847d62ecf52e | 158 | { |
mijimy | 0:847d62ecf52e | 159 | uint8_t i; |
mijimy | 0:847d62ecf52e | 160 | for (i=0;i<strlen(text);i++) { |
mijimy | 0:847d62ecf52e | 161 | printC_5x7(x,y,text[i]); |
mijimy | 0:847d62ecf52e | 162 | x=x+5; |
mijimy | 0:847d62ecf52e | 163 | } |
mijimy | 0:847d62ecf52e | 164 | } |
mijimy | 0:847d62ecf52e | 165 | |
mijimy | 0:847d62ecf52e | 166 | void draw_Pixel(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor) |
mijimy | 0:847d62ecf52e | 167 | { |
mijimy | 0:847d62ecf52e | 168 | if (fgColor!=0) |
mijimy | 0:847d62ecf52e | 169 | DisplayBuffer[x+y/8*LCD_Xmax] |= (0x01<<(y%8)); |
mijimy | 0:847d62ecf52e | 170 | else |
mijimy | 0:847d62ecf52e | 171 | DisplayBuffer[x+y/8*LCD_Xmax] &= (0xFE<<(y%8)); |
mijimy | 0:847d62ecf52e | 172 | |
mijimy | 0:847d62ecf52e | 173 | lcdSetAddr(x, y/8); |
mijimy | 0:847d62ecf52e | 174 | lcdWriteData(DisplayBuffer[x+y/8*LCD_Xmax]); |
mijimy | 0:847d62ecf52e | 175 | } |
mijimy | 0:847d62ecf52e | 176 | |
mijimy | 0:847d62ecf52e | 177 | void draw_Bmp8x8(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) |
mijimy | 0:847d62ecf52e | 178 | { |
mijimy | 0:847d62ecf52e | 179 | uint8_t t,i,k, kx,ky; |
mijimy | 0:847d62ecf52e | 180 | if (x<(LCD_Xmax-7) && y<(LCD_Ymax-7)) // boundary check |
mijimy | 0:847d62ecf52e | 181 | for (i=0;i<8;i++){ |
mijimy | 0:847d62ecf52e | 182 | kx=x+i; |
mijimy | 0:847d62ecf52e | 183 | t=bitmap[i]; |
mijimy | 0:847d62ecf52e | 184 | for (k=0;k<8;k++) { |
mijimy | 0:847d62ecf52e | 185 | ky=y+k; |
mijimy | 0:847d62ecf52e | 186 | if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); |
mijimy | 0:847d62ecf52e | 187 | } |
mijimy | 0:847d62ecf52e | 188 | } |
mijimy | 0:847d62ecf52e | 189 | } |
mijimy | 0:847d62ecf52e | 190 | |
mijimy | 0:847d62ecf52e | 191 | void draw_Bmp32x8(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) |
mijimy | 0:847d62ecf52e | 192 | { |
mijimy | 0:847d62ecf52e | 193 | uint8_t t,i,k, kx,ky; |
mijimy | 0:847d62ecf52e | 194 | if (x<(LCD_Xmax-7) && y<(LCD_Ymax-7)) // boundary check |
mijimy | 0:847d62ecf52e | 195 | for (i=0;i<32;i++){ |
mijimy | 0:847d62ecf52e | 196 | kx=x+i; |
mijimy | 0:847d62ecf52e | 197 | t=bitmap[i]; |
mijimy | 0:847d62ecf52e | 198 | for (k=0;k<8;k++) { |
mijimy | 0:847d62ecf52e | 199 | ky=y+k; |
mijimy | 0:847d62ecf52e | 200 | if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); |
mijimy | 0:847d62ecf52e | 201 | } |
mijimy | 0:847d62ecf52e | 202 | } |
mijimy | 0:847d62ecf52e | 203 | } |
mijimy | 0:847d62ecf52e | 204 | |
mijimy | 0:847d62ecf52e | 205 | void draw_Bmp120x8(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) |
mijimy | 0:847d62ecf52e | 206 | { |
mijimy | 0:847d62ecf52e | 207 | uint8_t t,i,k, kx,ky; |
mijimy | 0:847d62ecf52e | 208 | if (x<(LCD_Xmax-7) && y<(LCD_Ymax-7)) // boundary check |
mijimy | 0:847d62ecf52e | 209 | for (i=0;i<120;i++){ |
mijimy | 0:847d62ecf52e | 210 | kx=x+i; |
mijimy | 0:847d62ecf52e | 211 | t=bitmap[i]; |
mijimy | 0:847d62ecf52e | 212 | for (k=0;k<8;k++) { |
mijimy | 0:847d62ecf52e | 213 | ky=y+k; |
mijimy | 0:847d62ecf52e | 214 | if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); |
mijimy | 0:847d62ecf52e | 215 | } |
mijimy | 0:847d62ecf52e | 216 | } |
mijimy | 0:847d62ecf52e | 217 | } |
mijimy | 0:847d62ecf52e | 218 | |
mijimy | 0:847d62ecf52e | 219 | void draw_Bmp8x16(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) |
mijimy | 0:847d62ecf52e | 220 | { |
mijimy | 0:847d62ecf52e | 221 | uint8_t t,i,k, kx,ky; |
mijimy | 0:847d62ecf52e | 222 | if (x<(LCD_Xmax-7) && y<(LCD_Ymax-7)) // boundary check |
mijimy | 0:847d62ecf52e | 223 | for (i=0;i<8;i++){ |
mijimy | 0:847d62ecf52e | 224 | kx=x+i; |
mijimy | 0:847d62ecf52e | 225 | t=bitmap[i]; |
mijimy | 0:847d62ecf52e | 226 | for (k=0;k<8;k++) { |
mijimy | 0:847d62ecf52e | 227 | ky=y+k; |
mijimy | 0:847d62ecf52e | 228 | if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); |
mijimy | 0:847d62ecf52e | 229 | } |
mijimy | 0:847d62ecf52e | 230 | t=bitmap[i+8]; |
mijimy | 0:847d62ecf52e | 231 | for (k=0;k<8;k++) { |
mijimy | 0:847d62ecf52e | 232 | ky=y+k+8; |
mijimy | 0:847d62ecf52e | 233 | if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); |
mijimy | 0:847d62ecf52e | 234 | } |
mijimy | 0:847d62ecf52e | 235 | } |
mijimy | 0:847d62ecf52e | 236 | } |
mijimy | 0:847d62ecf52e | 237 | |
mijimy | 0:847d62ecf52e | 238 | void draw_Bmp16x8(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) |
mijimy | 0:847d62ecf52e | 239 | { |
mijimy | 0:847d62ecf52e | 240 | uint8_t t,i,k,kx,ky; |
mijimy | 0:847d62ecf52e | 241 | if (x<(LCD_Xmax-15) && y<(LCD_Ymax-7)) // boundary check |
mijimy | 0:847d62ecf52e | 242 | for (i=0;i<16;i++) |
mijimy | 0:847d62ecf52e | 243 | { |
mijimy | 0:847d62ecf52e | 244 | kx=x+i; |
mijimy | 0:847d62ecf52e | 245 | t=bitmap[i]; |
mijimy | 0:847d62ecf52e | 246 | for (k=0;k<8;k++) { |
mijimy | 0:847d62ecf52e | 247 | ky=y+k; |
mijimy | 0:847d62ecf52e | 248 | if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); |
mijimy | 0:847d62ecf52e | 249 | } |
mijimy | 0:847d62ecf52e | 250 | } |
mijimy | 0:847d62ecf52e | 251 | } |
mijimy | 0:847d62ecf52e | 252 | |
mijimy | 0:847d62ecf52e | 253 | void draw_Bmp16x16(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) |
mijimy | 0:847d62ecf52e | 254 | { |
mijimy | 0:847d62ecf52e | 255 | uint8_t t,i,j,k, kx,ky; |
mijimy | 0:847d62ecf52e | 256 | if (x<(LCD_Xmax-15) && y<(LCD_Ymax-15)) // boundary check |
mijimy | 0:847d62ecf52e | 257 | for (j=0;j<2; j++){ |
mijimy | 0:847d62ecf52e | 258 | for (i=0;i<16;i++) { |
mijimy | 0:847d62ecf52e | 259 | kx=x+i; |
mijimy | 0:847d62ecf52e | 260 | t=bitmap[i+j*16]; |
mijimy | 0:847d62ecf52e | 261 | for (k=0;k<8;k++) { |
mijimy | 0:847d62ecf52e | 262 | ky=y+j*8+k; |
mijimy | 0:847d62ecf52e | 263 | if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); |
mijimy | 0:847d62ecf52e | 264 | } |
mijimy | 0:847d62ecf52e | 265 | } |
mijimy | 0:847d62ecf52e | 266 | } |
mijimy | 0:847d62ecf52e | 267 | } |
mijimy | 0:847d62ecf52e | 268 | |
mijimy | 0:847d62ecf52e | 269 | void draw_Bmp16x24(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) |
mijimy | 0:847d62ecf52e | 270 | { |
mijimy | 0:847d62ecf52e | 271 | uint8_t t,i,j,k, kx,ky; |
mijimy | 0:847d62ecf52e | 272 | if (x<(LCD_Xmax-15) && y<(LCD_Ymax-15)) // boundary check |
mijimy | 0:847d62ecf52e | 273 | for (j=0;j<3; j++){ |
mijimy | 0:847d62ecf52e | 274 | for (i=0;i<16;i++) { |
mijimy | 0:847d62ecf52e | 275 | kx=x+i; |
mijimy | 0:847d62ecf52e | 276 | t=bitmap[i+j*16]; |
mijimy | 0:847d62ecf52e | 277 | for (k=0;k<8;k++) { |
mijimy | 0:847d62ecf52e | 278 | ky=y+j*8+k; |
mijimy | 0:847d62ecf52e | 279 | if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); |
mijimy | 0:847d62ecf52e | 280 | } |
mijimy | 0:847d62ecf52e | 281 | } |
mijimy | 0:847d62ecf52e | 282 | } |
mijimy | 0:847d62ecf52e | 283 | } |
mijimy | 0:847d62ecf52e | 284 | |
mijimy | 0:847d62ecf52e | 285 | void draw_Bmp16x32(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) |
mijimy | 0:847d62ecf52e | 286 | { |
mijimy | 0:847d62ecf52e | 287 | uint8_t t, i,j,k, kx,ky; |
mijimy | 0:847d62ecf52e | 288 | if (x<(LCD_Xmax-15) && y<(LCD_Ymax-31)) // boundary check |
mijimy | 0:847d62ecf52e | 289 | for (j=0;j<4; j++) { |
mijimy | 0:847d62ecf52e | 290 | for (i=0;i<16;i++) { |
mijimy | 0:847d62ecf52e | 291 | kx=x+i; |
mijimy | 0:847d62ecf52e | 292 | t=bitmap[i+j*16]; |
mijimy | 0:847d62ecf52e | 293 | for (k=0;k<8;k++) { |
mijimy | 0:847d62ecf52e | 294 | ky=y+j*8+k; |
mijimy | 0:847d62ecf52e | 295 | if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); |
mijimy | 0:847d62ecf52e | 296 | } |
mijimy | 0:847d62ecf52e | 297 | } |
mijimy | 0:847d62ecf52e | 298 | } |
mijimy | 0:847d62ecf52e | 299 | } |
mijimy | 0:847d62ecf52e | 300 | |
mijimy | 0:847d62ecf52e | 301 | void draw_Bmp16x40(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) |
mijimy | 0:847d62ecf52e | 302 | { |
mijimy | 0:847d62ecf52e | 303 | uint8_t t, i,j,k, kx,ky; |
mijimy | 0:847d62ecf52e | 304 | if (x<(LCD_Xmax-15) && y<(LCD_Ymax-31)) // boundary check |
mijimy | 0:847d62ecf52e | 305 | for (j=0;j<5; j++) { |
mijimy | 0:847d62ecf52e | 306 | for (i=0;i<16;i++) { |
mijimy | 0:847d62ecf52e | 307 | kx=x+i; |
mijimy | 0:847d62ecf52e | 308 | t=bitmap[i+j*16]; |
mijimy | 0:847d62ecf52e | 309 | for (k=0;k<8;k++) { |
mijimy | 0:847d62ecf52e | 310 | ky=y+j*8+k; |
mijimy | 0:847d62ecf52e | 311 | if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); |
mijimy | 0:847d62ecf52e | 312 | } |
mijimy | 0:847d62ecf52e | 313 | } |
mijimy | 0:847d62ecf52e | 314 | } |
mijimy | 0:847d62ecf52e | 315 | } |
mijimy | 0:847d62ecf52e | 316 | |
mijimy | 0:847d62ecf52e | 317 | void draw_Bmp16x48(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) |
mijimy | 0:847d62ecf52e | 318 | { |
mijimy | 0:847d62ecf52e | 319 | uint8_t t,i,j,k,kx,ky; |
mijimy | 0:847d62ecf52e | 320 | if (x<(LCD_Xmax-15) && y<(LCD_Ymax-47)) // boundary check |
mijimy | 0:847d62ecf52e | 321 | for (j=0;j<6; j++) { |
mijimy | 0:847d62ecf52e | 322 | k=x; |
mijimy | 0:847d62ecf52e | 323 | for (i=0;i<16;i++) { |
mijimy | 0:847d62ecf52e | 324 | kx=x+i; |
mijimy | 0:847d62ecf52e | 325 | t=bitmap[i+j*16]; |
mijimy | 0:847d62ecf52e | 326 | for (k=0;k<8;k++) { |
mijimy | 0:847d62ecf52e | 327 | ky=y+j*8+k; |
mijimy | 0:847d62ecf52e | 328 | if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); |
mijimy | 0:847d62ecf52e | 329 | } |
mijimy | 0:847d62ecf52e | 330 | } |
mijimy | 0:847d62ecf52e | 331 | } |
mijimy | 0:847d62ecf52e | 332 | } |
mijimy | 0:847d62ecf52e | 333 | |
mijimy | 0:847d62ecf52e | 334 | void draw_Bmp16x64(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) |
mijimy | 0:847d62ecf52e | 335 | { |
mijimy | 0:847d62ecf52e | 336 | uint8_t t,i,j,k,kx,ky; |
mijimy | 0:847d62ecf52e | 337 | if (x<(LCD_Xmax-15) && y==0) // boundary check |
mijimy | 0:847d62ecf52e | 338 | for (j=0;j<8; j++) { |
mijimy | 0:847d62ecf52e | 339 | k=x; |
mijimy | 0:847d62ecf52e | 340 | for (i=0;i<16;i++) { |
mijimy | 0:847d62ecf52e | 341 | kx=x+i; |
mijimy | 0:847d62ecf52e | 342 | t=bitmap[i+j*16]; |
mijimy | 0:847d62ecf52e | 343 | for (k=0;k<8;k++) { |
mijimy | 0:847d62ecf52e | 344 | ky=y+j*8+k; |
mijimy | 0:847d62ecf52e | 345 | if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); |
mijimy | 0:847d62ecf52e | 346 | } |
mijimy | 0:847d62ecf52e | 347 | } |
mijimy | 0:847d62ecf52e | 348 | } |
mijimy | 0:847d62ecf52e | 349 | } |
mijimy | 0:847d62ecf52e | 350 | |
mijimy | 0:847d62ecf52e | 351 | void draw_Bmp32x16(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) |
mijimy | 0:847d62ecf52e | 352 | { |
mijimy | 0:847d62ecf52e | 353 | uint8_t t,i,jx,jy,k,kx,ky; |
mijimy | 0:847d62ecf52e | 354 | if (x<(LCD_Xmax-31) && y<(LCD_Ymax-15)) // boundary check |
mijimy | 0:847d62ecf52e | 355 | for (jy=0;jy<2;jy++) |
mijimy | 0:847d62ecf52e | 356 | for (jx=0;jx<2;jx++) { |
mijimy | 0:847d62ecf52e | 357 | k=x; |
mijimy | 0:847d62ecf52e | 358 | for (i=0;i<16;i++) { |
mijimy | 0:847d62ecf52e | 359 | kx=x+jx*16+i; |
mijimy | 0:847d62ecf52e | 360 | t=bitmap[i+jx*16+jy*32]; |
mijimy | 0:847d62ecf52e | 361 | for (k=0;k<8;k++) { |
mijimy | 0:847d62ecf52e | 362 | ky=y+jy*8+k; |
mijimy | 0:847d62ecf52e | 363 | if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); |
mijimy | 0:847d62ecf52e | 364 | } |
mijimy | 0:847d62ecf52e | 365 | } |
mijimy | 0:847d62ecf52e | 366 | } |
mijimy | 0:847d62ecf52e | 367 | } |
mijimy | 0:847d62ecf52e | 368 | |
mijimy | 0:847d62ecf52e | 369 | void draw_Bmp32x32(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) |
mijimy | 0:847d62ecf52e | 370 | { |
mijimy | 0:847d62ecf52e | 371 | uint8_t t,i,jx,jy,k, kx,ky; |
mijimy | 0:847d62ecf52e | 372 | if (x<(LCD_Xmax-31) && y<(LCD_Ymax-31)) // boundary check |
mijimy | 0:847d62ecf52e | 373 | for (jy=0;jy<4;jy++) |
mijimy | 0:847d62ecf52e | 374 | for (jx=0;jx<2;jx++) { |
mijimy | 0:847d62ecf52e | 375 | k=x; |
mijimy | 0:847d62ecf52e | 376 | for (i=0;i<16;i++) { |
mijimy | 0:847d62ecf52e | 377 | kx=x+jx*16+i; |
mijimy | 0:847d62ecf52e | 378 | t=bitmap[i+jx*16+jy*32]; |
mijimy | 0:847d62ecf52e | 379 | for (k=0;k<8;k++) { |
mijimy | 0:847d62ecf52e | 380 | ky=y+jy*8+k; |
mijimy | 0:847d62ecf52e | 381 | if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); |
mijimy | 0:847d62ecf52e | 382 | } |
mijimy | 0:847d62ecf52e | 383 | } |
mijimy | 0:847d62ecf52e | 384 | } |
mijimy | 0:847d62ecf52e | 385 | } |
mijimy | 0:847d62ecf52e | 386 | |
mijimy | 0:847d62ecf52e | 387 | void draw_Bmp32x48(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) |
mijimy | 0:847d62ecf52e | 388 | { |
mijimy | 0:847d62ecf52e | 389 | uint8_t t,i,jx,jy,k, kx,ky; |
mijimy | 0:847d62ecf52e | 390 | if (x<(LCD_Xmax-31) && y<(LCD_Ymax-47)) // boundary check |
mijimy | 0:847d62ecf52e | 391 | for (jy=0;jy<6;jy++) |
mijimy | 0:847d62ecf52e | 392 | for (jx=0;jx<2;jx++) { |
mijimy | 0:847d62ecf52e | 393 | k=x; |
mijimy | 0:847d62ecf52e | 394 | for (i=0;i<16;i++) { |
mijimy | 0:847d62ecf52e | 395 | kx=x+jx*16+i; |
mijimy | 0:847d62ecf52e | 396 | t=bitmap[i+jx*16+jy*32]; |
mijimy | 0:847d62ecf52e | 397 | for (k=0;k<8;k++) { |
mijimy | 0:847d62ecf52e | 398 | ky=y+jy*8+k; |
mijimy | 0:847d62ecf52e | 399 | if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); |
mijimy | 0:847d62ecf52e | 400 | } |
mijimy | 0:847d62ecf52e | 401 | } |
mijimy | 0:847d62ecf52e | 402 | } |
mijimy | 0:847d62ecf52e | 403 | } |
mijimy | 0:847d62ecf52e | 404 | |
mijimy | 0:847d62ecf52e | 405 | void draw_Bmp32x64(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) |
mijimy | 0:847d62ecf52e | 406 | { |
mijimy | 0:847d62ecf52e | 407 | uint8_t t,i,jx,jy,k, kx,ky; |
mijimy | 0:847d62ecf52e | 408 | if (x<(LCD_Xmax-31) && y==0) // boundary check |
mijimy | 0:847d62ecf52e | 409 | for (jy=0;jy<8;jy++) |
mijimy | 0:847d62ecf52e | 410 | for (jx=0;jx<2;jx++) { |
mijimy | 0:847d62ecf52e | 411 | k=x; |
mijimy | 0:847d62ecf52e | 412 | for (i=0;i<16;i++) { |
mijimy | 0:847d62ecf52e | 413 | kx=x+jx*16+i; |
mijimy | 0:847d62ecf52e | 414 | t=bitmap[i+jx*16+jy*32]; |
mijimy | 0:847d62ecf52e | 415 | for (k=0;k<8;k++) { |
mijimy | 0:847d62ecf52e | 416 | ky=y+jy*8+k; |
mijimy | 0:847d62ecf52e | 417 | if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); |
mijimy | 0:847d62ecf52e | 418 | } |
mijimy | 0:847d62ecf52e | 419 | } |
mijimy | 0:847d62ecf52e | 420 | } |
mijimy | 0:847d62ecf52e | 421 | } |
mijimy | 0:847d62ecf52e | 422 | |
mijimy | 0:847d62ecf52e | 423 | void draw_Bmp64x64(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) |
mijimy | 0:847d62ecf52e | 424 | { |
mijimy | 0:847d62ecf52e | 425 | uint8_t t, i,jx,jy,k, kx,ky; |
mijimy | 0:847d62ecf52e | 426 | if (x<(LCD_Xmax-63) && y==0) // boundary check |
mijimy | 0:847d62ecf52e | 427 | for (jy=0;jy<8;jy++) |
mijimy | 0:847d62ecf52e | 428 | for (jx=0;jx<4;jx++) { |
mijimy | 0:847d62ecf52e | 429 | k=x; |
mijimy | 0:847d62ecf52e | 430 | for (i=0;i<16;i++) { |
mijimy | 0:847d62ecf52e | 431 | kx=x+jx*16+i; |
mijimy | 0:847d62ecf52e | 432 | t=bitmap[i+jx*16+jy*64]; |
mijimy | 0:847d62ecf52e | 433 | for (k=0;k<8;k++) { |
mijimy | 0:847d62ecf52e | 434 | ky=y+jy*8+k; |
mijimy | 0:847d62ecf52e | 435 | if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); |
mijimy | 0:847d62ecf52e | 436 | } |
mijimy | 0:847d62ecf52e | 437 | } |
mijimy | 0:847d62ecf52e | 438 | } |
mijimy | 0:847d62ecf52e | 439 | } |
mijimy | 0:847d62ecf52e | 440 | |
mijimy | 0:847d62ecf52e | 441 | void draw_LCD(const unsigned char *buffer) |
mijimy | 0:847d62ecf52e | 442 | { |
mijimy | 0:847d62ecf52e | 443 | uint8_t x,y; |
mijimy | 0:847d62ecf52e | 444 | for (x=0; x<LCD_Xmax; x++) { |
mijimy | 0:847d62ecf52e | 445 | for (y=0; y<(LCD_Ymax/8); y++) { |
mijimy | 0:847d62ecf52e | 446 | lcdSetAddr(x ,y); |
mijimy | 0:847d62ecf52e | 447 | lcdWriteData(buffer[x+y*LCD_Xmax]); |
mijimy | 0:847d62ecf52e | 448 | } |
mijimy | 0:847d62ecf52e | 449 | } |
mijimy | 0:847d62ecf52e | 450 | } |
mijimy | 0:847d62ecf52e | 451 |