mirror of
https://github.com/meshtastic/firmware.git
synced 2025-07-31 02:45:41 +00:00
Added option to invert screen on InkHUD (#7075)
* Added option to invert screen on InkHUD * Rewrite to make use of existing config.display.displaymode --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
parent
90e99b2bac
commit
e505ec847e
@ -33,6 +33,7 @@ enum MenuAction {
|
||||
LAYOUT,
|
||||
TOGGLE_BATTERY_ICON,
|
||||
TOGGLE_NOTIFICATIONS,
|
||||
TOGGLE_INVERT_COLOR,
|
||||
TOGGLE_12H_CLOCK,
|
||||
};
|
||||
|
||||
|
@ -205,6 +205,15 @@ void InkHUD::MenuApplet::execute(MenuItem item)
|
||||
settings->optionalFeatures.notifications = !settings->optionalFeatures.notifications;
|
||||
break;
|
||||
|
||||
case TOGGLE_INVERT_COLOR:
|
||||
if (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_INVERTED)
|
||||
config.display.displaymode = meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT;
|
||||
else
|
||||
config.display.displaymode = meshtastic_Config_DisplayConfig_DisplayMode_INVERTED;
|
||||
|
||||
nodeDB->saveToDisk(SEGMENT_CONFIG);
|
||||
break;
|
||||
|
||||
case SET_RECENTS:
|
||||
// Set value of settings.recentlyActiveSeconds
|
||||
// Uses menu cursor to read RECENTS_OPTIONS_MINUTES array (defined at top of this file)
|
||||
@ -316,6 +325,10 @@ void InkHUD::MenuApplet::showPage(MenuPage page)
|
||||
&settings->optionalFeatures.notifications));
|
||||
items.push_back(MenuItem("Battery Icon", MenuAction::TOGGLE_BATTERY_ICON, MenuPage::OPTIONS,
|
||||
&settings->optionalFeatures.batteryIcon));
|
||||
|
||||
invertedColors = (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_INVERTED);
|
||||
items.push_back(MenuItem("Invert Color", MenuAction::TOGGLE_INVERT_COLOR, MenuPage::OPTIONS, &invertedColors));
|
||||
|
||||
items.push_back(
|
||||
MenuItem("12-Hour Clock", MenuAction::TOGGLE_12H_CLOCK, MenuPage::OPTIONS, &config.display.use_12h_clock));
|
||||
items.push_back(MenuItem("Exit", MenuPage::EXIT));
|
||||
|
@ -91,6 +91,8 @@ class MenuApplet : public SystemApplet, public concurrency::OSThread
|
||||
} cm;
|
||||
|
||||
Applet *borrowedTileOwner = nullptr; // Which applet we have temporarily replaced while displaying menu
|
||||
|
||||
bool invertedColors = false; // Helper to display current state of config.display.displaymode in InkHUD options
|
||||
};
|
||||
|
||||
} // namespace NicheGraphics::InkHUD
|
||||
|
@ -224,6 +224,13 @@ void InkHUD::Renderer::render(bool async)
|
||||
renderPlaceholders();
|
||||
renderSystemApplets();
|
||||
|
||||
// Invert Buffer if set by user
|
||||
if (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_INVERTED) {
|
||||
for (size_t i = 0; i < imageBufferWidth * imageBufferHeight; ++i) {
|
||||
imageBuffer[i] = ~imageBuffer[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Tell display to begin process of drawing new image
|
||||
LOG_INFO("Updating display");
|
||||
driver->update(imageBuffer, updateType);
|
||||
|
Loading…
Reference in New Issue
Block a user