/**************************************************************************/
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));
+
}
/**************************************************************************/
{
for(j=0;j<96;j++)
{
- if(i>55){DATA(COLOR_WHITE>>8);DATA(COLOR_WHITE);}
- else if(i>47){DATA(COLOR_BLUE>>8);DATA(COLOR_BLUE);}
- else if(i>39){DATA(COLOR_GREEN>>8);DATA(COLOR_GREEN);}
- else if(i>31){DATA(COLOR_CYAN>>8);DATA(COLOR_CYAN);}
- else if(i>23){DATA(COLOR_RED>>8);DATA(COLOR_RED);}
- else if(i>15){DATA(COLOR_MAGENTA>>8);DATA(COLOR_MAGENTA);}
- else if(i>7){DATA(COLOR_YELLOW>>8);DATA(COLOR_YELLOW);}
- else {DATA(COLOR_BLACK>>8);DATA(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);}
}
}
}