From ca188d1154a0a7948a90e9e5330de8050b8ef95f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 2 Apr 2024 14:50:25 +0200 Subject: [PATCH 1/5] - map fn+m to mute and unmute the external notification module - map fn+t to be an alternative for the TAB key --- src/modules/CannedMessageModule.cpp | 15 ++++++++++++++- src/modules/ExternalNotificationModule.cpp | 4 ++-- src/modules/ExternalNotificationModule.h | 5 +++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 60334ca031..b57a1c3173 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -12,7 +12,8 @@ #include "detect/ScanI2C.h" #include "mesh/generated/meshtastic/cannedmessages.pb.h" -#include "main.h" // for cardkb_found +#include "main.h" // for cardkb_found +#include "modules/ExternalNotificationModule.h" // for buzzer control #ifndef INPUTBROKER_MATRIX_TYPE #define INPUTBROKER_MATRIX_TYPE 0 @@ -397,6 +398,7 @@ int32_t CannedMessageModule::runOnce() } break; case 0x09: // tab + case 0x91: // fn+t for T-Deck that doesn't have a tab key if (this->destSelect == CANNED_MESSAGE_DESTINATION_TYPE_CHANNEL) { this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE; } else if (this->destSelect == CANNED_MESSAGE_DESTINATION_TYPE_NODE) { @@ -419,6 +421,17 @@ int32_t CannedMessageModule::runOnce() screen->startRebootScreen(); rebootAtMsec = millis() + DEFAULT_REBOOT_SECONDS * 1000; break; + // mute (switch off/toggle) external notifications on fn+m + case 0xac: + if (moduleConfig.external_notification.enabled) { + if (externalNotificationModule->getMute()) { + externalNotificationModule->setMute(false); + } else { + externalNotificationModule->stopNow(); // this will turn off all GPIO and sounds and idle the loop + externalNotificationModule->setMute(true); + } + } + break; default: if (this->cursor == this->freetext.length()) { this->freetext += this->payload; diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 2a4fdd0aef..617796544c 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -336,7 +336,7 @@ ExternalNotificationModule::ExternalNotificationModule() ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshPacket &mp) { - if (moduleConfig.external_notification.enabled) { + if (moduleConfig.external_notification.enabled && !isMuted) { #ifdef T_WATCH_S3 drv.setWaveform(0, 75); drv.setWaveform(1, 56); @@ -445,7 +445,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP setIntervalFromNow(0); // run once so we know if we should do something } } else { - LOG_INFO("External Notification Module Disabled\n"); + LOG_INFO("External Notification Module Disabled or muted\n"); } return ProcessMessage::CONTINUE; // Let others look at this message also if they want diff --git a/src/modules/ExternalNotificationModule.h b/src/modules/ExternalNotificationModule.h index 3331ec428d..08e72c35a9 100644 --- a/src/modules/ExternalNotificationModule.h +++ b/src/modules/ExternalNotificationModule.h @@ -38,6 +38,9 @@ class ExternalNotificationModule : public SinglePortModule, private concurrency: void setExternalOff(uint8_t index = 0); bool getExternal(uint8_t index = 0); + void setMute(bool mute) { isMuted = mute; } + bool getMute() { return isMuted; } + void stopNow(); void handleGetRingtone(const meshtastic_MeshPacket &req, meshtastic_AdminMessage *response); @@ -56,6 +59,8 @@ class ExternalNotificationModule : public SinglePortModule, private concurrency: bool isNagging = false; + bool isMuted = false; + virtual AdminMessageHandleResult handleAdminMessageForModule(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *request, meshtastic_AdminMessage *response) override; From b1ef922e48526b5e1c69fab4608bc8895e1d926c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 3 Apr 2024 19:11:02 +0200 Subject: [PATCH 2/5] add whitelist to inputbroker --- src/input/kbI2cBase.cpp | 1 + src/modules/CannedMessageModule.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/input/kbI2cBase.cpp b/src/input/kbI2cBase.cpp index 048f8bbdc6..206ca0ca26 100644 --- a/src/input/kbI2cBase.cpp +++ b/src/input/kbI2cBase.cpp @@ -218,6 +218,7 @@ int32_t KbI2cBase::runOnce() break; case 0x90: // fn+r case 0x9b: // fn+s + case 0xac: // fn+t // just pass those unmodified e.inputEvent = ANYKEY; e.kbchar = c; diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index b57a1c3173..8978018dd5 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -423,7 +423,7 @@ int32_t CannedMessageModule::runOnce() break; // mute (switch off/toggle) external notifications on fn+m case 0xac: - if (moduleConfig.external_notification.enabled) { + if (moduleConfig.external_notification.enabled == true) { if (externalNotificationModule->getMute()) { externalNotificationModule->setMute(false); } else { From 4f7f198dbeff4b58f2109d45ad44b06ba3fd90b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 3 Apr 2024 19:58:42 +0200 Subject: [PATCH 3/5] (maybe) sweet-talking t-deck into tabbing... --- src/input/kbI2cBase.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/input/kbI2cBase.cpp b/src/input/kbI2cBase.cpp index 206ca0ca26..7ab8783851 100644 --- a/src/input/kbI2cBase.cpp +++ b/src/input/kbI2cBase.cpp @@ -218,11 +218,14 @@ int32_t KbI2cBase::runOnce() break; case 0x90: // fn+r case 0x9b: // fn+s - case 0xac: // fn+t // just pass those unmodified e.inputEvent = ANYKEY; e.kbchar = c; break; + case 0xac: // fn+t + e.inputEvent = ANYKEY; + e.kbchar = 0x09; // TAB Scancode + break; case 0x0d: // Enter e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT; break; From 1b0c9056a233724c324a4d4be024e5d743ef22de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 3 Apr 2024 20:06:26 +0200 Subject: [PATCH 4/5] now for real - back in Kansas --- src/input/kbI2cBase.cpp | 6 ++---- src/modules/CannedMessageModule.cpp | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/input/kbI2cBase.cpp b/src/input/kbI2cBase.cpp index 7ab8783851..dc09a81b5f 100644 --- a/src/input/kbI2cBase.cpp +++ b/src/input/kbI2cBase.cpp @@ -217,15 +217,13 @@ int32_t KbI2cBase::runOnce() e.kbchar = 0xb7; break; case 0x90: // fn+r + case 0x91: // fn+t (alt+t for t-deck) case 0x9b: // fn+s + case 0xac: // fn+m // just pass those unmodified e.inputEvent = ANYKEY; e.kbchar = c; break; - case 0xac: // fn+t - e.inputEvent = ANYKEY; - e.kbchar = 0x09; // TAB Scancode - break; case 0x0d: // Enter e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT; break; diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 8978018dd5..590c67b1c4 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -398,7 +398,7 @@ int32_t CannedMessageModule::runOnce() } break; case 0x09: // tab - case 0x91: // fn+t for T-Deck that doesn't have a tab key + case 0x91: // alt+t for T-Deck that doesn't have a tab key if (this->destSelect == CANNED_MESSAGE_DESTINATION_TYPE_CHANNEL) { this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE; } else if (this->destSelect == CANNED_MESSAGE_DESTINATION_TYPE_NODE) { From 3dee22b84034301fc0e3a12c81d7cf942090a431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 4 Apr 2024 09:50:39 +0200 Subject: [PATCH 5/5] More fancy mappings --- src/input/kbI2cBase.cpp | 4 +++- src/modules/CannedMessageModule.cpp | 27 +++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/input/kbI2cBase.cpp b/src/input/kbI2cBase.cpp index dc09a81b5f..74a6c718de 100644 --- a/src/input/kbI2cBase.cpp +++ b/src/input/kbI2cBase.cpp @@ -217,9 +217,11 @@ int32_t KbI2cBase::runOnce() e.kbchar = 0xb7; break; case 0x90: // fn+r - case 0x91: // fn+t (alt+t for t-deck) + case 0x91: // fn+t case 0x9b: // fn+s case 0xac: // fn+m + case 0x9e: // fn+g + case 0xaf: // fn+space // just pass those unmodified e.inputEvent = ANYKEY; e.kbchar = c; diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 590c67b1c4..c1cf903252 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -14,6 +14,9 @@ #include "main.h" // for cardkb_found #include "modules/ExternalNotificationModule.h" // for buzzer control +#if !MESHTASTIC_EXCLUDE_GPS +#include "GPS.h" +#endif #ifndef INPUTBROKER_MATRIX_TYPE #define INPUTBROKER_MATRIX_TYPE 0 @@ -413,25 +416,45 @@ int32_t CannedMessageModule::runOnce() break; // handle fn+s for shutdown case 0x9b: - screen->startShutdownScreen(); + if (screen) + screen->startShutdownScreen(); shutdownAtMsec = millis() + DEFAULT_SHUTDOWN_SECONDS * 1000; + runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; break; // and fn+r for reboot case 0x90: - screen->startRebootScreen(); + if (screen) + screen->startRebootScreen(); rebootAtMsec = millis() + DEFAULT_REBOOT_SECONDS * 1000; + runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; + break; + case 0x9e: // toggle GPS like triple press does + if (gps != nullptr) { + gps->toggleGpsMode(); + } + if (screen) + screen->forceDisplay(); + runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; break; + // mute (switch off/toggle) external notifications on fn+m case 0xac: if (moduleConfig.external_notification.enabled == true) { if (externalNotificationModule->getMute()) { externalNotificationModule->setMute(false); + runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; } else { externalNotificationModule->stopNow(); // this will turn off all GPIO and sounds and idle the loop externalNotificationModule->setMute(true); + runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; } } break; + case 0xaf: // fn+space send network ping like double press does + service.refreshLocalMeshNode(); + service.sendNetworkPing(NODENUM_BROADCAST, true); + runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; + break; default: if (this->cursor == this->freetext.length()) { this->freetext += this->payload;