mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-08 06:35:38 +00:00

* Initial work on splitting notification renderer into components for reuse * More progress * Fix notification popup * more fix, less crash * Adjustments for OLED on keeping menus tidy, added Bluetooth Toggle to Home frame. Also widen the frame slightly if you have a scroll bar * Small changes for EInk to not crowd elements * Change System frame menu over to better match actions; added color picker for T114 * Fix build errors and add T190 for testing * Logic gates are hard sometimes * Screen Color Picker changes, defined Yellow as a Color. * Additional colors and tuning * Abandon std::sort in NodeDB, and associated fixes (#7175) * Generate short name for nodes that don't have user yet * Add reboot menu * Sort fixes * noop sort option to avoid infinite loop * Refactor Overlay Banner * Continuing work on Color Picker * Add BaseUI menus to add and remove Favorited Nodes * Create TFT_MESH_OVERRIDE for variants.h and defined colors * Trigger a NodeStatus update at the end of setup() to get fresh data on display at boot. * T114 defaults to White, Yellow is now bright Yellow * Revert "T114 defaults to White, Yellow is now bright Yellow" This reverts commit8d05e17f11
. * Only show OEM text if not OLED * Adjust OEM logo to maximize visible area * Start plumbing in Color Picker changes * Finished plumbing * Fix warning * Revert "Fix warning" This reverts commit2e8aecd52d
. * Fix display not fully redrawing * T-Deck should get color too * Emote Revamp * Update emotes.cpp * Poo Emote fix * Trunk fix * Add secret test menu and number picker * Missed bits * Save colors between reboots * Save Clock Face election to protobuf * Make reboot first, then settings * Add padding for single line pop-ups * Compass saving and faster menus * Resolve build issue with Excluding GPS * Resolve issue with memory bars on EInk * Add brightness settings for supported screen (#7182) * Add brightness menu. * add loop destination selection. * Bring back color (and sanity) to the menus! * Trunk --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Jason P <applewiz@mac.com> Co-authored-by: HarukiToreda <116696711+HarukiToreda@users.noreply.github.com> Co-authored-by: Wilson <m.tools@qq.com>
123 lines
4.3 KiB
C++
123 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");
|
|
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:
|
|
LOG_ERROR("Shutting Down");
|
|
IF_SCREEN(screen->showSimpleBanner("Shutting Down..."));
|
|
nodeDB->saveToDisk();
|
|
shutdownAtMsec = millis() + DEFAULT_SHUTDOWN_SECONDS * 1000;
|
|
// runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
|
|
return true;
|
|
|
|
default:
|
|
// No other input events handled here
|
|
break;
|
|
}
|
|
return false;
|
|
}
|