Improved color handling in Lua
LCD flags can now hold either a theme color index or a RGB value. Hence, values from lcd.RGB() and literal colors like e.g. RED, WHITE etc. can be used interchangeably with theme colors and CUSTOM_COLOR. Also redesigned drawText, drawNumber and drawTimer, so they now use a common function to implement the party tricks with BLINK and INVERS flags.
This commit is contained in:
committed by
Raphael Coeffic
parent
57e455d343
commit
9d878b71ce
@@ -42,24 +42,6 @@ enum LcdColorIndex
|
||||
COLOR_THEME_WARNING_INDEX,
|
||||
COLOR_THEME_DISABLED_INDEX,
|
||||
CUSTOM_COLOR_INDEX,
|
||||
|
||||
// Literal colors
|
||||
COLOR_BLACK_INDEX,
|
||||
COLOR_WHITE_INDEX,
|
||||
COLOR_LIGHTWHITE_INDEX,
|
||||
COLOR_YELLOW_INDEX,
|
||||
COLOR_BLUE_INDEX,
|
||||
COLOR_DARKBLUE_INDEX,
|
||||
COLOR_GREY_INDEX,
|
||||
COLOR_DARKGREY_INDEX,
|
||||
COLOR_LIGHTGREY_INDEX,
|
||||
COLOR_RED_INDEX,
|
||||
COLOR_DARKRED_INDEX,
|
||||
COLOR_GREEN_INDEX,
|
||||
COLOR_LIGHTBROWN_INDEX,
|
||||
COLOR_DARKBROWN_INDEX,
|
||||
COLOR_BRIGHTGREEN_INDEX,
|
||||
COLOR_ORANGE_INDEX,
|
||||
|
||||
// this one MUST be last
|
||||
LCD_COLOR_COUNT,
|
||||
@@ -90,6 +72,8 @@ enum LcdColorIndex
|
||||
#define BRIGHTGREEN RGB(0, 180, 60)
|
||||
#define ORANGE RGB(229, 100, 30)
|
||||
|
||||
#define RGB2FLAGS(r, g, b) (COLOR2FLAGS(RGB(r, g, b)) | RGB_FLAG)
|
||||
|
||||
//
|
||||
// Indexed colors
|
||||
//
|
||||
@@ -100,7 +84,7 @@ inline void lcdSetColor(uint16_t color)
|
||||
lcdColorTable[CUSTOM_COLOR_INDEX] = color;
|
||||
}
|
||||
|
||||
#define COLOR(index) ((uint32_t)lcdColorTable[unsigned(index) >= LCD_COLOR_COUNT ? CUSTOM_COLOR_INDEX : unsigned(index)] << 16u)
|
||||
#define COLOR(index) ((uint32_t)lcdColorTable[unsigned(index & 0xFF) >= LCD_COLOR_COUNT ? DEFAULT_COLOR_INDEX : unsigned(index & 0xFF)] << 16u)
|
||||
|
||||
#define COLOR_THEME_PRIMARY1 COLOR(COLOR_THEME_PRIMARY1_INDEX)
|
||||
#define COLOR_THEME_PRIMARY2 COLOR(COLOR_THEME_PRIMARY2_INDEX)
|
||||
|
||||
@@ -54,24 +54,7 @@ class Theme480: public OpenTxTheme
|
||||
lcdColorTable[COLOR_THEME_ACTIVE_INDEX] = RGB(255, 222, 0);
|
||||
lcdColorTable[COLOR_THEME_WARNING_INDEX] = RGB(224, 0, 0);
|
||||
lcdColorTable[COLOR_THEME_DISABLED_INDEX] = RGB(140, 140, 140);
|
||||
|
||||
// Literal colors
|
||||
lcdColorTable[COLOR_BLACK_INDEX] = BLACK;
|
||||
lcdColorTable[COLOR_WHITE_INDEX] = WHITE;
|
||||
lcdColorTable[COLOR_LIGHTWHITE_INDEX] = LIGHTWHITE;
|
||||
lcdColorTable[COLOR_YELLOW_INDEX] = YELLOW;
|
||||
lcdColorTable[COLOR_BLUE_INDEX] = BLUE;
|
||||
lcdColorTable[COLOR_DARKBLUE_INDEX] = DARKBLUE;
|
||||
lcdColorTable[COLOR_GREY_INDEX] = GREY;
|
||||
lcdColorTable[COLOR_DARKGREY_INDEX] = DARKGREY;
|
||||
lcdColorTable[COLOR_LIGHTGREY_INDEX] = LIGHTGREY;
|
||||
lcdColorTable[COLOR_RED_INDEX] = RED;
|
||||
lcdColorTable[COLOR_DARKRED_INDEX] = DARKRED;
|
||||
lcdColorTable[COLOR_GREEN_INDEX] = GREEN;
|
||||
lcdColorTable[COLOR_LIGHTBROWN_INDEX] = LIGHTBROWN;
|
||||
lcdColorTable[COLOR_DARKBROWN_INDEX] = DARKBROWN;
|
||||
lcdColorTable[COLOR_BRIGHTGREEN_INDEX] = BRIGHTGREEN;
|
||||
lcdColorTable[COLOR_ORANGE_INDEX] = ORANGE;
|
||||
lcdColorTable[CUSTOM_COLOR_INDEX] = RGB(170, 85, 0);
|
||||
}
|
||||
|
||||
void loadMenuIcon(uint8_t index, const uint8_t * lbm) const
|
||||
|
||||
@@ -53,24 +53,7 @@ class FlyskyTheme: public OpenTxTheme
|
||||
lcdColorTable[COLOR_THEME_ACTIVE_INDEX] = RGB(255, 222, 0);
|
||||
lcdColorTable[COLOR_THEME_WARNING_INDEX] = RGB(224, 0, 0);
|
||||
lcdColorTable[COLOR_THEME_DISABLED_INDEX] = RGB(140, 140, 140);
|
||||
|
||||
// Literal colors
|
||||
lcdColorTable[COLOR_BLACK_INDEX] = BLACK;
|
||||
lcdColorTable[COLOR_WHITE_INDEX] = WHITE;
|
||||
lcdColorTable[COLOR_LIGHTWHITE_INDEX] = LIGHTWHITE;
|
||||
lcdColorTable[COLOR_YELLOW_INDEX] = YELLOW;
|
||||
lcdColorTable[COLOR_BLUE_INDEX] = BLUE;
|
||||
lcdColorTable[COLOR_DARKBLUE_INDEX] = DARKBLUE;
|
||||
lcdColorTable[COLOR_GREY_INDEX] = GREY;
|
||||
lcdColorTable[COLOR_DARKGREY_INDEX] = DARKGREY;
|
||||
lcdColorTable[COLOR_LIGHTGREY_INDEX] = LIGHTGREY;
|
||||
lcdColorTable[COLOR_RED_INDEX] = RED;
|
||||
lcdColorTable[COLOR_DARKRED_INDEX] = DARKRED;
|
||||
lcdColorTable[COLOR_GREEN_INDEX] = GREEN;
|
||||
lcdColorTable[COLOR_LIGHTBROWN_INDEX] = LIGHTBROWN;
|
||||
lcdColorTable[COLOR_DARKBROWN_INDEX] = DARKBROWN;
|
||||
lcdColorTable[COLOR_BRIGHTGREEN_INDEX] = BRIGHTGREEN;
|
||||
lcdColorTable[COLOR_ORANGE_INDEX] = ORANGE;
|
||||
lcdColorTable[CUSTOM_COLOR_INDEX] = RGB(170, 85, 0);
|
||||
}
|
||||
|
||||
void loadMenuIcon(uint8_t index, const char * filename, uint32_t color=COLOR_THEME_SECONDARY1) const
|
||||
|
||||
Reference in New Issue
Block a user