Gather canned message magic numbers into header defines.

This commit is contained in:
Robert Fisk
2024-09-04 06:20:26 -04:00
committed by Thomas Göttgens
parent 55292f8a84
commit 8e0a342f06
5 changed files with 58 additions and 40 deletions

View File

@@ -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;