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:
Thomas Göttgens
2026-08-19 15:52:23 +00:00
committed by GitHub
parent bb6a81f1e9
commit 9c027a24ea
4 changed files with 23 additions and 15 deletions
+4 -9
View File
@@ -102,7 +102,9 @@ bool ButtonThread::initButton(const ButtonConfig &config)
#endif
userButton.setPressMs(_longPressTime);
if (screen) {
// The 20ms window a screen normally gets closes before a second click can land, so boards
// binding double or multi click need the full one.
if (screen && _doublePress == INPUT_BROKER_NONE && _triplePress == INPUT_BROKER_NONE) {
userButton.setClickMs(20);
} else {
userButton.setClickMs(BUTTON_CLICK_MS);
@@ -225,15 +227,8 @@ int32_t ButtonThread::runOnce()
break;
}
case BUTTON_EVENT_DOUBLE_PRESSED: { // not wired in if screen detected
case BUTTON_EVENT_DOUBLE_PRESSED: { // only on boards binding ButtonConfig::doublePress
LOG_INFO("Double press");
#if defined(ELECROW_ThinkNode_M8)
if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED)
config.device.buzzer_mode = meshtastic_Config_DeviceConfig_BuzzerMode_DISABLED;
else if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_DISABLED)
config.device.buzzer_mode = meshtastic_Config_DeviceConfig_BuzzerMode_ALL_ENABLED;
service->reloadConfig(SEGMENT_CONFIG);
#endif
// Reset combination tracking
waitingForLongPress = false;
+1 -1
View File
@@ -382,7 +382,7 @@ void InputBroker::Init()
userConfig.singlePress = INPUT_BROKER_SEND_PING;
userConfig.longPress = INPUT_BROKER_SHUTDOWN;
userConfig.longPressTime = 5000;
userConfig.doublePress = INPUT_BROKER_GPS_TOGGLE;
userConfig.doublePress = INPUT_BROKER_PRIVACY_TOGGLE;
UserButtonThread->initButton(userConfig);
}
#else
+1
View File
@@ -28,6 +28,7 @@ enum input_broker_event {
INPUT_BROKER_FACTORY_RST = 0x9a,
INPUT_BROKER_SHUTDOWN = 0x9b,
INPUT_BROKER_GPS_TOGGLE = 0x9e,
INPUT_BROKER_PRIVACY_TOGGLE = 0x9f, // GPS and buzzer off together, and back on together
INPUT_BROKER_SEND_PING = 0xaf,
INPUT_BROKER_FN_F1 = 0xf1,
INPUT_BROKER_FN_F2 = 0xf2,
+17 -5
View File
@@ -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