Trunk fmt

This commit is contained in:
Ben Meadors 2024-07-31 07:42:23 -05:00
parent 106a50bce2
commit 24ecfa1a45
4 changed files with 53 additions and 70 deletions

View File

@ -21,14 +21,13 @@ unsigned char KeyMap[3][4][10]= {{{'.','a','d','g','j','m','p','t','w',' '},
#endif
SerialKeyboard::SerialKeyboard(const char *name) : concurrency::OSThread(name)
{
this->_originName = name;
}
void SerialKeyboard::erase(){
void SerialKeyboard::erase()
{
InputEvent e;
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_BACK;
e.kbchar = 0x08;
@ -36,7 +35,6 @@ void SerialKeyboard::erase(){
this->notifyObservers(&e);
}
int32_t SerialKeyboard::runOnce()
{
if (!INPUTBROKER_SERIAL_TYPE) {
@ -79,54 +77,43 @@ int32_t SerialKeyboard::runOnce()
quickPress = 0;
}
if (keys < prevKeys) { // a new key has been pressed (and not released), doesn't works for multiple presses at once but shouldn't be a limitation
if (keys < prevKeys) { // a new key has been pressed (and not released), doesn't works for multiple presses at once but
// shouldn't be a limitation
InputEvent e;
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
e.source = this->_originName;
// SELECT OR SEND OR CANCEL EVENT
if (!(shiftRegister2 & (1 << 3))) {
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_UP;
}
else if (!(shiftRegister2 & (1 << 2))) {
} else if (!(shiftRegister2 & (1 << 2))) {
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT;
e.kbchar = 0xb7;
}
else if (!(shiftRegister2 & (1 << 1))) {
} else if (!(shiftRegister2 & (1 << 1))) {
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT;
}
else if (!(shiftRegister2 & (1 << 0))) {
} else if (!(shiftRegister2 & (1 << 0))) {
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_CANCEL;
}
// TEXT INPUT EVENT
else if (!(shiftRegister1 & (1 << 4))) {
keyPressed = 0;
}
else if (!(shiftRegister1 & (1 << 3))) {
} else if (!(shiftRegister1 & (1 << 3))) {
keyPressed = 1;
}
else if (!(shiftRegister2 & (1 << 4))) {
} else if (!(shiftRegister2 & (1 << 4))) {
keyPressed = 2;
}
else if (!(shiftRegister1 & (1 << 5))) {
} else if (!(shiftRegister1 & (1 << 5))) {
keyPressed = 3;
}
else if (!(shiftRegister1 & (1 << 2))) {
} else if (!(shiftRegister1 & (1 << 2))) {
keyPressed = 4;
}
else if (!(shiftRegister2 & (1 << 5))) {
} else if (!(shiftRegister2 & (1 << 5))) {
keyPressed = 5;
}
else if (!(shiftRegister1 & (1 << 6))) {
} else if (!(shiftRegister1 & (1 << 6))) {
keyPressed = 6;
}
else if (!(shiftRegister1 & (1 << 1))) {
} else if (!(shiftRegister1 & (1 << 1))) {
keyPressed = 7;
}
else if (!(shiftRegister2 & (1 << 6))) {
} else if (!(shiftRegister2 & (1 << 6))) {
keyPressed = 8;
}
else if (!(shiftRegister1 & (1 << 0))) {
} else if (!(shiftRegister1 & (1 << 0))) {
keyPressed = 9;
}
// BACKSPACE or TAB
@ -144,7 +131,6 @@ int32_t SerialKeyboard::runOnce()
keyPressed = 10;
}
if (keyPressed < 11) {
if (keyPressed == lastKeyPressed && millis() - lastPressTime < 500) {
quickPress += 1;
@ -161,8 +147,7 @@ int32_t SerialKeyboard::runOnce()
}
e.inputEvent = ANYKEY;
e.kbchar = char(KeyMap[shift][quickPress][keyPressed]);
}
else { //then it's shift
} else { // then it's shift
shift += 1;
if (shift > 2) {
shift = 0;
@ -178,10 +163,8 @@ int32_t SerialKeyboard::runOnce()
}
}
prevKeys = keys;
}
return 50;
}
#endif // INPUTBROKER_SERIAL_TYPE

View File

@ -1,6 +1,6 @@
#include "configuration.h"
#include "InputBroker.h"
#include "SerialKeyboardImpl.h"
#include "InputBroker.h"
#include "configuration.h"
#ifdef INPUTBROKER_SERIAL_TYPE

View File

@ -2,11 +2,11 @@
#if !MESHTASTIC_EXCLUDE_INPUTBROKER
#include "input/InputBroker.h"
#include "input/RotaryEncoderInterruptImpl1.h"
#include "input/SerialKeyboardImpl.h"
#include "input/TrackballInterruptImpl1.h"
#include "input/UpDownInterruptImpl1.h"
#include "input/cardKbI2cImpl.h"
#include "input/kbMatrixImpl.h"
#include "input/SerialKeyboardImpl.h"
#endif
#if !MESHTASTIC_EXCLUDE_ADMIN
#include "modules/AdminModule.h"