TCA8418 initial config + basic 3x4 keypad config (#6320)

* add TCA8418 to configuration.h

added the TCA8418

* add TCA8418 to ScanI2C.cpp

add TCA8418

* add TCA8418KB to ScanI2C.h

add TCA8418KB

* add TCA8418KB ScanI2CTwoWire.cpp

add TCA8418KB

* Create TCA8418Keyboard.cpp

Create TCA8418Keyboard.cpp

* Create TCA8418Keyboard.h

Create TCA8418Keyboard.h

* add TCA8418 to kbI2cBase.cpp

add TCA8418

* add TCA8418 to kbI2cBase.h

add TCA8418

* add TCA8418KB to main.cpp

add TCA8418KB

* add TCA8418KB to cardKbI2cImpl.cpp

add TCA8418KB

* Update TCA8418 kbI2cBase.cpp

* enable debug TCA8418

* Nokia 5130 config

* Update TCA8418Keyboard.h

old version in initial commit

* Update ScanI2CTwoWire.cpp

* add tap_interval and backlight_on to constructor

* Create TCA8418-layouts.cpp

TCA8418-layout

3x4 should work

Nokia 5130 needs editing.

* put layouts in different file + adjusted code for variable matrix sizes

* rename TCA8418-layouts.cpp to TCA8418Layouts.cpp + add endif

* Update TCA8418Keyboard.cpp name change layouts

* forgot a \

* Create TCA8418Layouts.h

* Update TCA8418Keyboard.cpp

* add include

forgot include

* Update TCA8418Keyboard.cpp

* Update TCA8418Keyboard.h

* Update TCA8418Layouts.h

* revert to keyboard layout in main TCA8418Keyboard.cpp

* fixed the address

* changed ordering of constructor

* reflect changes #6371

* edit config.h

* bug fix fast pressing multiple buttons + clean up scanI2CTwoWire.cpp

* trunked

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
Co-authored-by: Tom Fifield <tom@tomfifield.net>
This commit is contained in:
Nasimovy
2025-03-26 02:29:18 +00:00
committed by GitHub
parent d28af68b5a
commit 13101c1bab
10 changed files with 750 additions and 19 deletions

View File

@@ -43,6 +43,9 @@ int32_t KbI2cBase::runOnce()
if (cardkb_found.address == MPR121_KB_ADDR) {
MPRkeyboard.begin(MPR121_KB_ADDR, &Wire1);
}
if (cardkb_found.address == XPOWERS_AXP192_AXP2101_ADDRESS) {
TCAKeyboard.begin(XPOWERS_AXP192_AXP2101_ADDRESS, &Wire1);
}
break;
#endif
case ScanI2C::WIRE:
@@ -55,6 +58,9 @@ int32_t KbI2cBase::runOnce()
if (cardkb_found.address == MPR121_KB_ADDR) {
MPRkeyboard.begin(MPR121_KB_ADDR, &Wire);
}
if (cardkb_found.address == XPOWERS_AXP192_AXP2101_ADDRESS) {
TCAKeyboard.begin(XPOWERS_AXP192_AXP2101_ADDRESS, &Wire);
}
break;
case ScanI2C::NO_I2C:
default:
@@ -163,6 +169,70 @@ int32_t KbI2cBase::runOnce()
}
break;
}
case 0x84: { // Adafruit TCA8418
TCAKeyboard.trigger();
InputEvent e;
while (TCAKeyboard.hasEvent()) {
char nextEvent = TCAKeyboard.dequeueEvent();
e.inputEvent = ANYKEY;
e.kbchar = 0x00;
e.source = this->_originName;
switch (nextEvent) {
case _TCA8418_NONE:
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
e.kbchar = 0x00;
break;
case _TCA8418_REBOOT:
e.inputEvent = ANYKEY;
e.kbchar = INPUT_BROKER_MSG_REBOOT;
break;
case _TCA8418_LEFT:
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT;
e.kbchar = 0x00;
break;
case _TCA8418_UP:
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_UP;
e.kbchar = 0x00;
break;
case _TCA8418_DOWN:
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_DOWN;
e.kbchar = 0x00;
break;
case _TCA8418_RIGHT:
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT;
e.kbchar = 0x00;
break;
case _TCA8418_BSP:
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_BACK;
e.kbchar = 0x08;
break;
case _TCA8418_SELECT:
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT;
e.kbchar = 0x0d;
break;
case _TCA8418_ESC:
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_CANCEL;
e.kbchar = 0x1b;
break;
default:
if (nextEvent > 127) {
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
e.kbchar = 0x00;
break;
}
e.inputEvent = ANYKEY;
e.kbchar = nextEvent;
break;
}
if (e.inputEvent != meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE) {
LOG_DEBUG("TCA8418 Notifying: %i Char: %c", e.inputEvent, e.kbchar);
this->notifyObservers(&e);
}
}
break;
}
case 0x37: { // MPR121
MPRkeyboard.trigger();
InputEvent e;