InkHUD refactoring (#6216)

* chore: todo.txt
* chore: comments
* fix: no fast refresh on VME290
Reverts a line of code which was accidentally committed
* refactor: god class
Divide the behavior from the old WindowManager class into several subclasses which each have a clear role.
* refactor: cppcheck medium warnings
Enough to pass github CI for now
* refactor: updateType selection
* refactor: don't use a setter for the shared AppletFonts
* fix: update prioritization
forceUpdate calls weren't being prioritized
* refactor: remove unhelpful logging
getTimeString is used for parsing our own time, but also the timestamps of messages. The "one time only" log printing will likely fire in unhelpful situations.
* fix: " "
* refactor: get rid of types.h file for enums
* Keep that sneaky todo file out of commits
This commit is contained in:
todd-herbert
2025-03-06 11:25:41 +01:00
committed by GitHub
parent b2ef92a328
commit e6a98b1d6b
70 changed files with 2381 additions and 1955 deletions
@@ -62,30 +62,29 @@ void setupNicheGraphics()
// InkHUD
// ----------------------------
InkHUD::WindowManager *windowManager = InkHUD::WindowManager::getInstance();
InkHUD::InkHUD *inkhud = InkHUD::InkHUD::getInstance();
// Set the driver
windowManager->setDriver(driver);
inkhud->setDriver(driver);
// Set how many FAST updates per FULL update
// Set how unhealthy additional FAST updates beyond this number are
windowManager->setDisplayResilience(7, 1.5);
inkhud->setDisplayResilience(7, 1.5);
// Prepare fonts
InkHUD::AppletFont largeFont(FreeSans9pt7b);
InkHUD::AppletFont smallFont(FreeSans6pt7b);
InkHUD::Applet::fontLarge = InkHUD::AppletFont(FreeSans9pt7b);
InkHUD::Applet::fontSmall = InkHUD::AppletFont(FreeSans6pt7b);
/*
// Font localization demo: Cyrillic
InkHUD::AppletFont smallFont(FreeSans6pt8bCyrillic);
smallFont.addSubstitutionsWin1251();
InkHUD::Applet::fontSmall = InkHUD::AppletFont(FreeSans6pt8bCyrillic);
InkHUD::Applet::fontSmall.addSubstitutionsWin1251();
*/
InkHUD::Applet::setDefaultFonts(largeFont, smallFont);
// Init settings, and customize defaults
InkHUD::settings.userTiles.maxCount = 2; // How many tiles can the display handle?
InkHUD::settings.rotation = 1; // 90 degrees clockwise
InkHUD::settings.userTiles.count = 1; // One tile only by default, keep things simple for new users
InkHUD::settings.optionalMenuItems.nextTile = false; // Behavior handled by aux button instead
inkhud->persistence->settings.userTiles.maxCount = 2; // How many tiles can the display handle?
inkhud->persistence->settings.rotation = 1; // 90 degrees clockwise
inkhud->persistence->settings.userTiles.count = 1; // One tile only by default, keep things simple for new users
inkhud->persistence->settings.optionalMenuItems.nextTile = false; // Behavior handled by aux button instead
// Pick applets
// Note: order of applets determines priority of "auto-show" feature
@@ -93,35 +92,33 @@ void setupNicheGraphics()
// - is activated?
// - is autoshown?
// - is foreground on a specific tile (index)?
windowManager->addApplet("All Messages", new InkHUD::AllMessageApplet, true, true); // Activated, autoshown
windowManager->addApplet("DMs", new InkHUD::DMApplet);
windowManager->addApplet("Channel 0", new InkHUD::ThreadedMessageApplet(0));
windowManager->addApplet("Channel 1", new InkHUD::ThreadedMessageApplet(1));
windowManager->addApplet("Positions", new InkHUD::PositionsApplet, true); // Activated
windowManager->addApplet("Recents List", new InkHUD::RecentsListApplet);
windowManager->addApplet("Heard", new InkHUD::HeardApplet, true, false, 0); // Activated, not autoshown, default on tile 0
// windowManager->addApplet("Basic", new InkHUD::BasicExampleApplet);
// windowManager->addApplet("NewMsg", new InkHUD::NewMsgExampleApplet);
inkhud->addApplet("All Messages", new InkHUD::AllMessageApplet, true, true); // Activated, autoshown
inkhud->addApplet("DMs", new InkHUD::DMApplet);
inkhud->addApplet("Channel 0", new InkHUD::ThreadedMessageApplet(0));
inkhud->addApplet("Channel 1", new InkHUD::ThreadedMessageApplet(1));
inkhud->addApplet("Positions", new InkHUD::PositionsApplet, true); // Activated
inkhud->addApplet("Recents List", new InkHUD::RecentsListApplet);
inkhud->addApplet("Heard", new InkHUD::HeardApplet, true, false, 0); // Activated, not autoshown, default on tile 0
// inkhud->addApplet("Basic", new InkHUD::BasicExampleApplet);
// inkhud->addApplet("NewMsg", new InkHUD::NewMsgExampleApplet);
// Start running window manager
windowManager->begin();
// Start running InkHUD
inkhud->begin();
// Buttons
// --------------------------
Inputs::TwoButton *buttons = Inputs::TwoButton::getInstance(); // Shared NicheGraphics component
constexpr uint8_t MAIN_BUTTON = 0;
constexpr uint8_t AUX_BUTTON = 1;
Inputs::TwoButton *buttons = Inputs::TwoButton::getInstance(); // A shared NicheGraphics component
// Setup the main user button
buttons->setWiring(MAIN_BUTTON, BUTTON_PIN);
buttons->setHandlerShortPress(MAIN_BUTTON, []() { InkHUD::WindowManager::getInstance()->handleButtonShort(); });
buttons->setHandlerLongPress(MAIN_BUTTON, []() { InkHUD::WindowManager::getInstance()->handleButtonLong(); });
// Setup the main user button (0)
buttons->setWiring(0, BUTTON_PIN);
buttons->setHandlerShortPress(0, []() { InkHUD::InkHUD::getInstance()->shortpress(); });
buttons->setHandlerLongPress(0, []() { InkHUD::InkHUD::getInstance()->longpress(); });
// Setup the aux button
// Setup the aux button (1)
// Bonus feature of VME290
buttons->setWiring(AUX_BUTTON, BUTTON_PIN_SECONDARY);
buttons->setHandlerShortPress(AUX_BUTTON, []() { InkHUD::WindowManager::getInstance()->nextTile(); });
buttons->setWiring(1, BUTTON_PIN_SECONDARY);
buttons->setHandlerShortPress(1, []() { InkHUD::InkHUD::getInstance()->nextTile(); });
buttons->start();
}
@@ -34,8 +34,8 @@ build_flags =
${inkhud.build_flags}
-I variants/heltec_vision_master_e290
-D HELTEC_VISION_MASTER_E290
-D MAX_THREADS=40
-D MAX_THREADS=40 ; Required if used with WiFi
lib_deps =
${inkhud.lib_deps} ; InkHUD libs first, so we get GFXRoot intead of AdafruitGFX
${inkhud.lib_deps} ; InkHUD libs first, so we get GFXRoot instead of AdafruitGFX
${esp32s3_base.lib_deps}
upload_speed = 115200
upload_speed = 921600