This commit is contained in:
nasimovy 2025-03-25 17:27:06 +00:00
parent 92b3b208c4
commit 5a72eeae61
4 changed files with 39 additions and 41 deletions

View File

@ -157,7 +157,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MLX90614_ADDR_DEF 0x5A #define MLX90614_ADDR_DEF 0x5A
#define CGRADSENS_ADDR 0x66 #define CGRADSENS_ADDR 0x66
#define LTR390UV_ADDR 0x53 #define LTR390UV_ADDR 0x53
#define XPOWERS_AXP192_AXP2101_ADDRESS 0x34 //same adress as TCA8418 #define XPOWERS_AXP192_AXP2101_ADDRESS 0x34 // same adress as TCA8418
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// ACCELEROMETER // ACCELEROMETER
@ -375,4 +375,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#endif #endif
#include "DebugConfiguration.h" #include "DebugConfiguration.h"
#include "RF95Configuration.h" #include "RF95Configuration.h"

View File

@ -17,7 +17,7 @@ class ScanI2C
CARDKB, CARDKB,
TDECKKB, TDECKKB,
BBQ10KB, BBQ10KB,
RAK14004, RAK14004,
PMU_AXP192_AXP2101, // has the same address as the TCA8418KB PMU_AXP192_AXP2101, // has the same address as the TCA8418KB
BME_680, BME_680,
BME_280, BME_280,
@ -133,4 +133,4 @@ class ScanI2C
private: private:
bool shouldSuppressScreen = false; bool shouldSuppressScreen = false;
}; };

View File

