Replace color format conversion macros with proper routines to prevent side effects with using the macro.
Also fix a number of compiler warnings.ugfx_release_2.6
parent
643670ecd1
commit
7f1b78a067
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -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 */
|
||||
/** @} */
|
||||
|
|
Loading…
Reference in New Issue