mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-02 11:55:56 +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,
|
LAYOUT,
|
||||||
TOGGLE_BATTERY_ICON,
|
TOGGLE_BATTERY_ICON,
|
||||||
TOGGLE_NOTIFICATIONS,
|
TOGGLE_NOTIFICATIONS,
|
||||||
|
TOGGLE_INVERT_COLOR,
|
||||||
TOGGLE_12H_CLOCK,
|
TOGGLE_12H_CLOCK,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -205,6 +205,15 @@ void InkHUD::MenuApplet::execute(MenuItem item)
|
|||||||
settings->optionalFeatures.notifications = !settings->optionalFeatures.notifications;
|
settings->optionalFeatures.notifications = !settings->optionalFeatures.notifications;
|
||||||
break;
|
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:
|
case SET_RECENTS:
|
||||||
// Set value of settings.recentlyActiveSeconds
|
// Set value of settings.recentlyActiveSeconds
|
||||||
// Uses menu cursor to read RECENTS_OPTIONS_MINUTES array (defined at top of this file)
|
// 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));
|
&settings->optionalFeatures.notifications));
|
||||||
items.push_back(MenuItem("Battery Icon", MenuAction::TOGGLE_BATTERY_ICON, MenuPage::OPTIONS,
|
items.push_back(MenuItem("Battery Icon", MenuAction::TOGGLE_BATTERY_ICON, MenuPage::OPTIONS,
|
||||||
&settings->optionalFeatures.batteryIcon));
|
&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(
|
items.push_back(
|
||||||
MenuItem("12-Hour Clock", MenuAction::TOGGLE_12H_CLOCK, MenuPage::OPTIONS, &config.display.use_12h_clock));
|
MenuItem("12-Hour Clock", MenuAction::TOGGLE_12H_CLOCK, MenuPage::OPTIONS, &config.display.use_12h_clock));
|
||||||
items.push_back(MenuItem("Exit", MenuPage::EXIT));
|
items.push_back(MenuItem("Exit", MenuPage::EXIT));
|
||||||
|
@ -91,6 +91,8 @@ class MenuApplet : public SystemApplet, public concurrency::OSThread
|
|||||||
} cm;
|
} cm;
|
||||||
|
|
||||||
Applet *borrowedTileOwner = nullptr; // Which applet we have temporarily replaced while displaying menu
|
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
|
} // namespace NicheGraphics::InkHUD
|
||||||
|
@ -224,6 +224,13 @@ void InkHUD::Renderer::render(bool async)
|
|||||||
renderPlaceholders();
|
renderPlaceholders();
|
||||||
renderSystemApplets();
|
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
|
// Tell display to begin process of drawing new image
|
||||||
LOG_INFO("Updating display");
|
LOG_INFO("Updating display");
|
||||||
driver->update(imageBuffer, updateType);
|
driver->update(imageBuffer, updateType);
|
||||||
|
Loading…
Reference in New Issue
Block a user