mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-20 17:52:35 +00:00
MPR121 Touch IC Based Keypad Input Module (#5103)
Implements an input driver utilising the MPR121 Touch IC and is compatible with common MPR121 keypad PCB's. - Implements a "candybar" phone style 12-key keypad - multiple taps to rotate through the character set - longpress for navigation keys - keymap to allow arbitrary routing of MPR121 pin to button configuration - extendable to other key functions - Integrates with the existing kbI2cBase implementation - Works with CannedMessageModule Freetext mode - Can be used with common MPR121 boards, such as https://www.amazon.com/MPR121-Capacitive-Keyboard-Buttons-Sensitive/dp/B083R89CHB/ref=sr_1_6 - Of use for PCB based radios, where some form of low surface area low component freetext input is required, but also without consuming too many IO pins. - Tested on a T3S3 connected to Wire1 (Second) interface. - Demonstration of functionality: https://youtu.be/UI6QP6nGvhY
This commit is contained in:
@@ -40,6 +40,9 @@ int32_t KbI2cBase::runOnce()
|
||||
Q10keyboard.begin(BBQ10_KB_ADDR, &Wire1);
|
||||
Q10keyboard.setBacklight(0);
|
||||
}
|
||||
if (cardkb_found.address == MPR121_KB_ADDR) {
|
||||
MPRkeyboard.begin(MPR121_KB_ADDR, &Wire1);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case ScanI2C::WIRE:
|
||||
@@ -49,6 +52,9 @@ int32_t KbI2cBase::runOnce()
|
||||
Q10keyboard.begin(BBQ10_KB_ADDR, &Wire);
|
||||
Q10keyboard.setBacklight(0);
|
||||
}
|
||||
if (cardkb_found.address == MPR121_KB_ADDR) {
|
||||
MPRkeyboard.begin(MPR121_KB_ADDR, &Wire);
|
||||
}
|
||||
break;
|
||||
case ScanI2C::NO_I2C:
|
||||
default:
|
||||
@@ -157,6 +163,69 @@ int32_t KbI2cBase::runOnce()
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x37: { // MPR121
|
||||
MPRkeyboard.trigger();
|
||||
InputEvent e;
|
||||
|
||||
while (MPRkeyboard.hasEvent()) {
|
||||
char nextEvent = MPRkeyboard.dequeueEvent();
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = 0x00;
|
||||
e.source = this->_originName;
|
||||
switch (nextEvent) {
|
||||
case 0x00: // MPR121_NONE
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
case 0x90: // MPR121_REBOOT
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = INPUT_BROKER_MSG_REBOOT;
|
||||
break;
|
||||
case 0xb4: // MPR121_LEFT
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
case 0xb5: // MPR121_UP
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_UP;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
case 0xb6: // MPR121_DOWN
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_DOWN;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
case 0xb7: // MPR121_RIGHT
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
case 0x1b: // MPR121_ESC
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_CANCEL;
|
||||
e.kbchar = 0x1b;
|
||||
break;
|
||||
case 0x08: // MPR121_BSP
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_BACK;
|
||||
e.kbchar = 0x08;
|
||||
break;
|
||||
case 0x0d: // MPR121_SELECT
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT;
|
||||
e.kbchar = 0x0d;
|
||||
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("MP121 Notifying: %i Char: %i", e.inputEvent, e.kbchar);
|
||||
this->notifyObservers(&e);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x02: {
|
||||
// RAK14004
|
||||
uint8_t rDataBuf[8] = {0};
|
||||
|
||||
Reference in New Issue
Block a user