X-Git-Url: https://git.rohieb.name/hackover2013-badge-firmware.git/blobdiff_plain/1ee47540d67648bc4f9f530c62bc96f29b53e2f6..2f05268611277338f015e48c98b330078781172f:/drivers/lcd/tft/hw/ssd1331.c diff --git a/drivers/lcd/tft/hw/ssd1331.c b/drivers/lcd/tft/hw/ssd1331.c index 73b9654..a934ba2 100644 --- a/drivers/lcd/tft/hw/ssd1331.c +++ b/drivers/lcd/tft/hw/ssd1331.c @@ -145,19 +145,38 @@ void ssd1331SetCursor(uint8_t x, uint8_t y) /**************************************************************************/ void ssd1331DrawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint16_t color) { + uint16_t x, pixels; + if ((x1 >= ssd1331Properties.width) || (x2 >= ssd1331Properties.width) || (y1 >= ssd1331Properties.height) || (y2 >= ssd1331Properties.height)) { return; } + // Switch x2 and x1 if required + if (x2 < x1) + { + x = x2; + x2 = x1; + x1 = x; + } + + // Switch y2 and y1 if required + if (y2 < y1) + { + x = y2; + y2 = y1; + y1 = x; + } + CMD(SSD1331_CMD_DRAWLINE); CMD(x1); CMD(y1); CMD(x2); CMD(y2); - CMD((color >> 11) << 1); - CMD((color >> 5) & 0x3F); - CMD((color << 1)& 0x3F); + CMD((uint8_t)((color >> 11) & 0x1F)); + CMD((uint8_t)((color >> 5) & 0x3F)); + CMD((uint8_t)(color & 0x1F)); + } /**************************************************************************/ @@ -306,14 +325,14 @@ void lcdTest(void) { for(j=0;j<96;j++) { - if(i>55){DATA(invert565Color(COLOR_WHITE)>>8);DATA(invert565Color(COLOR_WHITE));} - else if(i>47){DATA(invert565Color(COLOR_BLUE)>>8);DATA(invert565Color(COLOR_BLUE));} - else if(i>39){DATA(invert565Color(COLOR_GREEN)>>8);DATA(invert565Color(COLOR_GREEN));} - else if(i>31){DATA(invert565Color(COLOR_CYAN)>>8);DATA(invert565Color(COLOR_CYAN));} - else if(i>23){DATA(invert565Color(COLOR_RED)>>8);DATA(invert565Color(COLOR_RED));} - else if(i>15){DATA(invert565Color(COLOR_MAGENTA)>>8);DATA(invert565Color(COLOR_MAGENTA));} - else if(i>7){DATA(invert565Color(COLOR_YELLOW)>>8);DATA(invert565Color(COLOR_YELLOW));} - else {DATA(invert565Color(COLOR_BLACK)>>8);DATA(invert565Color(COLOR_BLACK));} + if(i>55){DATA((uint8_t)COLOR_WHITE>>8);DATA((uint8_t)COLOR_WHITE);} + else if(i>47){DATA((uint8_t)COLOR_BLUE>>8);DATA((uint8_t)COLOR_BLUE);} + else if(i>39){DATA((uint8_t)COLOR_GREEN>>8);DATA((uint8_t)COLOR_GREEN);} + else if(i>31){DATA((uint8_t)COLOR_CYAN>>8);DATA((uint8_t)COLOR_CYAN);} + else if(i>23){DATA((uint8_t)COLOR_RED>>8);DATA((uint8_t)COLOR_RED);} + else if(i>15){DATA((uint8_t)COLOR_MAGENTA>>8);DATA((uint8_t)COLOR_MAGENTA);} + else if(i>7){DATA((uint8_t)COLOR_YELLOW>>8);DATA((uint8_t)COLOR_YELLOW);} + else {DATA((uint8_t)COLOR_BLACK>>8);DATA((uint8_t)COLOR_BLACK);} } } } @@ -325,7 +344,6 @@ void lcdTest(void) /**************************************************************************/ void lcdFillRGB(uint16_t data) { - data = invert565Color(data); ssd1331FillRect(0,0,ssd1331Properties.width-1,ssd1331Properties.height-1, data, data); } @@ -340,7 +358,6 @@ void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color) return; ssd1331SetCursor((uint8_t)x, (uint8_t)y); - color = invert565Color(color); DATA(color >> 8); DATA(color); } @@ -364,7 +381,6 @@ void lcdDrawPixels(uint16_t x, uint16_t y, uint16_t *data, uint32_t len) /**************************************************************************/ void lcdDrawHLine(uint16_t x0, uint16_t x1, uint16_t y, uint16_t color) { - color = invert565Color(color); ssd1331DrawLine((uint8_t)x0, (uint8_t)y, (uint8_t)x1, (uint8_t)y, color); } @@ -376,7 +392,6 @@ void lcdDrawHLine(uint16_t x0, uint16_t x1, uint16_t y, uint16_t color) /**************************************************************************/ void lcdDrawVLine(uint16_t x, uint16_t y0, uint16_t y1, uint16_t color) { - color = invert565Color(color); ssd1331DrawLine((uint8_t)x, (uint8_t)y0, (uint8_t)x, (uint8_t)y1, color); }