EPD display library.

Dependents:   acd52832_ePaper acd52832_SAADC_Differential_input_2 acd52832_SAADC_Differential_input_EPD acd52832_Car_battery_ch ... more

Fork of GDEP015OC1 by aconno dev team

Committer:
Anunnaki
Date:
Tue Sep 20 10:11:07 2016 +0000
Revision:
4:86114342ce8f
Parent:
3:dc7b794b59b7
Child:
5:6709a20459ad
Child:
6:45d2ec037fd6
Added fill function;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Anunnaki 3:dc7b794b59b7 1 /**
Anunnaki 3:dc7b794b59b7 2 * Created by Filip Hormot (f.hormot@gmail.com) on 14/09/16.
Anunnaki 3:dc7b794b59b7 3 */
Anunnaki 1:4fff95e316c9 4 #include "mbed.h"
Anunnaki 1:4fff95e316c9 5 #include "GDEP015OC1.h"
Anunnaki 3:dc7b794b59b7 6 #include "5x7.h"
Anunnaki 1:4fff95e316c9 7
Anunnaki 2:1c8f73aa2a16 8 static const unsigned char _lutFull[] = {
Anunnaki 2:1c8f73aa2a16 9 0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22, 0x66, 0x69, 0x69, 0x59, 0x58, 0x99, 0x99,
Anunnaki 2:1c8f73aa2a16 10 0x88, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xB4, 0x13, 0x51, 0x35, 0x51, 0x51, 0x19, 0x01, 0x00
Anunnaki 2:1c8f73aa2a16 11 };
Anunnaki 2:1c8f73aa2a16 12
Anunnaki 2:1c8f73aa2a16 13 GDEP015OC1::GDEP015OC1(SPI& spi, PinName cs=p5, PinName dc=p6, PinName rst=p7, PinName busy=p8) : _spi(spi), _cs(cs), _dc(dc), _rst(rst), _busy(busy){
Anunnaki 3:dc7b794b59b7 14 _bold = _italic = false;
Anunnaki 1:4fff95e316c9 15 _init();
Anunnaki 1:4fff95e316c9 16 }
Anunnaki 1:4fff95e316c9 17
Anunnaki 2:1c8f73aa2a16 18 void GDEP015OC1::_spiCommand(unsigned char command){
Anunnaki 2:1c8f73aa2a16 19 _cs = _dc = 0;
Anunnaki 2:1c8f73aa2a16 20 wait_us(1);
Anunnaki 2:1c8f73aa2a16 21
Anunnaki 2:1c8f73aa2a16 22 _spi.write(command);
Anunnaki 2:1c8f73aa2a16 23 }
Anunnaki 2:1c8f73aa2a16 24
Anunnaki 2:1c8f73aa2a16 25 void GDEP015OC1::_spiData(unsigned char data){
Anunnaki 2:1c8f73aa2a16 26 _cs = 0;
Anunnaki 2:1c8f73aa2a16 27 _dc = 1;
Anunnaki 2:1c8f73aa2a16 28 wait_us(1);
Anunnaki 2:1c8f73aa2a16 29
Anunnaki 2:1c8f73aa2a16 30 _spi.write(data);
Anunnaki 2:1c8f73aa2a16 31 }
Anunnaki 2:1c8f73aa2a16 32
Anunnaki 2:1c8f73aa2a16 33 void GDEP015OC1::_init(void){
Anunnaki 2:1c8f73aa2a16 34 _rst = _cs = 1;
Anunnaki 3:dc7b794b59b7 35 empty();
Anunnaki 1:4fff95e316c9 36 }
Anunnaki 1:4fff95e316c9 37
Anunnaki 2:1c8f73aa2a16 38 void GDEP015OC1::_wakeUp(void){
Anunnaki 2:1c8f73aa2a16 39 _rst = 0;
Anunnaki 2:1c8f73aa2a16 40 wait_ms(10);
Anunnaki 2:1c8f73aa2a16 41 _rst = 1;
Anunnaki 2:1c8f73aa2a16 42 wait_ms(10);
Anunnaki 1:4fff95e316c9 43
Anunnaki 2:1c8f73aa2a16 44 //Stage 3
Anunnaki 2:1c8f73aa2a16 45 //Driver Output control
Anunnaki 2:1c8f73aa2a16 46 _spiCommand(0x01);
Anunnaki 2:1c8f73aa2a16 47 _spiData(0xC7);
Anunnaki 2:1c8f73aa2a16 48 _spiData(0x00);
Anunnaki 2:1c8f73aa2a16 49 _spiData(0x00);
Anunnaki 2:1c8f73aa2a16 50 //Softstart
Anunnaki 2:1c8f73aa2a16 51 _spiCommand(0x0C);
Anunnaki 2:1c8f73aa2a16 52 _spiData(0xD7);
Anunnaki 2:1c8f73aa2a16 53 _spiData(0xD6);
Anunnaki 2:1c8f73aa2a16 54 _spiData(0x9D);
Anunnaki 2:1c8f73aa2a16 55
Anunnaki 2:1c8f73aa2a16 56 _spiCommand(0x22);
Anunnaki 2:1c8f73aa2a16 57 _spiData(0xF0);
Anunnaki 2:1c8f73aa2a16 58
Anunnaki 2:1c8f73aa2a16 59 //VCOM setting
Anunnaki 2:1c8f73aa2a16 60 _spiCommand(0x2C);
Anunnaki 2:1c8f73aa2a16 61 _spiData(0xA8);
Anunnaki 2:1c8f73aa2a16 62 //Dummy line period
Anunnaki 2:1c8f73aa2a16 63 _spiCommand(0x3A);
Anunnaki 2:1c8f73aa2a16 64 _spiData(0x1A);
Anunnaki 2:1c8f73aa2a16 65 //Gate line width
Anunnaki 2:1c8f73aa2a16 66 _spiCommand(0x3B);
Anunnaki 2:1c8f73aa2a16 67 _spiData(0x08);
Anunnaki 2:1c8f73aa2a16 68 //Set data entry mode
Anunnaki 2:1c8f73aa2a16 69 _spiCommand(0x11);
Anunnaki 2:1c8f73aa2a16 70 _spiData(0x01); //DO NOT TOUCH THIS! (MUST BE 0x01)
Anunnaki 2:1c8f73aa2a16 71
Anunnaki 2:1c8f73aa2a16 72 //Gate driver start position
Anunnaki 2:1c8f73aa2a16 73 _spiCommand(0x0F);
Anunnaki 2:1c8f73aa2a16 74 _spiData(0x2B);
Anunnaki 2:1c8f73aa2a16 75 _spiData(0x01);
Anunnaki 2:1c8f73aa2a16 76
Anunnaki 2:1c8f73aa2a16 77 //VGH VGL
Anunnaki 2:1c8f73aa2a16 78 _spiCommand(0x03);
Anunnaki 2:1c8f73aa2a16 79 _spiData(0x00);
Anunnaki 2:1c8f73aa2a16 80 //VSH, VSL
Anunnaki 2:1c8f73aa2a16 81 _spiCommand(0x04);
Anunnaki 2:1c8f73aa2a16 82 _spiData(0x0A);
Anunnaki 2:1c8f73aa2a16 83
Anunnaki 2:1c8f73aa2a16 84 //Define X display size
Anunnaki 2:1c8f73aa2a16 85 _spiCommand(0x44);
Anunnaki 2:1c8f73aa2a16 86 _spiData(0x00);
Anunnaki 2:1c8f73aa2a16 87 _spiData(0x18);
Anunnaki 2:1c8f73aa2a16 88 //Define Y display size
Anunnaki 2:1c8f73aa2a16 89 _spiCommand(0x45);
Anunnaki 2:1c8f73aa2a16 90 _spiData(0xC7);
Anunnaki 2:1c8f73aa2a16 91 _spiData(0x00);
Anunnaki 2:1c8f73aa2a16 92 _spiData(0x2B);
Anunnaki 2:1c8f73aa2a16 93 _spiData(0x01);
Anunnaki 2:1c8f73aa2a16 94
Anunnaki 2:1c8f73aa2a16 95 //Define X RAM address
Anunnaki 2:1c8f73aa2a16 96 _spiCommand(0x4E);
Anunnaki 2:1c8f73aa2a16 97 _spiData(0x00);
Anunnaki 2:1c8f73aa2a16 98 //Define Y RAM address
Anunnaki 2:1c8f73aa2a16 99 _spiCommand(0x4F);
Anunnaki 2:1c8f73aa2a16 100 _spiData(0xC7);
Anunnaki 2:1c8f73aa2a16 101 _spiData(0x00);
Anunnaki 2:1c8f73aa2a16 102
Anunnaki 2:1c8f73aa2a16 103 //Border waveform control
Anunnaki 2:1c8f73aa2a16 104 _spiCommand(0x3C);
Anunnaki 2:1c8f73aa2a16 105 _spiData(0x33);
Anunnaki 2:1c8f73aa2a16 106
Anunnaki 2:1c8f73aa2a16 107 //Write LUT
Anunnaki 2:1c8f73aa2a16 108 _spiCommand(0x32);
Anunnaki 2:1c8f73aa2a16 109 for(uint8_t i = 0; i<30;i++)
Anunnaki 2:1c8f73aa2a16 110 _spiData(_lutFull[i]);
Anunnaki 2:1c8f73aa2a16 111
Anunnaki 2:1c8f73aa2a16 112 //Power on
Anunnaki 2:1c8f73aa2a16 113 _spiCommand(0x22);
Anunnaki 2:1c8f73aa2a16 114 _spiData(0xC0);
Anunnaki 2:1c8f73aa2a16 115
Anunnaki 2:1c8f73aa2a16 116 //Define X RAM address
Anunnaki 2:1c8f73aa2a16 117 _spiCommand(0x4E);
Anunnaki 2:1c8f73aa2a16 118 _spiData(0x00);
Anunnaki 2:1c8f73aa2a16 119 //Define Y RAM address
Anunnaki 2:1c8f73aa2a16 120 _spiCommand(0x4F);
Anunnaki 2:1c8f73aa2a16 121 _spiData(0xC7);
Anunnaki 2:1c8f73aa2a16 122 _spiData(0x00);
Anunnaki 1:4fff95e316c9 123 }
Anunnaki 1:4fff95e316c9 124
Anunnaki 2:1c8f73aa2a16 125 void GDEP015OC1::_sleep(void){
Anunnaki 2:1c8f73aa2a16 126 while(_busy == BUSY_STATE);
Anunnaki 2:1c8f73aa2a16 127
Anunnaki 2:1c8f73aa2a16 128 _spiCommand(0x10);
Anunnaki 2:1c8f73aa2a16 129 _spiData(0x01);
Anunnaki 2:1c8f73aa2a16 130 }
Anunnaki 2:1c8f73aa2a16 131
Anunnaki 2:1c8f73aa2a16 132 //If you touch this function satan will feast on your soul for an eternity!
Anunnaki 2:1c8f73aa2a16 133 unsigned char GDEP015OC1::_pixelConv(unsigned char *data, int i){
Anunnaki 2:1c8f73aa2a16 134 uint8_t pix = 0x00;
Anunnaki 2:1c8f73aa2a16 135 for(uint8_t x = 0; x < 8; x++){
Anunnaki 2:1c8f73aa2a16 136 pix |= ((*(data + (i*200)%5000 + (24-i/200) + x*25)>>((i/25)%8))&(0x01))<<(7-x);
Anunnaki 2:1c8f73aa2a16 137 }
Anunnaki 3:dc7b794b59b7 138 return pix^0xFF;
Anunnaki 2:1c8f73aa2a16 139 }
Anunnaki 2:1c8f73aa2a16 140
Anunnaki 2:1c8f73aa2a16 141 uint8_t GDEP015OC1::_mirrorData(uint8_t data){
Anunnaki 2:1c8f73aa2a16 142 uint8_t mirror = 0x00;
Anunnaki 2:1c8f73aa2a16 143 for(uint8_t i=0; i<8; i++)
Anunnaki 2:1c8f73aa2a16 144 mirror |= ((data>>i) & 0x01) << (7 - i);
Anunnaki 2:1c8f73aa2a16 145
Anunnaki 2:1c8f73aa2a16 146 return mirror;
Anunnaki 2:1c8f73aa2a16 147 }
Anunnaki 2:1c8f73aa2a16 148
Anunnaki 4:86114342ce8f 149 void GDEP015OC1::fill(unsigned char data, int x){
Anunnaki 4:86114342ce8f 150 _buffer[x] = data;
Anunnaki 4:86114342ce8f 151 }
Anunnaki 4:86114342ce8f 152
Anunnaki 2:1c8f73aa2a16 153 void GDEP015OC1::empty(void){
Anunnaki 2:1c8f73aa2a16 154 for(uint16_t x=0; x<5000; x++)
Anunnaki 2:1c8f73aa2a16 155 _buffer[x] = 0x00;
Anunnaki 2:1c8f73aa2a16 156 }
Anunnaki 2:1c8f73aa2a16 157
Anunnaki 2:1c8f73aa2a16 158 void GDEP015OC1::write(void){
Anunnaki 2:1c8f73aa2a16 159 _wakeUp();
Anunnaki 2:1c8f73aa2a16 160
Anunnaki 2:1c8f73aa2a16 161 _spiCommand(0x24);
Anunnaki 2:1c8f73aa2a16 162 for(int16_t x=0; x>=0 && x<200; x++){
Anunnaki 2:1c8f73aa2a16 163 for(int16_t y=24; y>=0 && y<25; y--){
Anunnaki 2:1c8f73aa2a16 164 _spiData(_mirrorData(_pixelConv(_buffer, x*25+y)));
Anunnaki 2:1c8f73aa2a16 165 wait_us(10);
Anunnaki 2:1c8f73aa2a16 166 }
Anunnaki 2:1c8f73aa2a16 167 }
Anunnaki 2:1c8f73aa2a16 168
Anunnaki 2:1c8f73aa2a16 169 _spiCommand(0x22);
Anunnaki 2:1c8f73aa2a16 170 _spiData(0x04);
Anunnaki 2:1c8f73aa2a16 171 _spiCommand(0x22);
Anunnaki 2:1c8f73aa2a16 172 _spiData(0x08);
Anunnaki 2:1c8f73aa2a16 173
Anunnaki 2:1c8f73aa2a16 174 //Update
Anunnaki 2:1c8f73aa2a16 175 _spiCommand(0x22);
Anunnaki 2:1c8f73aa2a16 176 _spiData(0xC7);
Anunnaki 2:1c8f73aa2a16 177 _spiCommand(0x20);
Anunnaki 2:1c8f73aa2a16 178
Anunnaki 2:1c8f73aa2a16 179 _sleep();
Anunnaki 2:1c8f73aa2a16 180 }
Anunnaki 2:1c8f73aa2a16 181
Anunnaki 2:1c8f73aa2a16 182 void GDEP015OC1::drawPixel(uint16_t startX, uint16_t startY, bool color=0){
Anunnaki 2:1c8f73aa2a16 183 if(startX>199 || startY>199) return;
Anunnaki 2:1c8f73aa2a16 184
Anunnaki 2:1c8f73aa2a16 185 uint16_t i = startX/8 + startY*25;
Anunnaki 2:1c8f73aa2a16 186
Anunnaki 2:1c8f73aa2a16 187 if(!color)
Anunnaki 2:1c8f73aa2a16 188 _buffer[i] = (_buffer[i] | (1<<(7-startX%8)));
Anunnaki 2:1c8f73aa2a16 189 else
Anunnaki 2:1c8f73aa2a16 190 _buffer[i] = (_buffer[i] & (0xFF^(1<<(7-startX%8))));
Anunnaki 2:1c8f73aa2a16 191 }
Anunnaki 2:1c8f73aa2a16 192
Anunnaki 2:1c8f73aa2a16 193
Anunnaki 2:1c8f73aa2a16 194 void GDEP015OC1::drawLine(uint16_t startX, uint16_t startY, uint16_t stopX, uint16_t stopY, bool color=0){
Anunnaki 2:1c8f73aa2a16 195 int dx = abs(stopX-startX), sx = startX<stopX ? 1 : -1;
Anunnaki 2:1c8f73aa2a16 196 int dy = abs(stopY-startY), sy = startY<stopY ? 1 : -1;
Anunnaki 2:1c8f73aa2a16 197 int err = (dx>dy ? dx : -dy)/2, e2;
Anunnaki 2:1c8f73aa2a16 198
Anunnaki 2:1c8f73aa2a16 199 for(;;){
Anunnaki 2:1c8f73aa2a16 200 drawPixel(startX,startY,color);
Anunnaki 2:1c8f73aa2a16 201 if (startX==stopX && startY==stopY) break;
Anunnaki 2:1c8f73aa2a16 202 e2 = err;
Anunnaki 2:1c8f73aa2a16 203 if (e2 >-dx) { err -= dy; startX += sx; }
Anunnaki 2:1c8f73aa2a16 204 if (e2 < dy) { err += dx; startY += sy; }
Anunnaki 2:1c8f73aa2a16 205 }
Anunnaki 3:dc7b794b59b7 206 }
Anunnaki 3:dc7b794b59b7 207
Anunnaki 3:dc7b794b59b7 208 void GDEP015OC1::drawTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, bool color=0){
Anunnaki 3:dc7b794b59b7 209 drawLine(x1, y1, x2, y2, color);
Anunnaki 3:dc7b794b59b7 210 drawLine(x2, y2, x3, y3, color);
Anunnaki 3:dc7b794b59b7 211 drawLine(x3, y3, x1, y1, color);
Anunnaki 3:dc7b794b59b7 212 }
Anunnaki 3:dc7b794b59b7 213
Anunnaki 3:dc7b794b59b7 214 void GDEP015OC1::drawRectangle(uint16_t startX, uint16_t startY, uint16_t stopX, uint16_t stopY, bool color=0){
Anunnaki 3:dc7b794b59b7 215 drawLine(startX, startY, stopX, startY, color);
Anunnaki 3:dc7b794b59b7 216 drawLine(stopX, startY, stopX, stopY, color);
Anunnaki 3:dc7b794b59b7 217 drawLine(stopX, stopY, startX, stopY, color);
Anunnaki 3:dc7b794b59b7 218 drawLine(startX, stopY, startX, startY, color);
Anunnaki 3:dc7b794b59b7 219 }
Anunnaki 3:dc7b794b59b7 220
Anunnaki 3:dc7b794b59b7 221 void GDEP015OC1::drawCircle(uint16_t startX, uint16_t startY, uint16_t radius, bool color=0){
Anunnaki 3:dc7b794b59b7 222 int d,x,y;
Anunnaki 3:dc7b794b59b7 223
Anunnaki 3:dc7b794b59b7 224 d=3-2*radius;
Anunnaki 3:dc7b794b59b7 225 x=0;
Anunnaki 3:dc7b794b59b7 226 y=radius;
Anunnaki 3:dc7b794b59b7 227 while(x<=y){
Anunnaki 3:dc7b794b59b7 228 drawPixel(startX+x,startY+y,color);
Anunnaki 3:dc7b794b59b7 229 drawPixel(startX-y,startY-x,color);
Anunnaki 3:dc7b794b59b7 230 drawPixel(startX+y,startY-x,color);
Anunnaki 3:dc7b794b59b7 231 drawPixel(startX-y,startY+x,color);
Anunnaki 3:dc7b794b59b7 232 drawPixel(startX+y,startY+x,color);
Anunnaki 3:dc7b794b59b7 233 drawPixel(startX-x,startY-y,color);
Anunnaki 3:dc7b794b59b7 234 drawPixel(startX+x,startY-y,color);
Anunnaki 3:dc7b794b59b7 235 drawPixel(startX-x,startY+y,color);
Anunnaki 3:dc7b794b59b7 236
Anunnaki 3:dc7b794b59b7 237 if(d<=0)
Anunnaki 3:dc7b794b59b7 238 d=d+4*x+6;
Anunnaki 3:dc7b794b59b7 239 else{
Anunnaki 3:dc7b794b59b7 240 d=d+4*x-4*y+10;
Anunnaki 3:dc7b794b59b7 241 y--;
Anunnaki 3:dc7b794b59b7 242 }
Anunnaki 3:dc7b794b59b7 243 x++;
Anunnaki 3:dc7b794b59b7 244 }
Anunnaki 3:dc7b794b59b7 245 }
Anunnaki 3:dc7b794b59b7 246
Anunnaki 3:dc7b794b59b7 247 void GDEP015OC1::fillCircle(uint16_t startX, uint16_t startY, uint16_t radius, bool color=0){
Anunnaki 3:dc7b794b59b7 248 for(uint16_t r = 1;r<=radius; r++){
Anunnaki 3:dc7b794b59b7 249 drawCircle(startX, startY, r, color);
Anunnaki 3:dc7b794b59b7 250 drawCircle(startX+1, startY, r-1, color);
Anunnaki 3:dc7b794b59b7 251 drawCircle(startX-1, startY, r-1, color);
Anunnaki 3:dc7b794b59b7 252 }
Anunnaki 3:dc7b794b59b7 253 }
Anunnaki 3:dc7b794b59b7 254
Anunnaki 3:dc7b794b59b7 255 void GDEP015OC1::drawEllipse(uint16_t startX, uint16_t startY, uint16_t width, uint16_t height, bool color){
Anunnaki 3:dc7b794b59b7 256 int a2 = width*width;
Anunnaki 3:dc7b794b59b7 257 int b2 = height*height;
Anunnaki 3:dc7b794b59b7 258 int fa2 = 4*a2, fb2 = 4*b2;
Anunnaki 3:dc7b794b59b7 259 int x, y, sigma;
Anunnaki 3:dc7b794b59b7 260
Anunnaki 3:dc7b794b59b7 261 //First half
Anunnaki 3:dc7b794b59b7 262 for(int x = 0, y = height, sigma = 2*b2+a2*(1-2*height); b2*x <= a2*y; x++){
Anunnaki 3:dc7b794b59b7 263 drawPixel(startX+x,startY+y,color);
Anunnaki 3:dc7b794b59b7 264 drawPixel(startX-x,startY+y,color);
Anunnaki 3:dc7b794b59b7 265 drawPixel(startX+x,startY-y,color);
Anunnaki 3:dc7b794b59b7 266 drawPixel(startX-x,startY-y,color);
Anunnaki 3:dc7b794b59b7 267 if(sigma >= 0){
Anunnaki 3:dc7b794b59b7 268 sigma += fa2 * (1-y);
Anunnaki 3:dc7b794b59b7 269 y--;
Anunnaki 3:dc7b794b59b7 270 }
Anunnaki 3:dc7b794b59b7 271 sigma += b2 * ((4 * x) + 6);
Anunnaki 3:dc7b794b59b7 272 }
Anunnaki 3:dc7b794b59b7 273 //Second half
Anunnaki 3:dc7b794b59b7 274 for (x = width, y = 0, sigma = 2*a2+b2*(1-2*width); a2*y <= b2*x; y++){
Anunnaki 3:dc7b794b59b7 275 drawPixel(startX+x,startY+y,color);
Anunnaki 3:dc7b794b59b7 276 drawPixel(startX-x,startY+y,color);
Anunnaki 3:dc7b794b59b7 277 drawPixel(startX+x,startY-y,color);
Anunnaki 3:dc7b794b59b7 278 drawPixel(startX-x,startY-y,color);
Anunnaki 3:dc7b794b59b7 279 if (sigma >= 0){
Anunnaki 3:dc7b794b59b7 280 sigma += fb2 * (1 - x);
Anunnaki 3:dc7b794b59b7 281 x--;
Anunnaki 3:dc7b794b59b7 282 }
Anunnaki 3:dc7b794b59b7 283 sigma += a2 * ((4 * y) + 6);
Anunnaki 3:dc7b794b59b7 284 }
Anunnaki 3:dc7b794b59b7 285 }
Anunnaki 3:dc7b794b59b7 286
Anunnaki 3:dc7b794b59b7 287 void GDEP015OC1::fillEllipse(uint16_t startX, uint16_t startY, uint16_t width, uint16_t height, bool color=0){
Anunnaki 3:dc7b794b59b7 288 for(uint16_t w = width; w > 0; w--){
Anunnaki 3:dc7b794b59b7 289 drawEllipse(startX, startX, w, height, color);
Anunnaki 3:dc7b794b59b7 290 }
Anunnaki 3:dc7b794b59b7 291 drawLine(startX, startY-height, startX, startY+height, color);
Anunnaki 3:dc7b794b59b7 292 }
Anunnaki 3:dc7b794b59b7 293
Anunnaki 3:dc7b794b59b7 294 void GDEP015OC1::writeChar(char character, uint16_t startX, uint16_t startY, bool color=0){
Anunnaki 3:dc7b794b59b7 295 unsigned char letter[FONT_WIDTH];
Anunnaki 3:dc7b794b59b7 296
Anunnaki 3:dc7b794b59b7 297 //Grab data for the corresponding font
Anunnaki 3:dc7b794b59b7 298 for(uint8_t i = 0; i<FONT_WIDTH; i++)
Anunnaki 3:dc7b794b59b7 299 letter[i] = Font5x7[(character - ' ') * FONT_WIDTH + i];
Anunnaki 3:dc7b794b59b7 300
Anunnaki 3:dc7b794b59b7 301 for(uint8_t i = 0; i<FONT_WIDTH; i++){
Anunnaki 3:dc7b794b59b7 302 for(uint8_t j = 0; j<FONT_HEIGHT; j++){
Anunnaki 3:dc7b794b59b7 303 if((letter[i]>>j)&0x01){
Anunnaki 3:dc7b794b59b7 304 if(_italic){
Anunnaki 3:dc7b794b59b7 305 drawPixel(startX+i+(FONT_HEIGHT/3 - j/3), startY+j, color);
Anunnaki 3:dc7b794b59b7 306 if(_bold){
Anunnaki 3:dc7b794b59b7 307 for(uint8_t z=0; z<2; z++)
Anunnaki 3:dc7b794b59b7 308 drawPixel(startX+i-z+(FONT_HEIGHT/3- j/3), startY+j, color);
Anunnaki 3:dc7b794b59b7 309 }
Anunnaki 3:dc7b794b59b7 310 }
Anunnaki 3:dc7b794b59b7 311 else{
Anunnaki 3:dc7b794b59b7 312 drawPixel(startX+i, startY+j, color);
Anunnaki 3:dc7b794b59b7 313 if(_bold){
Anunnaki 3:dc7b794b59b7 314 for(uint8_t z=0; z<2; z++)
Anunnaki 3:dc7b794b59b7 315 drawPixel(startX+i-z, startY+j, color);
Anunnaki 3:dc7b794b59b7 316 }
Anunnaki 3:dc7b794b59b7 317 }
Anunnaki 3:dc7b794b59b7 318 }
Anunnaki 3:dc7b794b59b7 319 }
Anunnaki 3:dc7b794b59b7 320 }
Anunnaki 3:dc7b794b59b7 321 }
Anunnaki 3:dc7b794b59b7 322
Anunnaki 3:dc7b794b59b7 323 void GDEP015OC1::writeString(char *string, uint16_t startX, uint16_t startY, bool color=0){
Anunnaki 3:dc7b794b59b7 324 uint8_t length = 0;
Anunnaki 3:dc7b794b59b7 325 while(*(string+length) != '\0') length++;
Anunnaki 3:dc7b794b59b7 326
Anunnaki 3:dc7b794b59b7 327 for(uint8_t x=0; x<length; x++)
Anunnaki 4:86114342ce8f 328 writeChar(*(string+x), startX+(FONT_WIDTH+1)*x, startY, color); //FONT_WIDTH+1 gives a 1px space between the characters
Anunnaki 2:1c8f73aa2a16 329 }