Skip to content

Commit dad9405

Browse files
committed
Sort out InkHUD applying-changes notifications
notifyApplyingChanges() was doing two jobs at its call sites in MenuApplet.cpp: signalling a live change that is applied without restarting, and warning of an imminent reboot. Audited every site. The finding is that none of them are redundant, so this records why rather than removing anything. The two live-change calls - LoRa region and modem preset - cover the seconds the e-ink takes to redraw while the radio reconfigures, and nothing else raises them. The reboot-path calls warn before the display goes. requestReboot() cannot absorb those: it deliberately carries no UI, because BaseUI renders its own notice at draw time from rebootAtMsec, while e-ink only draws when pushed. Also worth recording: the existing notifyReboot Observable (sleep.h, fired from Power::reboot) is a different moment - reboot execution, not scheduling - and InkHUD already observes it to save settings and shut applets down. A new "reboot scheduled" observable to centralise these calls would be a third reboot signal for no functional gain, so it is not added. clod helped too
1 parent a73fd76 commit dad9405

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,9 @@ static void applyLoRaRegion(meshtastic_Config_LoRaConfig_RegionCode region)
342342
snprintf(moduleConfig.mqtt.root, sizeof(moduleConfig.mqtt.root), "%s/%s", default_mqtt_root, myRegion->name);
343343
changes |= SEGMENT_MODULECONFIG;
344344
}
345-
// Notify UI that changes are being applied
345+
// Live change, not a reboot: covers the e-ink redraw while the radio reconfigures. See the
346+
// two-jobs note on InkHUD::notifyApplyingChanges() - this call is not interchangeable with the
347+
// ones that sit beside CONFIG_APPLY_REBOOT below.
346348
InkHUD::InkHUD::getInstance()->notifyApplyingChanges();
347349
// LoRa config applies live via configChanged observer -> RadioInterface::reconfigure(); no reboot needed.
348350
service->applyConfigChange(changes, CONFIG_APPLY_RADIO);
@@ -372,7 +374,7 @@ static void applyLoRaPreset(meshtastic_Config_LoRaConfig_ModemPreset preset)
372374
// LoRa config applies live via configChanged observer -> RadioInterface::reconfigure(); no reboot needed.
373375
service->applyConfigChange(SEGMENT_CONFIG, CONFIG_APPLY_RADIO);
374376

375-
// Notify UI that changes are being applied
377+
// Live change, not a reboot (see applyLoRaRegion above).
376378
InkHUD::InkHUD::getInstance()->notifyApplyingChanges();
377379
}
378380

src/graphics/niche/InkHUD/InkHUD.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,26 @@ class InkHUD
4949
void setDriver(Drivers::EInk *driver);
5050
void setDisplayResilience(uint8_t fastPerFull = 5, float stressMultiplier = 2.0);
5151
void addApplet(const char *name, Applet *a, bool defaultActive = false, bool defaultAutoshow = false, uint8_t onTile = -1);
52+
53+
/** Show the "applying changes" holding screen.
54+
*
55+
* Called at the moment a config change is *initiated*, and it serves two distinct jobs at its
56+
* call sites in MenuApplet.cpp. Do not treat them alike when refactoring:
57+
*
58+
* - a **live** change, applied without restarting (LoRa region and modem preset). The screen
59+
* covers the seconds the e-ink takes to redraw. These calls must stay: nothing else raises
60+
* them.
61+
* - an imminent **reboot**, where it warns before the display goes. These sit next to an
62+
* applyConfigChange(..., CONFIG_APPLY_REBOOT).
63+
*
64+
* Neither is redundant with anything, which is the point worth recording. MeshService's
65+
* requestReboot() deliberately carries no UI: BaseUI renders its own notice at draw time from
66+
* rebootAtMsec, whereas e-ink only draws when pushed, so InkHUD has to be told explicitly.
67+
* And the existing `notifyReboot` Observable (sleep.h, fired from Power::reboot) is a
68+
* *different moment* - reboot execution, not scheduling - which InkHUD already observes to save
69+
* settings and shut applets down. Centralising these calls onto a new "reboot scheduled"
70+
* observable would add a third reboot signal for no functional gain.
71+
*/
5272
void notifyApplyingChanges();
5373

5474
void begin();

0 commit comments

Comments
 (0)