mirror of
https://github.com/meshtastic/firmware.git
synced 2025-07-30 02:15:41 +00:00

Some checks are pending
CI / setup (check) (push) Waiting to run
CI / setup (esp32) (push) Waiting to run
CI / setup (esp32c3) (push) Waiting to run
CI / setup (esp32c6) (push) Waiting to run
CI / setup (esp32s3) (push) Waiting to run
CI / setup (nrf52840) (push) Waiting to run
CI / setup (rp2040) (push) Waiting to run
CI / setup (rp2350) (push) Waiting to run
CI / setup (stm32) (push) Waiting to run
CI / version (push) Waiting to run
CI / check (push) Blocked by required conditions
CI / build-esp32 (push) Blocked by required conditions
CI / build-esp32s3 (push) Blocked by required conditions
CI / build-esp32c3 (push) Blocked by required conditions
CI / build-esp32c6 (push) Blocked by required conditions
CI / build-nrf52840 (push) Blocked by required conditions
CI / build-rp2040 (push) Blocked by required conditions
CI / build-rp2350 (push) Blocked by required conditions
CI / build-stm32 (push) Blocked by required conditions
CI / build-debian-src (push) Waiting to run
CI / package-pio-deps-native-tft (push) Waiting to run
CI / test-native (push) Waiting to run
CI / docker-deb-amd64 (push) Waiting to run
CI / docker-deb-amd64-tft (push) Waiting to run
CI / docker-alp-amd64 (push) Waiting to run
CI / docker-alp-amd64-tft (push) Waiting to run
CI / docker-deb-arm64 (push) Waiting to run
CI / docker-deb-armv7 (push) Waiting to run
CI / gather-artifacts (esp32) (push) Blocked by required conditions
CI / gather-artifacts (esp32c3) (push) Blocked by required conditions
CI / gather-artifacts (esp32c6) (push) Blocked by required conditions
CI / gather-artifacts (esp32s3) (push) Blocked by required conditions
CI / gather-artifacts (nrf52840) (push) Blocked by required conditions
CI / gather-artifacts (rp2040) (push) Blocked by required conditions
CI / gather-artifacts (rp2350) (push) Blocked by required conditions
CI / gather-artifacts (stm32) (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
CI / release-firmware (esp32) (push) Blocked by required conditions
CI / release-firmware (esp32c3) (push) Blocked by required conditions
CI / release-firmware (esp32c6) (push) Blocked by required conditions
CI / release-firmware (esp32s3) (push) Blocked by required conditions
CI / release-firmware (nrf52840) (push) Blocked by required conditions
CI / release-firmware (rp2040) (push) Blocked by required conditions
CI / release-firmware (rp2350) (push) Blocked by required conditions
CI / release-firmware (stm32) (push) Blocked by required conditions
CI / publish-firmware (push) Blocked by required conditions
* Clear position on GPS deactivation, unless using fixed position As reported by @dreimal8 , and confirmed by @tuxmobil , when using and then subsequently disabling GPS the last position retrieved from the GPS was stored and continued to be broadcast. This change introduces a check to see if we are transitioning from GPS Enabled to GPS Disabled or Not Present. If we are, and fixed position is not in use, then we clear the local position. This will prevent inaccurate and undesired position broadcasts for those who disable their GPS. Fixes https://github.com/meshtastic/firmware/issues/7228 * Update triple click to also clear position --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
124 lines
4.3 KiB
C++
124 lines
4.3 KiB
C++
#include "SystemCommandsModule.h"
|
|
#include "meshUtils.h"
|
|
#if HAS_SCREEN
|
|
#include "graphics/Screen.h"
|
|
#include "graphics/SharedUIDisplay.h"
|
|
#endif
|
|
#include "GPS.h"
|
|
#include "MeshService.h"
|
|
#include "Module.h"
|
|
#include "NodeDB.h"
|
|
#include "main.h"
|
|
#include "modules/AdminModule.h"
|
|
#include "modules/ExternalNotificationModule.h"
|
|
|
|
SystemCommandsModule *systemCommandsModule;
|
|
|
|
SystemCommandsModule::SystemCommandsModule()
|
|
{
|
|
if (inputBroker)
|
|
inputObserver.observe(inputBroker);
|
|
}
|
|
|
|
int SystemCommandsModule::handleInputEvent(const InputEvent *event)
|
|
{
|
|
LOG_INFO("Input event %u! kb %u", event->inputEvent, event->kbchar);
|
|
// System commands (all others fall through)
|
|
switch (event->kbchar) {
|
|
// Fn key symbols
|
|
case INPUT_BROKER_MSG_FN_SYMBOL_ON:
|
|
IF_SCREEN(screen->setFunctionSymbol("Fn"));
|
|
return 0;
|
|
case INPUT_BROKER_MSG_FN_SYMBOL_OFF:
|
|
IF_SCREEN(screen->removeFunctionSymbol("Fn"));
|
|
return 0;
|
|
// Brightness
|
|
case INPUT_BROKER_MSG_BRIGHTNESS_UP:
|
|
IF_SCREEN(screen->increaseBrightness());
|
|
LOG_DEBUG("Increase Screen Brightness");
|
|
return 0;
|
|
case INPUT_BROKER_MSG_BRIGHTNESS_DOWN:
|
|
IF_SCREEN(screen->decreaseBrightness());
|
|
LOG_DEBUG("Decrease Screen Brightness");
|
|
return 0;
|
|
// Mute
|
|
case INPUT_BROKER_MSG_MUTE_TOGGLE:
|
|
if (moduleConfig.external_notification.enabled && externalNotificationModule) {
|
|
bool isMuted = externalNotificationModule->getMute();
|
|
externalNotificationModule->setMute(!isMuted);
|
|
IF_SCREEN(graphics::isMuted = !isMuted; if (!isMuted) externalNotificationModule->stopNow();
|
|
screen->showSimpleBanner(isMuted ? "Notifications\nEnabled" : "Notifications\nDisabled", 3000);)
|
|
}
|
|
return 0;
|
|
// Bluetooth
|
|
case INPUT_BROKER_MSG_BLUETOOTH_TOGGLE:
|
|
config.bluetooth.enabled = !config.bluetooth.enabled;
|
|
LOG_INFO("User toggled Bluetooth");
|
|
nodeDB->saveToDisk();
|
|
#if defined(ARDUINO_ARCH_NRF52)
|
|
if (!config.bluetooth.enabled) {
|
|
disableBluetooth();
|
|
IF_SCREEN(screen->showSimpleBanner("Bluetooth OFF\nRebooting", 3000));
|
|
rebootAtMsec = millis() + DEFAULT_REBOOT_SECONDS * 2000;
|
|
} else {
|
|
IF_SCREEN(screen->showSimpleBanner("Bluetooth ON\nRebooting", 3000));
|
|
rebootAtMsec = millis() + DEFAULT_REBOOT_SECONDS * 1000;
|
|
}
|
|
#else
|
|
if (!config.bluetooth.enabled) {
|
|
disableBluetooth();
|
|
IF_SCREEN(screen->showSimpleBanner("Bluetooth OFF", 3000));
|
|
} else {
|
|
IF_SCREEN(screen->showSimpleBanner("Bluetooth ON\nRebooting", 3000));
|
|
rebootAtMsec = millis() + DEFAULT_REBOOT_SECONDS * 1000;
|
|
}
|
|
#endif
|
|
return 0;
|
|
case INPUT_BROKER_MSG_REBOOT:
|
|
IF_SCREEN(screen->showSimpleBanner("Rebooting...", 0));
|
|
nodeDB->saveToDisk();
|
|
rebootAtMsec = millis() + DEFAULT_REBOOT_SECONDS * 1000;
|
|
// runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
|
|
return true;
|
|
}
|
|
|
|
switch (event->inputEvent) {
|
|
// GPS
|
|
case INPUT_BROKER_GPS_TOGGLE:
|
|
LOG_WARN("GPS Toggle");
|
|
#if !MESHTASTIC_EXCLUDE_GPS
|
|
if (gps) {
|
|
LOG_WARN("GPS Toggle2");
|
|
if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED &&
|
|
config.position.fixed_position == false) {
|
|
nodeDB->clearLocalPosition();
|
|
nodeDB->saveToDisk();
|
|
}
|
|
gps->toggleGpsMode();
|
|
const char *msg =
|
|
(config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED) ? "GPS Enabled" : "GPS Disabled";
|
|
IF_SCREEN(screen->forceDisplay(); screen->showSimpleBanner(msg, 3000);)
|
|
}
|
|
#endif
|
|
return true;
|
|
// Mesh ping
|
|
case INPUT_BROKER_SEND_PING:
|
|
service->refreshLocalMeshNode();
|
|
if (service->trySendPosition(NODENUM_BROADCAST, true)) {
|
|
IF_SCREEN(screen->showSimpleBanner("Position\nSent", 3000));
|
|
} else {
|
|
IF_SCREEN(screen->showSimpleBanner("Node Info\nSent", 3000));
|
|
}
|
|
return true;
|
|
// Power control
|
|
case INPUT_BROKER_SHUTDOWN:
|
|
shutdownAtMsec = millis();
|
|
return true;
|
|
|
|
default:
|
|
// No other input events handled here
|
|
break;
|
|
}
|
|
return false;
|
|
}
|