mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-24 01:16:55 +00:00
Gather canned message magic numbers into header defines.
This commit is contained in:
parent
55292f8a84
commit
8e0a342f06
@ -1,6 +1,7 @@
|
||||
#include "configuration.h"
|
||||
#if ARCH_PORTDUINO
|
||||
#include "LinuxInput.h"
|
||||
#include "modules/CannedMessageModule.h"
|
||||
#include "platform/portduino/PortduinoGlue.h"
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
@ -147,11 +148,11 @@ int32_t LinuxInput::runOnce()
|
||||
case KEY_LEFT: // Left
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT;
|
||||
break;
|
||||
e.kbchar = 0xb4;
|
||||
e.kbchar = CANNED_MESSAGE_KEY_LEFT;
|
||||
case KEY_RIGHT: // Right
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT;
|
||||
break;
|
||||
e.kbchar = 0xb7;
|
||||
e.kbchar = CANNED_MESSAGE_KEY_RIGHT;
|
||||
case KEY_ENTER: // Enter
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT;
|
||||
break;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "SerialKeyboard.h"
|
||||
#include "configuration.h"
|
||||
#include "modules/CannedMessageModule.h"
|
||||
|
||||
#ifdef INPUTBROKER_SERIAL_TYPE
|
||||
#define CANNED_MESSAGE_MODULE_ENABLE 1 // in case it's not set in the variant file
|
||||
@ -87,7 +88,7 @@ int32_t SerialKeyboard::runOnce()
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_UP;
|
||||
} else if (!(shiftRegister2 & (1 << 2))) {
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT;
|
||||
e.kbchar = 0xb7;
|
||||
e.kbchar = CANNED_MESSAGE_KEY_RIGHT;
|
||||
} else if (!(shiftRegister2 & (1 << 1))) {
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT;
|
||||
} else if (!(shiftRegister2 & (1 << 0))) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "configuration.h"
|
||||
#include "detect/ScanI2C.h"
|
||||
#include "detect/ScanI2CTwoWire.h"
|
||||
#include "modules/CannedMessageModule.h"
|
||||
|
||||
extern ScanI2C::DeviceAddress cardkb_found;
|
||||
extern uint8_t kb_model;
|
||||
@ -94,7 +95,7 @@ int32_t KbI2cBase::runOnce()
|
||||
case 'e': // sym e
|
||||
if (is_sym) {
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_UP;
|
||||
e.kbchar = 0xb5;
|
||||
e.kbchar = CANNED_MESSAGE_KEY_UP;
|
||||
is_sym = false; // reset sym state after second keypress
|
||||
} else {
|
||||
e.inputEvent = ANYKEY;
|
||||
@ -104,7 +105,7 @@ int32_t KbI2cBase::runOnce()
|
||||
case 'x': // sym x
|
||||
if (is_sym) {
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_DOWN;
|
||||
e.kbchar = 0xb6;
|
||||
e.kbchar = CANNED_MESSAGE_KEY_DOWN;
|
||||
is_sym = false; // reset sym state after second keypress
|
||||
} else {
|
||||
e.inputEvent = ANYKEY;
|
||||
@ -134,8 +135,8 @@ int32_t KbI2cBase::runOnce()
|
||||
case 0x13: // Code scanner says the SYM key is 0x13
|
||||
is_sym = !is_sym;
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar =
|
||||
is_sym ? 0xf1 : 0xf2; // send 0xf1 to tell CannedMessages to display that the modifier key is active
|
||||
e.kbchar = is_sym ? CANNED_MESSAGE_KEY_FN_SYMBOL_ON // send 0xf1 to tell CannedMessages to display that
|
||||
: CANNED_MESSAGE_KEY_FN_SYMBOL_OFF; // the modifier key is active
|
||||
break;
|
||||
case 0x0a: // apparently Enter on Q10 is a line feed instead of carriage return
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT;
|
||||
@ -214,7 +215,7 @@ int32_t KbI2cBase::runOnce()
|
||||
if (is_sym) {
|
||||
is_sym = false;
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = 0xac; // mute notifications
|
||||
e.kbchar = CANNED_MESSAGE_KEY_MUTE_TOGGLE; // mute notifications
|
||||
} else {
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = c;
|
||||
@ -224,7 +225,7 @@ int32_t KbI2cBase::runOnce()
|
||||
if (is_sym) {
|
||||
is_sym = false;
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = 0x11; // Increase Brightness code
|
||||
e.kbchar = CANNED_MESSAGE_KEY_BRIGHTNESS_UP; // Increase Brightness code
|
||||
} else {
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = c;
|
||||
@ -234,7 +235,7 @@ int32_t KbI2cBase::runOnce()
|
||||
if (is_sym) {
|
||||
is_sym = false;
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = 0x12; // Decrease Brightness code
|
||||
e.kbchar = CANNED_MESSAGE_KEY_BRIGHTNESS_DOWN; // Decrease Brightness code
|
||||
} else {
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = c;
|
||||
@ -244,7 +245,7 @@ int32_t KbI2cBase::runOnce()
|
||||
if (is_sym) {
|
||||
is_sym = false;
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = 0xaf; // (fn + space)
|
||||
e.kbchar = CANNED_MESSAGE_KEY_SEND_PING; // (fn + space)
|
||||
} else {
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = c;
|
||||
@ -254,7 +255,7 @@ int32_t KbI2cBase::runOnce()
|
||||
if (is_sym) {
|
||||
is_sym = false;
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = 0x9e;
|
||||
e.kbchar = CANNED_MESSAGE_KEY_GPS_TOGGLE;
|
||||
} else {
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = c;
|
||||
@ -269,32 +270,33 @@ int32_t KbI2cBase::runOnce()
|
||||
break;
|
||||
case 0xb5: // Up
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_UP;
|
||||
e.kbchar = 0xb5;
|
||||
e.kbchar = CANNED_MESSAGE_KEY_UP;
|
||||
break;
|
||||
case 0xb6: // Down
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_DOWN;
|
||||
e.kbchar = 0xb6;
|
||||
e.kbchar = CANNED_MESSAGE_KEY_DOWN;
|
||||
break;
|
||||
case 0xb4: // Left
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT;
|
||||
e.kbchar = 0xb4;
|
||||
e.kbchar = CANNED_MESSAGE_KEY_LEFT;
|
||||
break;
|
||||
case 0xb7: // Right
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT;
|
||||
e.kbchar = 0xb7;
|
||||
e.kbchar = CANNED_MESSAGE_KEY_RIGHT;
|
||||
break;
|
||||
case 0xc: // Modifier key: 0xc is alt+c (Other options could be: 0xea = shift+mic button or 0x4 shift+$(speaker))
|
||||
// toggle moddifiers button.
|
||||
is_sym = !is_sym;
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = is_sym ? 0xf1 : 0xf2; // send 0xf1 to tell CannedMessages to display that the modifier key is active
|
||||
e.kbchar = is_sym ? CANNED_MESSAGE_KEY_FN_SYMBOL_ON // send 0xf1 to tell CannedMessages to display that the
|
||||
: CANNED_MESSAGE_KEY_FN_SYMBOL_OFF; // modifier key is active
|
||||
break;
|
||||
case 0x90: // fn+r
|
||||
case 0x90: // fn+r CANNED_MESSAGE_KEY_REBOOT
|
||||
case 0x91: // fn+t
|
||||
case 0x9b: // fn+s
|
||||
case 0xac: // fn+m
|
||||
case 0x9e: // fn+g
|
||||
case 0xaf: // fn+space
|
||||
case 0x9b: // fn+s CANNED_MESSAGE_KEY_SHUTDOWN
|
||||
case 0xac: // fn+m CANNED_MESSAGE_KEY_MUTE_TOGGLE
|
||||
case 0x9e: // fn+g CANNED_MESSAGE_KEY_GPS_TOGGLE
|
||||
case 0xaf: // fn+space CANNED_MESSAGE_KEY_SEND_PING
|
||||
// just pass those unmodified
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = c;
|
||||
|
@ -190,17 +190,17 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
|
||||
|
||||
#if defined(T_WATCH_S3) || defined(RAK14014)
|
||||
if (event->inputEvent == static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT)) {
|
||||
this->payload = 0xb4;
|
||||
this->payload = CANNED_MESSAGE_KEY_LEFT;
|
||||
} else if (event->inputEvent == static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT)) {
|
||||
this->payload = 0xb7;
|
||||
this->payload = CANNED_MESSAGE_KEY_RIGHT;
|
||||
}
|
||||
#else
|
||||
// tweak for left/right events generated via trackball/touch with empty kbchar
|
||||
if (!event->kbchar) {
|
||||
if (event->inputEvent == static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT)) {
|
||||
this->payload = 0xb4;
|
||||
this->payload = CANNED_MESSAGE_KEY_LEFT;
|
||||
} else if (event->inputEvent == static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT)) {
|
||||
this->payload = 0xb7;
|
||||
this->payload = CANNED_MESSAGE_KEY_RIGHT;
|
||||
}
|
||||
} else {
|
||||
// pass the pressed key
|
||||
@ -222,26 +222,26 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
|
||||
|
||||
// Run modifier key code below, (doesnt inturrupt typing or reset to start screen page)
|
||||
switch (event->kbchar) {
|
||||
case 0x11: // make screen brighter
|
||||
case CANNED_MESSAGE_KEY_BRIGHTNESS_UP: // make screen brighter
|
||||
if (screen)
|
||||
screen->increaseBrightness();
|
||||
LOG_DEBUG("increasing Screen Brightness\n");
|
||||
break;
|
||||
case 0x12: // make screen dimmer
|
||||
case CANNED_MESSAGE_KEY_BRIGHTNESS_DOWN: // make screen dimmer
|
||||
if (screen)
|
||||
screen->decreaseBrightness();
|
||||
LOG_DEBUG("Decreasing Screen Brightness\n");
|
||||
break;
|
||||
case 0xf1: // draw modifier (function) symbal
|
||||
case CANNED_MESSAGE_KEY_FN_SYMBOL_ON: // draw modifier (function) symbal
|
||||
if (screen)
|
||||
screen->setFunctionSymbal("Fn");
|
||||
break;
|
||||
case 0xf2: // remove modifier (function) symbal
|
||||
case CANNED_MESSAGE_KEY_FN_SYMBOL_OFF: // remove modifier (function) symbal
|
||||
if (screen)
|
||||
screen->removeFunctionSymbal("Fn");
|
||||
break;
|
||||
// mute (switch off/toggle) external notifications on fn+m
|
||||
case 0xac:
|
||||
case CANNED_MESSAGE_KEY_MUTE_TOGGLE:
|
||||
if (moduleConfig.external_notification.enabled == true) {
|
||||
if (externalNotificationModule->getMute()) {
|
||||
externalNotificationModule->setMute(false);
|
||||
@ -257,7 +257,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x9e: // toggle GPS like triple press does
|
||||
case CANNED_MESSAGE_KEY_GPS_TOGGLE: // toggle GPS like triple press does
|
||||
#if !MESHTASTIC_EXCLUDE_GPS
|
||||
if (gps != nullptr) {
|
||||
gps->toggleGpsMode();
|
||||
@ -267,7 +267,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
|
||||
showTemporaryMessage("GPS Toggled");
|
||||
#endif
|
||||
break;
|
||||
case 0xaf: // fn+space send network ping like double press does
|
||||
case CANNED_MESSAGE_KEY_SEND_PING: // fn+space send network ping like double press does
|
||||
service->refreshLocalMeshNode();
|
||||
if (service->trySendPosition(NODENUM_BROADCAST, true)) {
|
||||
showTemporaryMessage("Position \nUpdate Sent");
|
||||
@ -283,7 +283,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
|
||||
validEvent = true;
|
||||
break;
|
||||
}
|
||||
if (screen && (event->kbchar != 0xf1)) {
|
||||
if (screen && (event->kbchar != CANNED_MESSAGE_KEY_FN_SYMBOL_ON)) {
|
||||
screen->removeFunctionSymbal("Fn"); // remove modifier (function) symbal
|
||||
}
|
||||
}
|
||||
@ -505,7 +505,7 @@ int32_t CannedMessageModule::runOnce()
|
||||
}
|
||||
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT || this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) {
|
||||
switch (this->payload) {
|
||||
case 0xb4: // left
|
||||
case CANNED_MESSAGE_KEY_LEFT:
|
||||
if (this->destSelect == CANNED_MESSAGE_DESTINATION_TYPE_NODE) {
|
||||
size_t numMeshNodes = nodeDB->getNumMeshNodes();
|
||||
if (this->dest == NODENUM_BROADCAST) {
|
||||
@ -540,7 +540,7 @@ int32_t CannedMessageModule::runOnce()
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0xb7: // right
|
||||
case CANNED_MESSAGE_KEY_RIGHT:
|
||||
if (this->destSelect == CANNED_MESSAGE_DESTINATION_TYPE_NODE) {
|
||||
size_t numMeshNodes = nodeDB->getNumMeshNodes();
|
||||
if (this->dest == NODENUM_BROADCAST) {
|
||||
@ -602,19 +602,19 @@ int32_t CannedMessageModule::runOnce()
|
||||
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NODE;
|
||||
}
|
||||
break;
|
||||
case 0xb4: // left
|
||||
case 0xb7: // right
|
||||
case CANNED_MESSAGE_KEY_LEFT:
|
||||
case CANNED_MESSAGE_KEY_RIGHT:
|
||||
// already handled above
|
||||
break;
|
||||
// handle fn+s for shutdown
|
||||
case 0x9b:
|
||||
case CANNED_MESSAGE_KEY_SHUTDOWN:
|
||||
if (screen)
|
||||
screen->startAlert("Shutting down...");
|
||||
shutdownAtMsec = millis() + DEFAULT_SHUTDOWN_SECONDS * 1000;
|
||||
runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
|
||||
break;
|
||||
// and fn+r for reboot
|
||||
case 0x90:
|
||||
case CANNED_MESSAGE_KEY_REBOOT:
|
||||
if (screen)
|
||||
screen->startAlert("Rebooting...");
|
||||
rebootAtMsec = millis() + DEFAULT_REBOOT_SECONDS * 1000;
|
||||
|
@ -43,6 +43,20 @@ struct Letter {
|
||||
#define CANNED_MESSAGE_MODULE_ENABLE 0
|
||||
#endif
|
||||
|
||||
#define CANNED_MESSAGE_KEY_BRIGHTNESS_UP 0x11
|
||||
#define CANNED_MESSAGE_KEY_BRIGHTNESS_DOWN 0x12
|
||||
#define CANNED_MESSAGE_KEY_REBOOT 0x90
|
||||
#define CANNED_MESSAGE_KEY_SHUTDOWN 0x9b
|
||||
#define CANNED_MESSAGE_KEY_GPS_TOGGLE 0x9e
|
||||
#define CANNED_MESSAGE_KEY_MUTE_TOGGLE 0xac
|
||||
#define CANNED_MESSAGE_KEY_SEND_PING 0xaf
|
||||
#define CANNED_MESSAGE_KEY_LEFT 0xb4
|
||||
#define CANNED_MESSAGE_KEY_UP 0xb5
|
||||
#define CANNED_MESSAGE_KEY_DOWN 0xb6
|
||||
#define CANNED_MESSAGE_KEY_RIGHT 0xb7
|
||||
#define CANNED_MESSAGE_KEY_FN_SYMBOL_ON 0xf1
|
||||
#define CANNED_MESSAGE_KEY_FN_SYMBOL_OFF 0xf2
|
||||
|
||||
class CannedMessageModule : public SinglePortModule, public Observable<const UIFrameEvent *>, private concurrency::OSThread
|
||||
{
|
||||
CallbackObserver<CannedMessageModule, const InputEvent *> inputObserver =
|
||||
|
Loading…
Reference in New Issue
Block a user