aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2013-11-17 23:32:19 +1000
committerinmarket <andrewh@inmarket.com.au>2013-11-17 23:32:19 +1000
commit7f1b78a067e11c2394d83dbbc9b0fc78f78af493 (patch)
treecd49bed0ef2fb5469282f525c77e707620e7fbfb
parent643670ecd1c4dc631b4073d2384ff7fa56cb564d (diff)
downloaduGFX-7f1b78a067e11c2394d83dbbc9b0fc78f78af493.tar.gz
uGFX-7f1b78a067e11c2394d83dbbc9b0fc78f78af493.tar.bz2
uGFX-7f1b78a067e11c2394d83dbbc9b0fc78f78af493.zip
Replace color format conversion macros with proper routines to prevent side effects with using the macro.
Also fix a number of compiler warnings.
-rw-r--r--drivers/gdisp/ED060SC4/gdisp_lld_ED060SC4.c3
-rw-r--r--drivers/gdisp/HX8347D/gdisp_lld_HX8347D.c2
-rw-r--r--drivers/gdisp/ILI9320/gdisp_lld_ILI9320.c6
-rw-r--r--drivers/gdisp/ILI9325/gdisp_lld_ILI9325.c6
-rw-r--r--drivers/gdisp/ILI9341/gdisp_lld_ILI9341.c4
-rw-r--r--drivers/gdisp/ILI9481/gdisp_lld_ILI9481.c4
-rw-r--r--drivers/gdisp/Nokia6610GE12/gdisp_lld_Nokia6610GE12.c2
-rw-r--r--drivers/gdisp/Nokia6610GE8/gdisp_lld_Nokia6610GE8.c44
-rw-r--r--drivers/gdisp/RA8875/gdisp_lld_RA8875.c2
-rw-r--r--drivers/gdisp/S6D1121/gdisp_lld_S6D1121.c6
-rw-r--r--drivers/gdisp/SSD1289/gdisp_lld_SSD1289.c8
-rw-r--r--drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c4
-rw-r--r--drivers/gdisp/SSD1963/gdisp_lld_SSD1963.c2
-rw-r--r--drivers/gdisp/SSD2119/gdisp_lld_SSD2119.c8
-rw-r--r--drivers/gdisp/ST7565/gdisp_lld_ST7565.c4
-rw-r--r--drivers/multiple/Win32/gdisp_lld_Win32.c16
-rw-r--r--drivers/multiple/uGFXnet/gdisp_lld_uGFXnet.c8
-rw-r--r--include/gdisp/lld/gdisp_lld.h42
-rw-r--r--src/gdisp/gdisp.c39
19 files changed, 116 insertions, 94 deletions
diff --git a/drivers/gdisp/ED060SC4/gdisp_lld_ED060SC4.c b/drivers/gdisp/ED060SC4/gdisp_lld_ED060SC4.c
index 3ab1de79..166f564b 100644
--- a/drivers/gdisp/ED060SC4/gdisp_lld_ED060SC4.c
+++ b/drivers/gdisp/ED060SC4/gdisp_lld_ED060SC4.c
@@ -493,6 +493,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
uint8_t bitpos;
switch(g->g.Orientation) {
+ default:
case GDISP_ROTATE_0:
bx = g->p.x / EINK_BLOCKWIDTH;
dx = g->p.x % EINK_BLOCKWIDTH;
@@ -524,7 +525,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
bitpos = (6 - 2 * (dx % EINK_PPB));
byte = block->data[dy][dx / EINK_PPB];
byte &= ~(PIXELMASK << bitpos);
- if (COLOR2NATIVE(g->p.color) != Black)
+ if (gdispColor2Native(g->p.color) != Black)
byte |= PIXEL_WHITE << bitpos;
else
byte |= PIXEL_BLACK << bitpos;
diff --git a/drivers/gdisp/HX8347D/gdisp_lld_HX8347D.c b/drivers/gdisp/HX8347D/gdisp_lld_HX8347D.c
index 4514b495..88d3d19a 100644
--- a/drivers/gdisp/HX8347D/gdisp_lld_HX8347D.c
+++ b/drivers/gdisp/HX8347D/gdisp_lld_HX8347D.c
@@ -167,7 +167,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
busmode16(g);
}
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
- write_ram16(g, COLOR2NATIVE(g->p.color));
+ write_ram16(g, gdispColor2Native(g->p.color));
}
LLDSPEC void gdisp_lld_write_stop(GDisplay *g) {
busmode8(g);
diff --git a/drivers/gdisp/ILI9320/gdisp_lld_ILI9320.c b/drivers/gdisp/ILI9320/gdisp_lld_ILI9320.c
index e65e0a77..816d9956 100644
--- a/drivers/gdisp/ILI9320/gdisp_lld_ILI9320.c
+++ b/drivers/gdisp/ILI9320/gdisp_lld_ILI9320.c
@@ -60,6 +60,7 @@
static void set_cursor(GDisplay *g) {
switch(g->g.Orientation) {
+ default:
case GDISP_ROTATE_0:
case GDISP_ROTATE_180:
write_reg(g, 0x20, g->p.x);
@@ -77,6 +78,7 @@ static void set_cursor(GDisplay *g) {
static void set_viewport(GDisplay *g) {
switch(g->g.Orientation) {
+ default:
case GDISP_ROTATE_0:
case GDISP_ROTATE_180:
write_reg(g, 0x50, g->p.x);
@@ -204,7 +206,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
#endif
}
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
- write_data(g, COLOR2NATIVE(g->p.color));
+ write_data(g, gdispColor2Native(g->p.color));
}
LLDSPEC void gdisp_lld_write_stop(GDisplay *g) {
release_bus(g);
@@ -228,7 +230,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
uint16_t data;
data = read_data(g);
- return NATIVE2COLOR(data);
+ return gdispNative2Color(data);
}
LLDSPEC void gdisp_lld_read_stop(GDisplay *g) {
setwritemode(g);
diff --git a/drivers/gdisp/ILI9325/gdisp_lld_ILI9325.c b/drivers/gdisp/ILI9325/gdisp_lld_ILI9325.c
index ffd67cf7..0197a536 100644
--- a/drivers/gdisp/ILI9325/gdisp_lld_ILI9325.c
+++ b/drivers/gdisp/ILI9325/gdisp_lld_ILI9325.c
@@ -61,6 +61,7 @@
static void set_cursor(GDisplay *g) {
switch(g->g.Orientation) {
+ default:
case GDISP_ROTATE_0:
case GDISP_ROTATE_180:
write_reg(g, 0x20, g->p.x);
@@ -78,6 +79,7 @@ static void set_cursor(GDisplay *g) {
static void set_viewport(GDisplay* g) {
switch(g->g.Orientation) {
+ default:
case GDISP_ROTATE_0:
case GDISP_ROTATE_180:
write_reg(g, 0x50, g->p.x);
@@ -200,7 +202,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
set_viewport(g);
}
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
- write_data(g, COLOR2NATIVE(g->p.color));
+ write_data(g, gdispColor2Native(g->p.color));
}
LLDSPEC void gdisp_lld_write_stop(GDisplay *g) {
release_bus(g);
@@ -222,7 +224,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
uint16_t data;
data = read_data(g);
- return NATIVE2COLOR(data);
+ return gdispNative2Color(data);
}
LLDSPEC void gdisp_lld_read_stop(GDisplay *g) {
setwritemode(g);
diff --git a/drivers/gdisp/ILI9341/gdisp_lld_ILI9341.c b/drivers/gdisp/ILI9341/gdisp_lld_ILI9341.c
index 2513c48d..f4781059 100644
--- a/drivers/gdisp/ILI9341/gdisp_lld_ILI9341.c
+++ b/drivers/gdisp/ILI9341/gdisp_lld_ILI9341.c
@@ -246,7 +246,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
write_index(g, 0x2C);
}
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
- write_data16(g, COLOR2NATIVE(g->p.color));
+ write_data16(g, gdispColor2Native(g->p.color));
}
LLDSPEC void gdisp_lld_write_stop(GDisplay *g) {
release_bus(g);
@@ -265,7 +265,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
uint16_t data;
data = read_data(g);
- return NATIVE2COLOR(data);
+ return gdispNative2Color(data);
}
LLDSPEC void gdisp_lld_read_stop(GDisplay *g) {
setwritemode(g);
diff --git a/drivers/gdisp/ILI9481/gdisp_lld_ILI9481.c b/drivers/gdisp/ILI9481/gdisp_lld_ILI9481.c
index 2b2f0917..c96faf33 100644
--- a/drivers/gdisp/ILI9481/gdisp_lld_ILI9481.c
+++ b/drivers/gdisp/ILI9481/gdisp_lld_ILI9481.c
@@ -211,7 +211,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
set_viewport(g);
}
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
- write_data(g, COLOR2NATIVE(g->p.color));
+ write_data(g, gdispColor2Native(g->p.color));
}
LLDSPEC void gdisp_lld_write_stop(GDisplay *g) {
release_bus(g);
@@ -229,7 +229,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
uint16_t data;
data = read_data(g);
- return NATIVE2COLOR(data);
+ return gdispNative2Color(data);
}
LLDSPEC void gdisp_lld_read_stop(GDisplay *g) {
setwritemode(g);
diff --git a/drivers/gdisp/Nokia6610GE12/gdisp_lld_Nokia6610GE12.c b/drivers/gdisp/Nokia6610GE12/gdisp_lld_Nokia6610GE12.c
index 28a2fceb..261f6f66 100644
--- a/drivers/gdisp/Nokia6610GE12/gdisp_lld_Nokia6610GE12.c
+++ b/drivers/gdisp/Nokia6610GE12/gdisp_lld_Nokia6610GE12.c
@@ -145,7 +145,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
uint16_t c;
- c = COLOR2NATIVE(g->p.color);
+ c = gdispColor2Native(g->p.color);
if ((g->flags & GDISP_FLG_ODDBYTE)) {
// Write the pair of pixels to the display
write_data3(g, ((savecolor(g) >> 4) & 0xFF),
diff --git a/drivers/gdisp/Nokia6610GE8/gdisp_lld_Nokia6610GE8.c b/drivers/gdisp/Nokia6610GE8/gdisp_lld_Nokia6610GE8.c
index f6ce4278..afb060c1 100644
--- a/drivers/gdisp/Nokia6610GE8/gdisp_lld_Nokia6610GE8.c
+++ b/drivers/gdisp/Nokia6610GE8/gdisp_lld_Nokia6610GE8.c
@@ -139,22 +139,23 @@
static inline void set_viewport(GDisplay* g) {
#if GDISP_NOKIA_ORIENTATION && GDISP_NEED_CONTROL
switch(g->g.Orientation) {
- case GDISP_ROTATE_0:
- write_cmd2(g, CASET, GDISP_RAM_X_OFFSET+g->p.x, GDISP_RAM_X_OFFSET+g->p.x); // Column address set
- write_cmd2(g, PASET, GDISP_RAM_Y_OFFSET+g->p.y, GDISP_RAM_Y_OFFSET+g->p.y); // Page address set
- break;
- case GDISP_ROTATE_90:
- write_cmd2(g, CASET, GDISP_RAM_X_OFFSET+g->p.y, GDISP_RAM_X_OFFSET+g->p.y);
- write_cmd2(g, PASET, GDISP_RAM_Y_OFFSET-1+g->g.Width-g->p.x, GDISP_RAM_Y_OFFSET-1+g->g.Width-g->p.x);
- break;
- case GDISP_ROTATE_180:
- write_cmd2(g, CASET, GDISP_RAM_X_OFFSET-1+g->g.Width-g->p.x, GDISP_RAM_X_OFFSET-1+g->g.Width-g->p.x);
- write_cmd2(g, PASET, GDISP_RAM_Y_OFFSET-1+g->g.Height-g->p.y, GDISP_RAM_Y_OFFSET-1+g->g.Height-g->p.y);
- break;
- case GDISP_ROTATE_270:
- write_cmd2(g, CASET, GDISP_RAM_X_OFFSET-1+g->g.Height-g->p.y, GDISP_RAM_X_OFFSET-1+g->g.Height-g->p.y);
- write_cmd2(g, PASET, GDISP_RAM_Y_OFFSET+g->p.x, GDISP_RAM_Y_OFFSET+g->p.x);
- break;
+ default:
+ case GDISP_ROTATE_0:
+ write_cmd2(g, CASET, GDISP_RAM_X_OFFSET+g->p.x, GDISP_RAM_X_OFFSET+g->p.x); // Column address set
+ write_cmd2(g, PASET, GDISP_RAM_Y_OFFSET+g->p.y, GDISP_RAM_Y_OFFSET+g->p.y); // Page address set
+ break;
+ case GDISP_ROTATE_90:
+ write_cmd2(g, CASET, GDISP_RAM_X_OFFSET+g->p.y, GDISP_RAM_X_OFFSET+g->p.y);
+ write_cmd2(g, PASET, GDISP_RAM_Y_OFFSET-1+g->g.Width-g->p.x, GDISP_RAM_Y_OFFSET-1+g->g.Width-g->p.x);
+ break;
+ case GDISP_ROTATE_180:
+ write_cmd2(g, CASET, GDISP_RAM_X_OFFSET-1+g->g.Width-g->p.x, GDISP_RAM_X_OFFSET-1+g->g.Width-g->p.x);
+ write_cmd2(g, PASET, GDISP_RAM_Y_OFFSET-1+g->g.Height-g->p.y, GDISP_RAM_Y_OFFSET-1+g->g.Height-g->p.y);
+ break;
+ case GDISP_ROTATE_270:
+ write_cmd2(g, CASET, GDISP_RAM_X_OFFSET-1+g->g.Height-g->p.y, GDISP_RAM_X_OFFSET-1+g->g.Height-g->p.y);
+ write_cmd2(g, PASET, GDISP_RAM_Y_OFFSET+g->p.x, GDISP_RAM_Y_OFFSET+g->p.x);
+ break;
}
#else
write_cmd2(g, CASET, GDISP_RAM_X_OFFSET+g->p.x, GDISP_RAM_X_OFFSET+g->p.x+g->p.cx-1); // Column address set
@@ -233,7 +234,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
uint16_t c;
- c = COLOR2NATIVE(g->p.color);
+ c = gdispColor2Native(g->p.color);
#if GDISP_GE8_BROKEN_CONTROLLER
if (!(g->flags & GDISP_FLG_RUNBYTE)) {
PRIV->firstcolor = c;
@@ -289,7 +290,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
uint16_t c;
- c = COLOR2NATIVE(g->p.color);
+ c = gdispColor2Native(g->p.color);
acquire_bus(g);
set_viewport(g);
write_data3(g, 0, (c>>8) & 0x0F, c & 0xFF);
@@ -307,7 +308,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
tuples = (g->p.cx*g->p.cy+1)>>1; // With an odd sized area we over-print by one pixel.
// This extra pixel overwrites the first pixel (harmless as it is the same colour)
- c = COLOR2NATIVE(g->p.color);
+ c = gdispColor2Native(g->p.color);
acquire_bus(g);
set_viewport(g);
while(tuples--)
@@ -348,6 +349,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
* to column cx-1, cx-2 etc. We therefore have to write-out the last bitmap line first.
*/
switch(g->g.Orientation) {
+ default:
case GDISP_ROTATE_0: x = 0; y = 0; break;
case GDISP_ROTATE_90: x = g->p.cx-1; y = 0; break;
case GDISP_ROTATE_180: x = g->p.cx-1; y = g->p.cy-1; break;
@@ -364,7 +366,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
while(tuples--) {
/* Get a pixel */
- c1 = COLOR2NATIVE(*p++);
+ c1 = gdispColor2Native(*p++);
/* Check for line or buffer wrapping */
if (++x >= g->p.cx) {
@@ -377,7 +379,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
}
/* Get the next pixel */
- c2 = COLOR2NATIVE(*p++);
+ c2 = gdispColor2Native(*p++);
/* Check for line or buffer wrapping */
if (++x >= g->p.cx) {
diff --git a/drivers/gdisp/RA8875/gdisp_lld_RA8875.c b/drivers/gdisp/RA8875/gdisp_lld_RA8875.c
index d28670c6..e3fee636 100644
--- a/drivers/gdisp/RA8875/gdisp_lld_RA8875.c
+++ b/drivers/gdisp/RA8875/gdisp_lld_RA8875.c
@@ -184,7 +184,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
set_viewport(g);
}
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
- write_data(g, COLOR2NATIVE(g->p.color));
+ write_data(g, gdispColor2Native(g->p.color));
}
LLDSPEC void gdisp_lld_write_stop(GDisplay *g) {
release_bus(g);
diff --git a/drivers/gdisp/S6D1121/gdisp_lld_S6D1121.c b/drivers/gdisp/S6D1121/gdisp_lld_S6D1121.c
index cca9d67e..78b659de 100644
--- a/drivers/gdisp/S6D1121/gdisp_lld_S6D1121.c
+++ b/drivers/gdisp/S6D1121/gdisp_lld_S6D1121.c
@@ -64,6 +64,7 @@ static inline void set_cursor(GDisplay *g) {
* R21h - 9 bit
*/
switch(g->g.Orientation) {
+ default:
case GDISP_ROTATE_0:
write_reg(g, 0x20, g->p.x & 0x00FF);
write_reg(g, 0x21, g->p.y & 0x01FF);
@@ -91,6 +92,7 @@ static inline void set_viewport(GDisplay *g) {
*/
switch(g->g.Orientation) {
+ default:
case GDISP_ROTATE_0:
write_reg(g, 0x46, (((g->p.x + g->p.cx - 1) << 8) & 0xFF00 ) | (g->p.x & 0x00FF));
write_reg(g, 0x48, g->p.y & 0x01FF);
@@ -221,7 +223,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
set_viewport(g);
}
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
- write_data(g, COLOR2NATIVE(g->p.color));
+ write_data(g, gdispColor2Native(g->p.color));
}
LLDSPEC void gdisp_lld_write_stop(GDisplay *g) {
release_bus(g);
@@ -243,7 +245,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
uint16_t data;
data = read_data(g);
- return NATIVE2COLOR(data);
+ return gdispNative2Color(data);
}
LLDSPEC void gdisp_lld_read_stop(GDisplay *g) {
setwritemode(g);
diff --git a/drivers/gdisp/SSD1289/gdisp_lld_SSD1289.c b/drivers/gdisp/SSD1289/gdisp_lld_SSD1289.c
index d96f9479..79ac7dd9 100644
--- a/drivers/gdisp/SSD1289/gdisp_lld_SSD1289.c
+++ b/drivers/gdisp/SSD1289/gdisp_lld_SSD1289.c
@@ -52,6 +52,7 @@ static void set_cursor(GDisplay *g) {
* Use a bit mask to make sure they are not set too high
*/
switch(g->g.Orientation) {
+ default:
case GDISP_ROTATE_0:
write_reg(g, 0x4e, g->p.x & 0x00FF);
write_reg(g, 0x4f, g->p.y & 0x01FF);
@@ -83,6 +84,7 @@ static void set_viewport(GDisplay* g) {
* Use a bit mask to make sure they are not set too high
*/
switch(g->g.Orientation) {
+ default:
case GDISP_ROTATE_0:
write_reg(g, 0x44, (((g->p.x+g->p.cx-1) << 8) & 0xFF00 ) | (g->p.x & 0x00FF));
write_reg(g, 0x45, g->p.y & 0x01FF);
@@ -200,7 +202,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
#endif
}
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
- write_data(g, COLOR2NATIVE(g->p.color));
+ write_data(g, gdispColor2Native(g->p.color));
}
LLDSPEC void gdisp_lld_write_stop(GDisplay *g) {
release_bus(g);
@@ -224,7 +226,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
uint16_t data;
data = read_data(g);
- return NATIVE2COLOR(data);
+ return gdispNative2Color(data);
}
LLDSPEC void gdisp_lld_read_stop(GDisplay *g) {
setwritemode(g);
@@ -236,7 +238,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
LLDSPEC void gdisp_lld_fill_area(GDisplay *g) {
uint16_t c;
- c = COLOR2NATIVE(g->p.color);
+ c = gdispColor2Native(g->p.color);
acquire_bus(g);
set_viewport(g);
set_cursor(g);
diff --git a/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c b/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c
index b72ba781..b7bce1e2 100644
--- a/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c
+++ b/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c
@@ -159,6 +159,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
coord_t x, y;
switch(g->g.Orientation) {
+ default:
case GDISP_ROTATE_0:
x = g->p.x;
y = g->p.y;
@@ -176,7 +177,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
x = g->p.x;
break;
}
- if (COLOR2NATIVE(g->p.color) != Black)
+ if (gdispColor2Native(g->p.color) != Black)
RAM(g)[xyaddr(x, y)] |= xybit(y);
else
RAM(g)[xyaddr(x, y)] &= ~xybit(y);
@@ -189,6 +190,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
coord_t x, y;
switch(g->g.Orientation) {
+ default:
case GDISP_ROTATE_0:
x = g->p.x;
y = g->p.y;
diff --git a/drivers/gdisp/SSD1963/gdisp_lld_SSD1963.c b/drivers/gdisp/SSD1963/gdisp_lld_SSD1963.c
index eb1b9b15..e1924c2d 100644
--- a/drivers/gdisp/SSD1963/gdisp_lld_SSD1963.c
+++ b/drivers/gdisp/SSD1963/gdisp_lld_SSD1963.c
@@ -188,7 +188,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
set_viewport(g);
}
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
- write_data(g, COLOR2NATIVE(g->p.color));
+ write_data(g, gdispColor2Native(g->p.color));
}
LLDSPEC void gdisp_lld_write_stop(GDisplay *g) {
release_bus(g);
diff --git a/drivers/gdisp/SSD2119/gdisp_lld_SSD2119.c b/drivers/gdisp/SSD2119/gdisp_lld_SSD2119.c
index 9594ff95..a58d2973 100644
--- a/drivers/gdisp/SSD2119/gdisp_lld_SSD2119.c
+++ b/drivers/gdisp/SSD2119/gdisp_lld_SSD2119.c
@@ -53,6 +53,7 @@ static void set_cursor(GDisplay* g) {
* Use a bit mask to make sure they are not set too high
*/
switch(g->g.Orientation) {
+ default:
case GDISP_ROTATE_0:
write_reg(g, SSD2119_REG_X_RAM_ADDR, g->p.x & 0x01FF);
write_reg(g, SSD2119_REG_Y_RAM_ADDR, g->p.y & 0x00FF);
@@ -83,6 +84,7 @@ static void set_viewport(GDisplay* g) {
* 0 <= HSA <= HEA <= 0x13F
*/
switch(g->g.Orientation) {
+ default:
case GDISP_ROTATE_0:
write_reg(g, SSD2119_REG_V_RAM_POS, (((g->p.y + g->p.cy - 1) << 8) & 0xFF00 ) | (g->p.y & 0x00FF));
write_reg(g, SSD2119_REG_H_RAM_START, (g->p.x & 0x01FF));
@@ -238,7 +240,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay* g) {
set_viewport(g);
}
LLDSPEC void gdisp_lld_write_color(GDisplay* g) {
- write_data(g, COLOR2NATIVE(g->p.color));
+ write_data(g, gdispColor2Native(g->p.color));
}
LLDSPEC void gdisp_lld_write_stop(GDisplay* g) {
release_bus(g);
@@ -260,7 +262,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay* g) {
uint16_t data;
data = read_data(g);
- return NATIVE2COLOR(data);
+ return gdispNative2Color(data);
}
LLDSPEC void gdisp_lld_read_stop(GDisplay* g) {
setwritemode(g);
@@ -272,7 +274,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay* g) {
LLDSPEC void gdisp_lld_fill_area(GDisplay* g) {
uint16_t c;
- c = COLOR2NATIVE(g->p.color);
+ c = gdispColor2Native(g->p.color);
acquire_bus(g);
set_viewport(g);
set_cursor(g);
diff --git a/drivers/gdisp/ST7565/gdisp_lld_ST7565.c b/drivers/gdisp/ST7565/gdisp_lld_ST7565.c
index 2bb5406f..769f2eaf 100644
--- a/drivers/gdisp/ST7565/gdisp_lld_ST7565.c
+++ b/drivers/gdisp/ST7565/gdisp_lld_ST7565.c
@@ -150,6 +150,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
coord_t x, y;
switch(g->g.Orientation) {
+ default:
case GDISP_ROTATE_0:
x = g->p.x;
y = g->p.y;
@@ -167,7 +168,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
y = g->p.x;
break;
}
- if (COLOR2NATIVE(g->p.color) != Black)
+ if (gdispColor2Native(g->p.color) != Black)
RAM(g)[xyaddr(x, y)] |= xybit(y);
else
RAM(g)[xyaddr(x, y)] &= ~xybit(y);
@@ -180,6 +181,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
coord_t x, y;
switch(g->g.Orientation) {
+ default:
case GDISP_ROTATE_0:
x = g->p.x;
y = g->p.y;
diff --git a/drivers/multiple/Win32/gdisp_lld_Win32.c b/drivers/multiple/Win32/gdisp_lld_Win32.c
index 50f259b7..adeed579 100644
--- a/drivers/multiple/Win32/gdisp_lld_Win32.c
+++ b/drivers/multiple/Win32/gdisp_lld_Win32.c
@@ -286,9 +286,9 @@ static LRESULT myWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
// Paint the toggle area
#if GINPUT_NEED_TOGGLE
if (ps.rcPaint.bottom >= GDISP_SCREEN_HEIGHT && (g->flags & GDISP_FLG_HASTOGGLE)) {
- pen = CreatePen(PS_SOLID, 1, COLOR2NATIVE(Black));
- hbrOn = CreateSolidBrush(COLOR2NATIVE(Blue));
- hbrOff = CreateSolidBrush(COLOR2NATIVE(Gray));
+ pen = CreatePen(PS_SOLID, 1, gdispColor2Native(Black));
+ hbrOn = CreateSolidBrush(gdispColor2Native(Blue));
+ hbrOff = CreateSolidBrush(gdispColor2Native(Gray));
old = SelectObject(dc, pen);
MoveToEx(dc, 0, GDISP_SCREEN_HEIGHT, &p);
LineTo(dc, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT);
@@ -514,7 +514,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
COLORREF color;
priv = g->priv;
- color = COLOR2NATIVE(g->p.color);
+ color = gdispColor2Native(g->p.color);
if (!(g->flags & GDISP_FLG_WSTREAM))
BAD_PARAMETER("write_color: not in streaming mode");
@@ -664,7 +664,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
}
}
- return NATIVE2COLOR(color);
+ return gdispNative2Color(color);
}
LLDSPEC void gdisp_lld_read_stop(GDisplay *g) {
if (!(g->flags & GDISP_FLG_WSTREAM))
@@ -680,7 +680,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
COLORREF color;
priv = g->priv;
- color = COLOR2NATIVE(g->p.color);
+ color = gdispColor2Native(g->p.color);
#if GDISP_NEED_CONTROL
switch(g->g.Orientation) {
@@ -740,7 +740,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
COLORREF color;
priv = g->priv;
- color = COLOR2NATIVE(g->p.color);
+ color = gdispColor2Native(g->p.color);
hbr = CreateSolidBrush(color);
#if GDISP_NEED_CONTROL
@@ -975,7 +975,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
#endif
ReleaseMutex(drawMutex);
- return NATIVE2COLOR(color);
+ return gdispNative2Color(color);
}
#endif
diff --git a/drivers/multiple/uGFXnet/gdisp_lld_uGFXnet.c b/drivers/multiple/uGFXnet/gdisp_lld_uGFXnet.c
index b694358c..81e5d19b 100644
--- a/drivers/multiple/uGFXnet/gdisp_lld_uGFXnet.c
+++ b/drivers/multiple/uGFXnet/gdisp_lld_uGFXnet.c
@@ -425,7 +425,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
buf[0] = GNETCODE_PIXEL;
buf[1] = g->p.x;
buf[2] = g->p.y;
- buf[3] = COLOR2NATIVE(g->p.color);
+ buf[3] = gdispColor2Native(g->p.color);
MUTEX_ENTER;
sendpkt(priv->netfd, buf, 4);
MUTEX_EXIT;
@@ -453,7 +453,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
buf[2] = g->p.y;
buf[3] = g->p.cx;
buf[4] = g->p.cy;
- buf[5] = COLOR2NATIVE(g->p.color);
+ buf[5] = gdispColor2Native(g->p.color);
MUTEX_ENTER;
sendpkt(priv->netfd, buf, 6);
MUTEX_EXIT;
@@ -490,7 +490,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
for(y = 0; y < g->p.cy; y++, buffer += g->p.x2 - g->p.cx) {
for(x = 0; x < g->p.cx; x++, buffer++) {
- buf[0] = COLOR2NATIVE(buffer[0]);
+ buf[0] = gdispColor2Native(buffer[0]);
sendpkt(priv->netfd, buf, 1);
}
}
@@ -524,7 +524,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
while(!(g->flags & GDISP_FLG_HAVEDATA) || priv->data[0] != GNETCODE_READ)
gfxSleepMilliseconds(1);
- data = NATIVE2COLOR(priv->data[1]);
+ data = gdispNative2Color(priv->data[1]);
g->flags &= ~GDISP_FLG_HAVEDATA;
return data;
diff --git a/include/gdisp/lld/gdisp_lld.h b/include/gdisp/lld/gdisp_lld.h
index e48443e9..e4f9ece2 100644
--- a/include/gdisp/lld/gdisp_lld.h
+++ b/include/gdisp/lld/gdisp_lld.h
@@ -856,52 +856,18 @@ struct GDisplay {
* @brief Convert from a standard color format to the low level driver pixel format
* @note For use only by low level drivers
*/
- #define COLOR2NATIVE(c) (c)
+ #define gdispColor2Native(c) (c)
/**
* @brief Convert from a low level driver pixel format to the standard color format
* @note For use only by low level drivers
*/
- #define NATIVE2COLOR(c) (c)
-
+ #define gdispNative2Color(c) (c)
#else
- #if COLOR_SYSTEM == GDISP_COLORSYSTEM_GRAYSCALE || LLDCOLOR_SYSTEM == GDISP_COLORSYSTEM_GRAYSCALE
- #if GDISP_HARDWARE_USE_EXACT_COLOR
- #define COLOR2NATIVE(c) LLDLUMA2COLOR(EXACT_LUMA_OF(c))
- #define NATIVE2COLOR(c) LUMA2COLOR(LLDEXACT_LUMA_OF(c))
- #else
- #define COLOR2NATIVE(c) LLDLUMA2COLOR(LUMA_OF(c))
- #define NATIVE2COLOR(c) LUMA2COLOR(LLDLUMA_OF(c))
- #endif
- #elif COLOR_SYSTEM == GDISP_COLORSYSTEM_TRUECOLOR && LLDCOLOR_SYSTEM == GDISP_COLORSYSTEM_TRUECOLOR
- #if GDISP_HARDWARE_USE_EXACT_COLOR
- #define COLOR2NATIVE(c) LLDRGB2COLOR(EXACT_RED_OF(c), EXACT_GREEN_OF(c), EXACT_BLUE_OF(c))
- #define NATIVE2COLOR(c) RGB2COLOR(LLDEXACT_RED_OF(c), LLDEXACT_GREEN_OF(c), LLDEXACT_BLUE_OF(c))
- #else
- #define COLOR2NATIVE(c) LLDRGB2COLOR(RED_OF(c), GREEN_OF(c), BLUE_OF(c))
- #define NATIVE2COLOR(c) RGB2COLOR(LLDRED_OF(c), LLDGREEN_OF(c), LLDBLUE_OF(c))
- #endif
-
- /*
- #elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB888 && GDISP_LLD_PIXELFORMAT == GDISP_PIXELFORMAT_BGR888
- #define COLOR2NATIVE(c) ((LLDCOLOR_TYPE)(((c)&0xFF0000)>>16)|((c)&0x00FF00)|(((c)&0x0000FF)<<16))
- #define NATIVE2COLOR(c) ((COLOR_TYPE)(((c)&0xFF0000)>>16)|((c)&0x00FF00)|(((c)&0x0000FF)<<16))
- #elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB565 && GDISP_LLD_PIXELFORMAT == GDISP_PIXELFORMAT_BGR888
- #define COLOR2NATIVE(c) ((LLDCOLOR_TYPE)( \
- ((LARGER_COLOR_TYPE)((c)&(((1<<COLOR_BITS_R)-1)<<COLOR_SHIFT_R))>>(COLOR_BITS_R+COLOR_SHIFT_R-8))| \
- ((LARGER_COLOR_TYPE)((c)&(((1<<COLOR_BITS_G)-1)<<COLOR_SHIFT_G))<<(16-(COLOR_BITS_G+COLOR_SHIFT_G)))| \
- ((LARGER_COLOR_TYPE)((c)&(((1<<COLOR_BITS_B)-1)<<COLOR_SHIFT_B))<<(24-(COLOR_BITS_B+COLOR_SHIFT_B)))))
- #define NATIVE2COLOR(c) ((COLOR_TYPE)( \
- ((LARGER_COLOR_TYPE)((c)&0x0000F8)<<COLOR_SHIFT_R)| \
- ((LARGER_COLOR_TYPE)((c)&0x00FC00)>>(16-(COLOR_BITS_G+COLOR_SHIFT_G)))| \
- ((LARGER_COLOR_TYPE)((c)&0xF80000)>>(24-(COLOR_BITS_B+COLOR_SHIFT_B)))))
- */
- #else
- #error "GDISP: This pixel format conversion is not supported yet"
- #endif
+ LLDCOLOR_TYPE gdispColor2Native(color_t c);
+ color_t gdispNative2Color(LLDCOLOR_TYPE c);
#endif
#endif /* GFX_USE_GDISP */
#endif /* _GDISP_LLD_H */
/** @} */
-
diff --git a/src/gdisp/gdisp.c b/src/gdisp/gdisp.c
index 99af5afa..1eb5a41b 100644
--- a/src/gdisp/gdisp.c
+++ b/src/gdisp/gdisp.c
@@ -2825,6 +2825,45 @@ color_t gdispBlendColor(color_t fg, color_t bg, uint8_t alpha)
}
#endif
+#if GDISP_PIXELFORMAT != GDISP_LLD_PIXELFORMAT
+ LLDCOLOR_TYPE gdispColor2Native(color_t c) {
+ #if COLOR_SYSTEM == GDISP_COLORSYSTEM_GRAYSCALE || LLDCOLOR_SYSTEM == GDISP_COLORSYSTEM_GRAYSCALE
+ #if GDISP_HARDWARE_USE_EXACT_COLOR
+ return LLDLUMA2COLOR(EXACT_LUMA_OF(c));
+ #else
+ return LLDLUMA2COLOR(LUMA_OF(c));
+ #endif
+ #elif COLOR_SYSTEM == GDISP_COLORSYSTEM_TRUECOLOR && LLDCOLOR_SYSTEM == GDISP_COLORSYSTEM_TRUECOLOR
+ #if GDISP_HARDWARE_USE_EXACT_COLOR
+ return LLDRGB2COLOR(EXACT_RED_OF(c), EXACT_GREEN_OF(c), EXACT_BLUE_OF(c));
+ #else
+ return LLDRGB2COLOR(RED_OF(c), GREEN_OF(c), BLUE_OF(c));
+ #endif
+ #else
+ #error "GDISP: This pixel format conversion is not supported yet"
+ #endif
+ }
+#endif
+
+#if GDISP_PIXELFORMAT != GDISP_LLD_PIXELFORMAT
+ color_t gdispNative2Color(LLDCOLOR_TYPE c) {
+ #if COLOR_SYSTEM == GDISP_COLORSYSTEM_GRAYSCALE || LLDCOLOR_SYSTEM == GDISP_COLORSYSTEM_GRAYSCALE
+ #if GDISP_HARDWARE_USE_EXACT_COLOR
+ return LUMA2COLOR(LLDEXACT_LUMA_OF(c));
+ #else
+ return LUMA2COLOR(LLDLUMA_OF(c));
+ #endif
+ #elif COLOR_SYSTEM == GDISP_COLORSYSTEM_TRUECOLOR && LLDCOLOR_SYSTEM == GDISP_COLORSYSTEM_TRUECOLOR
+ #if GDISP_HARDWARE_USE_EXACT_COLOR
+ return RGB2COLOR(LLDEXACT_RED_OF(c), LLDEXACT_GREEN_OF(c), LLDEXACT_BLUE_OF(c));
+ #else
+ return RGB2COLOR(LLDRED_OF(c), LLDGREEN_OF(c), LLDBLUE_OF(c));
+ #endif
+ #else
+ #error "GDISP: This pixel format conversion is not supported yet"
+ #endif
+ }
+#endif
#endif /* GFX_USE_GDISP */
/** @} */