feat(bw128): add option to invert LCD/OLED display (#4933)
This commit is contained in:
@@ -979,8 +979,11 @@ PACK(struct RadioData {
|
||||
|
||||
#if defined(COLORLCD)
|
||||
NOBACKUP(uint8_t space:7 SKIP);
|
||||
#elif LCD_W == 128
|
||||
uint8_t invertLCD:1; // Invert B&W LCD display
|
||||
NOBACKUP(uint8_t spare:4 SKIP);
|
||||
#else
|
||||
NOBACKUP(uint8_t space:5 SKIP);
|
||||
NOBACKUP(uint8_t spare:5 SKIP);
|
||||
#endif
|
||||
|
||||
NOBACKUP(uint8_t getBrightness() const
|
||||
|
||||
@@ -80,6 +80,10 @@ enum {
|
||||
ITEM_RADIO_HARDWARE_JITTER_FILTER,
|
||||
ITEM_RADIO_HARDWARE_RAS,
|
||||
ITEM_RADIO_HARDWARE_SPORT_UPDATE_POWER,
|
||||
#if (defined(BACKLIGHT_GPIO) || defined(OLED_SCREEN)) && (LCD_W == 128)
|
||||
ITEM_RADIO_HARDWARE_SCREEN_LABEL,
|
||||
ITEM_RADIO_HARDWARE_SCREEN_INVERT,
|
||||
#endif
|
||||
ITEM_RADIO_HARDWARE_DEBUG,
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
ITEM_RADIO_HARDWARE_DEBUG_FS,
|
||||
@@ -211,6 +215,11 @@ static void _init_menu_tab_array(uint8_t* tab, size_t len)
|
||||
tab[ITEM_RADIO_HARDWARE_SPORT_UPDATE_POWER] = HIDDEN_ROW;
|
||||
}
|
||||
|
||||
#if (defined(BACKLIGHT_GPIO) || defined(OLED_SCREEN)) && (LCD_W == 128)
|
||||
tab[ITEM_RADIO_HARDWARE_SCREEN_LABEL] = READONLY_ROW;
|
||||
tab[ITEM_RADIO_HARDWARE_SCREEN_INVERT] = 0;
|
||||
#endif
|
||||
|
||||
tab[ITEM_RADIO_HARDWARE_DEBUG] = 1;
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
tab[ITEM_RADIO_HARDWARE_DEBUG_FS] = 0;
|
||||
@@ -425,6 +434,21 @@ void menuRadioHardware(event_t event)
|
||||
}
|
||||
break;
|
||||
|
||||
#if (defined(BACKLIGHT_GPIO) || defined(OLED_SCREEN)) && (LCD_W == 128)
|
||||
case ITEM_RADIO_HARDWARE_SCREEN_LABEL:
|
||||
lcdDrawTextAlignedLeft(y, STR_SCREEN);
|
||||
break;
|
||||
case ITEM_RADIO_HARDWARE_SCREEN_INVERT:
|
||||
{
|
||||
lcdDrawText(INDENT_WIDTH, y, STR_MENU_INVERT);
|
||||
bool inv = g_eeGeneral.invertLCD;
|
||||
g_eeGeneral.invertLCD = editCheckBox(g_eeGeneral.invertLCD, HW_SETTINGS_COLUMN2, y, nullptr, attr, event);
|
||||
if (inv != g_eeGeneral.invertLCD)
|
||||
lcdSetInvert(g_eeGeneral.invertLCD);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case ITEM_RADIO_HARDWARE_DEBUG:
|
||||
lcdDrawTextAlignedLeft(y, STR_DEBUG);
|
||||
lcdDrawText(HW_SETTINGS_COLUMN2, y, STR_ANALOGS_BTN, menuHorizontalPosition == 0 ? attr : 0);
|
||||
|
||||
@@ -611,5 +611,9 @@ const char * restoreModel(uint8_t idx, char *model_name)
|
||||
bool storageReadRadioSettings(bool checks)
|
||||
{
|
||||
if (!sdMounted()) sdInit();
|
||||
return loadRadioSettingsYaml(checks) == nullptr;
|
||||
bool rv = loadRadioSettingsYaml(checks) == nullptr;
|
||||
#if LCD_W == 128
|
||||
lcdSetInvert(g_eeGeneral.invertLCD);
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -358,7 +358,8 @@ static const struct YamlNode struct_RadioData[] = {
|
||||
YAML_UNSIGNED( "modelCustomScriptsDisabled", 1 ),
|
||||
YAML_UNSIGNED( "modelTelemetryDisabled", 1 ),
|
||||
YAML_UNSIGNED( "disableTrainerPoweroffAlarm", 1 ),
|
||||
YAML_PADDING( 5 ),
|
||||
YAML_UNSIGNED( "invertLCD", 1 ),
|
||||
YAML_PADDING( 4 ),
|
||||
YAML_END
|
||||
};
|
||||
static const struct YamlNode struct_unsigned_8[] = {
|
||||
|
||||
@@ -358,7 +358,8 @@ static const struct YamlNode struct_RadioData[] = {
|
||||
YAML_UNSIGNED( "modelCustomScriptsDisabled", 1 ),
|
||||
YAML_UNSIGNED( "modelTelemetryDisabled", 1 ),
|
||||
YAML_UNSIGNED( "disableTrainerPoweroffAlarm", 1 ),
|
||||
YAML_PADDING( 5 ),
|
||||
YAML_UNSIGNED( "invertLCD", 1 ),
|
||||
YAML_PADDING( 4 ),
|
||||
YAML_END
|
||||
};
|
||||
static const struct YamlNode struct_unsigned_8[] = {
|
||||
|
||||
@@ -358,7 +358,8 @@ static const struct YamlNode struct_RadioData[] = {
|
||||
YAML_UNSIGNED( "modelCustomScriptsDisabled", 1 ),
|
||||
YAML_UNSIGNED( "modelTelemetryDisabled", 1 ),
|
||||
YAML_UNSIGNED( "disableTrainerPoweroffAlarm", 1 ),
|
||||
YAML_PADDING( 5 ),
|
||||
YAML_UNSIGNED( "invertLCD", 1 ),
|
||||
YAML_PADDING( 4 ),
|
||||
YAML_END
|
||||
};
|
||||
static const struct YamlNode struct_unsigned_8[] = {
|
||||
|
||||
@@ -361,7 +361,8 @@ static const struct YamlNode struct_RadioData[] = {
|
||||
YAML_UNSIGNED( "modelCustomScriptsDisabled", 1 ),
|
||||
YAML_UNSIGNED( "modelTelemetryDisabled", 1 ),
|
||||
YAML_UNSIGNED( "disableTrainerPoweroffAlarm", 1 ),
|
||||
YAML_PADDING( 5 ),
|
||||
YAML_UNSIGNED( "invertLCD", 1 ),
|
||||
YAML_PADDING( 4 ),
|
||||
YAML_END
|
||||
};
|
||||
static const struct YamlNode struct_unsigned_8[] = {
|
||||
|
||||
@@ -426,6 +426,12 @@ void lcdSetRefVolt(uint8_t val)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LCD_W == 128
|
||||
void lcdSetInvert(bool invert)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
void boardInit()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -371,6 +371,9 @@ void lcdRefresh();
|
||||
void lcdRefresh(bool wait=true); // TODO uint8_t wait to simplify this
|
||||
#endif
|
||||
void lcdSetRefVolt(unsigned char val);
|
||||
#if LCD_W == 128
|
||||
void lcdSetInvert(bool invert);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
void lcdSetContrast(bool useDefault = false);
|
||||
#endif
|
||||
|
||||
@@ -411,3 +411,10 @@ void lcdSetRefVolt(uint8_t val)
|
||||
lcdWriteCommand(0x81); // Set Vop
|
||||
lcdWriteCommand(val+LCD_CONTRAST_OFFSET); // 0-255
|
||||
}
|
||||
|
||||
#if LCD_W == 128
|
||||
void lcdSetInvert(bool invert)
|
||||
{
|
||||
lcdWriteCommand(invert ? 0xA7 : 0xA6);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user