mirror of
https://github.com/meshtastic/firmware.git
synced 2026-09-29 01:36:26 -04:00
Toggle GPS and buzzer together on the ThinkNode M8 function button double click (#11551)
* Toggle GPS and buzzer together on the ThinkNode M8 function button double click * Shorten the comments added with the ThinkNode M8 double click toggle * Only sync the buzzer when the GPS mode actually toggles, and unmute before the tone plays
This commit is contained in:
1 parent
bb6a81f1e9
commit
9c027a24ea
4 files changed
+23
-15
No files matched your search
@@ -86,18 +86,30 @@ int SystemCommandsModule::handleInputEvent(const InputEvent *event)
|
||||
}
|
||||
|
||||
switch (event->inputEvent) {
|
||||
// GPS
|
||||
// GPS, on its own or together with the buzzer
|
||||
case INPUT_BROKER_GPS_TOGGLE:
|
||||
case INPUT_BROKER_PRIVACY_TOGGLE:
|
||||
#if !MESHTASTIC_EXCLUDE_GPS
|
||||
if (gps) {
|
||||
if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED &&
|
||||
config.position.fixed_position == false) {
|
||||
const bool wasEnabled = config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED;
|
||||
// toggleGpsMode() only moves between ENABLED and DISABLED, so leave the buzzer alone otherwise.
|
||||
const bool withBuzzer = event->inputEvent == INPUT_BROKER_PRIVACY_TOGGLE &&
|
||||
(wasEnabled || config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_DISABLED);
|
||||
if (wasEnabled && config.position.fixed_position == false) {
|
||||
nodeDB->clearLocalPosition();
|
||||
nodeDB->saveToDisk();
|
||||
}
|
||||
if (withBuzzer) // unmute first, so the confirmation beep is audible in both directions
|
||||
config.device.buzzer_mode = meshtastic_Config_DeviceConfig_BuzzerMode_ALL_ENABLED;
|
||||
gps->toggleGpsMode();
|
||||
const char *msg =
|
||||
(config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED) ? "GPS Enabled" : "GPS Disabled";
|
||||
const bool nowEnabled = config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED;
|
||||
if (withBuzzer) {
|
||||
config.device.buzzer_mode = nowEnabled ? meshtastic_Config_DeviceConfig_BuzzerMode_ALL_ENABLED
|
||||
: meshtastic_Config_DeviceConfig_BuzzerMode_DISABLED;
|
||||
nodeDB->saveToDisk(SEGMENT_CONFIG);
|
||||
}
|
||||
const char *msg = withBuzzer ? (nowEnabled ? "GPS + Buzzer\nEnabled" : "GPS + Buzzer\nDisabled")
|
||||
: (nowEnabled ? "GPS Enabled" : "GPS Disabled");
|
||||
IF_SCREEN(screen->forceDisplay(); screen->showSimpleBanner(msg, 3000);)
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user