@ -107,42 +107,42 @@ enum {
#define _TCA8418_ROWS 4 #define _TCA8418_ROWS 4
#define _TCA8418_NUM_KEYS 12 #define _TCA8418_NUM_KEYS 12
uint8_t TCA8418TapMod[_TCA8418_NUM_KEYS] = {13, 7, 7, 7, 7, 7, 9, 7, 9, 2, 2, 2}; // Num chars per key, Modulus for rotating through characters uint8_t TCA8418TapMod[_TCA8418_NUM_KEYS] = {13, 7, 7, 7, 7, 7,
9, 7, 9, 2, 2, 2}; // Num chars per key, Modulus for rotating through characters
unsigned char TCA8418TapMap[_TCA8418_NUM_KEYS][13] = { unsigned char TCA8418TapMap[_TCA8418_NUM_KEYS][13] = {
{'1', '.', ',', '?', '!', ':', ';', '-', '_', '\\', '/', '(', ')'}, // 1 {'1', '.', ',', '?', '!', ':', ';', '-', '_', '\\', '/', '(', ')'}, // 1
{'2', 'a', 'b', 'c', 'A', 'B', 'C'}, // 2 {'2', 'a', 'b', 'c', 'A', 'B', 'C'}, // 2
{'3', 'd', 'e', 'f', 'D', 'E', 'F'}, // 3 {'3', 'd', 'e', 'f', 'D', 'E', 'F'}, // 3
{'4', 'g', 'h', 'i', 'G', 'H', 'I'}, // 4 {'4', 'g', 'h', 'i', 'G', 'H', 'I'}, // 4
{'5', 'j', 'k', 'l', 'J', 'K', 'L'}, // 5 {'5', 'j', 'k', 'l', 'J', 'K', 'L'}, // 5
{'6', 'm', 'n', 'o', 'M', 'N', 'O'}, // 6 {'6', 'm', 'n', 'o', 'M', 'N', 'O'}, // 6
{'7', 'p', 'q', 'r', 's', 'P', 'Q', 'R', 'S'}, // 7 {'7', 'p', 'q', 'r', 's', 'P', 'Q', 'R', 'S'}, // 7
{'8', 't', 'u', 'v', 'T', 'U', 'V'}, // 8 {'8', 't', 'u', 'v', 'T', 'U', 'V'}, // 8
{'9', 'w', 'x', 'y', 'z', 'W', 'X', 'Y', 'Z'}, // 9 {'9', 'w', 'x', 'y', 'z', 'W', 'X', 'Y', 'Z'}, // 9
{'*', '+'}, // * {'*', '+'}, // *
{'0', ' '}, // 0 {'0', ' '}, // 0
{'#', '@'}, // # {'#', '@'}, // #
}; };
unsigned char TCA8418LongPressMap[_TCA8418_NUM_KEYS] = { unsigned char TCA8418LongPressMap[_TCA8418_NUM_KEYS] = {
_TCA8418_ESC, // 1 _TCA8418_ESC, // 1
_TCA8418_UP, // 2 _TCA8418_UP, // 2
_TCA8418_NONE, // 3 _TCA8418_NONE, // 3
_TCA8418_LEFT, // 4 _TCA8418_LEFT, // 4
_TCA8418_NONE, // 5 _TCA8418_NONE, // 5
_TCA8418_RIGHT, // 6 _TCA8418_RIGHT, // 6
_TCA8418_NONE, // 7 _TCA8418_NONE, // 7
_TCA8418_DOWN, // 8 _TCA8418_DOWN, // 8
_TCA8418_NONE, // 9 _TCA8418_NONE, // 9
_TCA8418_BSP, // * _TCA8418_BSP, // *
_TCA8418_NONE, // 0 _TCA8418_NONE, // 0
_TCA8418_NONE, // # _TCA8418_NONE, // #
}; };
#define _TCA8418_LONG_PRESS_THRESHOLD 2000 #define _TCA8418_LONG_PRESS_THRESHOLD 2000
#define _TCA8418_MULTI_TAP_THRESHOLD 750 #define _TCA8418_MULTI_TAP_THRESHOLD 750
TCA8418Keyboard::TCA8418Keyboard() : m_wire(nullptr), m_addr(0), readCallback(nullptr), writeCallback(nullptr) TCA8418Keyboard::TCA8418Keyboard() : m_wire(nullptr), m_addr(0), readCallback(nullptr), writeCallback(nullptr)
{ {
state = Init; state = Init;
@ -306,9 +306,9 @@ void TCA8418Keyboard::pressed(uint8_t key)
uint8_t next_key = 0; uint8_t next_key = 0;
int row = (key - 1) / 10; int row = (key - 1) / 10;
int col = (key - 1) % 10; int col = (key - 1) % 10;
if (row >= _TCA8418_ROWS || col >= _TCA8418_COLS) { if (row >= _TCA8418_ROWS || col >= _TCA8418_COLS) {
return; // Invalid key return; // Invalid key
} }
// Compute key index based on dynamic row/column // Compute key index based on dynamic row/column
@ -328,17 +328,16 @@ void TCA8418Keyboard::pressed(uint8_t key)
// Check if the key is the same as the last one or if the time interval has passed // Check if the key is the same as the last one or if the time interval has passed
if (next_key != last_key || tap_interval > _TCA8418_MULTI_TAP_THRESHOLD) { if (next_key != last_key || tap_interval > _TCA8418_MULTI_TAP_THRESHOLD) {
char_idx = 0; // Reset char index if new key or long press char_idx = 0; // Reset char index if new key or long press
should_backspace = false; // dont backspace on new key should_backspace = false; // dont backspace on new key
} else { } else {
char_idx += 1; // Cycle through characters if same key pressed char_idx += 1; // Cycle through characters if same key pressed
should_backspace = true; // allow backspace on same key should_backspace = true; // allow backspace on same key
} }
// Store the current key as the last key // Store the current key as the last key
last_key = next_key; last_key = next_key;
last_tap = now; last_tap = now;
} }
void TCA8418Keyboard::released() void TCA8418Keyboard::released()
@ -559,5 +558,4 @@ void TCA8418Keyboard::writeRegister(uint8_t reg, uint8_t value)
if (writeCallback) { if (writeCallback) {
writeCallback(m_addr, data[0], &(data[1]), 1); writeCallback(m_addr, data[0], &(data[1]), 1);
} }
} }

View File

@ -169,8 +169,8 @@ int32_t KbI2cBase::runOnce()
} }
break; break;
} }
case 0x84: { // Adafruit TCA8418 case 0x84: { // Adafruit TCA8418
TCAKeyboard.trigger(); TCAKeyboard.trigger();
InputEvent e; InputEvent e;
while (TCAKeyboard.hasEvent()) { while (TCAKeyboard.hasEvent()) {
@ -232,7 +232,7 @@ int32_t KbI2cBase::runOnce()
} }
break; break;
} }
case 0x37: { // MPR121 case 0x37: { // MPR121
MPRkeyboard.trigger(); MPRkeyboard.trigger();
InputEvent e; InputEvent e;
@ -468,4 +468,4 @@ int32_t KbI2cBase::runOnce()
LOG_WARN("Unknown kb_model 0x%02x", kb_model); LOG_WARN("Unknown kb_model 0x%02x", kb_model);
} }
return 300; return 300;
} }