A modified version of the GDEP015OC1 library that supports x-or as a color.
Fork of GDEP015OC1 by
Diff: GDEP015OC1.cpp
- Revision:
- 8:cd51988ee35d
- Parent:
- 7:70c58d3cbc8b
- Child:
- 9:1f1e705a5f02
--- a/GDEP015OC1.cpp Mon Sep 26 10:08:14 2016 +0000 +++ b/GDEP015OC1.cpp Mon Jan 16 15:48:53 2017 +0000 @@ -224,19 +224,26 @@ _sleep(); } -void GDEP015OC1::drawPixel(uint16_t startX, uint16_t startY, bool color=0){ +void GDEP015OC1::drawPixel(uint16_t startX, uint16_t startY, Color color=eBlack){ if(startX>199 || startY>199) return; uint16_t i = startX/8 + startY*25; - if(!color) - _buffer[i] = (_buffer[i] | (1<<(7-startX%8))); - else - _buffer[i] = (_buffer[i] & (0xFF^(1<<(7-startX%8)))); + switch(color) { + case eWhite : + _buffer[i] = (_buffer[i] & (0xFF^(1<<(7-startX%8)))); + break; + case eBlack : + _buffer[i] = (_buffer[i] | (1<<(7-startX%8))); + break; + case eInvert : + _buffer[i] = (_buffer[i] ^ (1<<(7-startX%8))); + break; + } } -void GDEP015OC1::drawLine(uint16_t startX, uint16_t startY, uint16_t stopX, uint16_t stopY, bool color=0){ +void GDEP015OC1::drawLine(uint16_t startX, uint16_t startY, uint16_t stopX, uint16_t stopY, Color color=eBlack){ int dx = abs(stopX-startX), sx = startX<stopX ? 1 : -1; int dy = abs(stopY-startY), sy = startY<stopY ? 1 : -1; int err = (dx>dy ? dx : -dy)/2, e2; @@ -250,20 +257,32 @@ } } -void GDEP015OC1::drawTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, bool color=0){ +void GDEP015OC1::drawTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, Color color=eBlack){ drawLine(x1, y1, x2, y2, color); drawLine(x2, y2, x3, y3, color); drawLine(x3, y3, x1, y1, color); } -void GDEP015OC1::drawRectangle(uint16_t startX, uint16_t startY, uint16_t stopX, uint16_t stopY, bool color=0){ +void GDEP015OC1::drawRectangle(uint16_t startX, uint16_t startY, uint16_t stopX, uint16_t stopY, Color color=eBlack){ drawLine(startX, startY, stopX, startY, color); drawLine(stopX, startY, stopX, stopY, color); drawLine(stopX, stopY, startX, stopY, color); drawLine(startX, stopY, startX, startY, color); } -void GDEP015OC1::drawCircle(uint16_t startX, uint16_t startY, uint16_t radius, bool color=0){ +void GDEP015OC1::fillRectangle(uint16_t startX, uint16_t startY, uint16_t stopX, uint16_t stopY, Color color=eBlack){ + for(int x = startX; x<stopX; x++) + { + drawLine(x, startY, x, stopY, color); + } + drawLine(startX, startY, stopX, startY, color); + drawLine(stopX, startY, stopX, stopY, color); + drawLine(stopX, stopY, startX, stopY, color); + drawLine(startX, stopY, startX, startY, color); +} + + +void GDEP015OC1::drawCircle(uint16_t startX, uint16_t startY, uint16_t radius, Color color=eBlack){ int d,x,y; d=3-2*radius; @@ -289,7 +308,7 @@ } } -void GDEP015OC1::fillCircle(uint16_t startX, uint16_t startY, uint16_t radius, bool color=0){ +void GDEP015OC1::fillCircle(uint16_t startX, uint16_t startY, uint16_t radius, Color color=eBlack){ for(uint16_t r = 1;r<=radius; r++){ drawCircle(startX, startY, r, color); drawCircle(startX+1, startY, r-1, color); @@ -297,7 +316,7 @@ } } -void GDEP015OC1::drawEllipse(uint16_t startX, uint16_t startY, uint16_t width, uint16_t height, bool color){ +void GDEP015OC1::drawEllipse(uint16_t startX, uint16_t startY, uint16_t width, uint16_t height, Color color=eBlack){ int a2 = width*width; int b2 = height*height; int fa2 = 4*a2, fb2 = 4*b2; @@ -329,14 +348,14 @@ } } -void GDEP015OC1::fillEllipse(uint16_t startX, uint16_t startY, uint16_t width, uint16_t height, bool color=0){ +void GDEP015OC1::fillEllipse(uint16_t startX, uint16_t startY, uint16_t width, uint16_t height, Color color=eBlack){ for(uint16_t w = width; w > 0; w--){ drawEllipse(startX, startX, w, height, color); } drawLine(startX, startY-height, startX, startY+height, color); } -void GDEP015OC1::writeChar(char character, uint16_t startX, uint16_t startY, bool color=0){ +void GDEP015OC1::writeChar(char character, uint16_t startX, uint16_t startY, Color color=eBlack){ unsigned char letter[FONT_WIDTH]; //Grab data for the corresponding font @@ -365,7 +384,7 @@ } } -void GDEP015OC1::writeString(char *string, uint16_t startX, uint16_t startY, bool color=0){ +void GDEP015OC1::writeString(char *string, uint16_t startX, uint16_t startY, Color color=eBlack){ uint8_t length = 0; while(*(string+length) != '\0') length++;