Refactor (to clarify) foreground/background/frame color handling for N1600 display

This commit is contained in:
Henryk Plötz 2012-02-01 06:27:15 +01:00
parent e66910638d
commit 2fdab582be
1 changed files with 15 additions and 18 deletions

View File

@ -315,9 +315,12 @@ static void _helper_hline(uint16_t color){
_helper_pixel16(color); _helper_pixel16(color);
} }
#define THECOLOR_R 0x0 #define COLORPACK_RGB565(r,g,b) (((r&0xF8) << 8) | ((g&0xFC)<<3) | ((b&0xF8) >> 3))
#define THECOLOR_G 0x60
#define THECOLOR_B 0x0 static const uint16_t COLOR_FG = COLORPACK_RGB565(0x00, 0x60, 0x00);
static const uint16_t COLOR_BG = COLORPACK_RGB565(0xff, 0xff, 0xff);
static const uint16_t COLOR_FRAME = COLORPACK_RGB565(0x00, 0x00, 0x80);
void lcdDisplay(void) { void lcdDisplay(void) {
char byte; char byte;
@ -341,23 +344,15 @@ void lcdDisplay(void) {
} }
} }
} else { /* displayType==DISPLAY_TYPE_N1600 */ } else { /* displayType==DISPLAY_TYPE_N1600 */
unsigned char r=THECOLOR_R,g=THECOLOR_G,b=THECOLOR_B;
unsigned char br=0xFF, bg=0xFF, bb=0xFF;
unsigned char frame_r=0x00, frame_g=0x00, frame_b=0x80;
uint16_t color,framecolor,backcolor;
uint16_t x,y; uint16_t x,y;
bool px; bool px;
uint16_t actualcolor;
color = ((r&0xF8) << 8) | ((g&0xFC)<<3) | ((b&0xF8) >> 3);
framecolor= ((frame_r&0xF8) << 8) | ((frame_g&0xFC)<<3) | ((frame_b&0xF8) >> 3);
backcolor= ((br&0xF8) << 8) | ((bg&0xFC)<<3) | ((bb&0xF8) >> 3);
//top line of the frame... //top line of the frame...
_helper_hline(framecolor); _helper_hline(COLOR_FRAME);
for(y=RESY;y>0;y--){ for(y=RESY;y>0;y--){
//left line of the frame //left line of the frame
_helper_pixel16(framecolor); _helper_pixel16(COLOR_FRAME);
for(x=RESX;x>0;x--){ for(x=RESX;x>0;x--){
if(GLOBAL(lcdmirror)) if(GLOBAL(lcdmirror))
@ -365,17 +360,19 @@ void lcdDisplay(void) {
else else
px=lcdGetPixel(x-1,y-1); px=lcdGetPixel(x-1,y-1);
if((!px)^(!GLOBAL(lcdinvert))) actualcolor=color; if((!px)^(!GLOBAL(lcdinvert))) {
else actualcolor=backcolor; /* white */ _helper_pixel16(COLOR_FG); /* foreground */
} else {
_helper_pixel16(COLOR_BG); /* background */
}
_helper_pixel16(actualcolor);
} }
//right line of the frame //right line of the frame
_helper_pixel16(framecolor); _helper_pixel16(COLOR_FRAME);
} }
//bottom line of the frame //bottom line of the frame
_helper_hline(framecolor); _helper_hline(COLOR_FRAME);
} }
lcd_deselect(); lcd_deselect();
} }