Cardputer adv and more (#395)

- Fixed TCA8418 driver
- Updated T-Lora Pager for TCA driver fixes
- Fixed issues with T-Lora keyboard driver
- Implemented Cardputer Adv
- Cleanup of Cardputer (regular)
- Fix sdkconfig for E32R28T and E32R32P
- Disable Wi-Fi on boot (was accidentally pushed before)
This commit is contained in:
Ken Van Hoeylandt
2025-10-28 00:39:31 +01:00
committed by GitHub
parent 647678ff82
commit efd3c6041c
32 changed files with 742 additions and 60 deletions
@@ -0,0 +1,26 @@
Software License Agreement (BSD License)
Copyright (c) 2019 Limor Fried (Adafruit Industries)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+1
View File
@@ -2,3 +2,4 @@
[Datasheet](https://www.ti.com/lit/ds/symlink/tca8418.pdf?ts=1751500237439)
[Original implementation](https://github.com/AnthonyDiGirolamo/i2c-thumb-keyboard/tree/master) by Anthony DiGirolamo
[Adafruit TCA8418](https://github.com/adafruit/Adafruit_TCA8418)
+41 -13
View File
@@ -1,7 +1,7 @@
#include "Tca8418.h"
#include <Tactility/Log.h>
#define TAG "tca8418"
constexpr auto TAG = "TCA8418";
namespace registers {
static const uint8_t CFG = 0x01U;
@@ -22,6 +22,38 @@ static const uint8_t KEY_EVENT_J = 0x0DU;
} // namespace registers
/** From https://github.com/adafruit/Adafruit_TCA8418/blob/main/Adafruit_TCA8418.cpp */
bool Tca8418::initMatrix(uint8_t rows, uint8_t columns) {
if ((rows > 8) || (columns > 10))
return false;
if ((rows != 0) && (columns != 0)) {
// Configure the keypad matrix.
uint8_t mask = 0x00;
for (int r = 0; r < rows; r++) {
mask <<= 1;
mask |= 1;
}
writeRegister(registers::KP_GPIO1, &mask, 1);
mask = 0x00;
for (int c = 0; c < columns && c < 8; c++) {
mask <<= 1;
mask |= 1;
}
writeRegister(registers::KP_GPIO2, &mask, 1);
if (columns > 8) {
if (columns == 9)
mask = 0x01;
else
mask = 0x03;
writeRegister(registers::KP_GPIO3, &mask, 1);
}
}
return true;
}
void Tca8418::init(uint8_t numrows, uint8_t numcols) {
/*
* | ADDRESS | REGISTER NAME | REGISTER DESCRIPTION | BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0 |
@@ -34,13 +66,7 @@ void Tca8418::init(uint8_t numrows, uint8_t numcols) {
num_rows = numrows;
num_cols = numcols;
// everything enabled in key scan mode
uint8_t enabled_rows = 0x3F;
uint16_t enabled_cols = 0x3FF;
writeRegister8(registers::KP_GPIO1, enabled_rows);
writeRegister8(registers::KP_GPIO2, (uint8_t)(0xFF & enabled_cols));
writeRegister8(registers::KP_GPIO3, (uint8_t)(0x03 & (enabled_cols >> 8)));
initMatrix(num_rows, num_cols);
/*
* BIT: NAME
@@ -97,7 +123,7 @@ void Tca8418::init(uint8_t numrows, uint8_t numcols) {
bool Tca8418::update() {
last_update_micros = this_update_micros;
uint8_t key_code, key_down, key_event, key_row, key_col;
uint8_t key_down, key_event, key_row, key_col;
key_event = get_key_event();
// TODO: read gpio R7/R6 status? 0x14 bits 7&6
@@ -108,10 +134,12 @@ bool Tca8418::update() {
delta_micros = this_update_micros - last_update_micros;
if (key_event > 0) {
key_code = key_event & 0x7F;
key_down = (key_event & 0x80) >> 7;
key_row = key_code / num_cols;
key_col = key_code % num_cols;
key_down = (key_event & 0x80);
uint16_t buffer = key_event;
buffer &= 0x7F;
buffer--;
key_row = buffer / 10;
key_col = buffer % 10;
// always clear the released list
clear_released_list();
+7 -2
View File
@@ -4,9 +4,12 @@
#include <Tactility/hal/i2c/I2cDevice.h>
#define TCA8418_ADDRESS 0x34U
#define KEY_EVENT_LIST_SIZE 10
constexpr auto TCA8418_ADDRESS = 0x34U;
constexpr auto KEY_EVENT_LIST_SIZE = 10;
/**
* See https://www.ti.com/lit/ds/symlink/tca8418.pdf
*/
class Tca8418 final : public tt::hal::i2c::I2cDevice {
uint8_t tca8418_address;
@@ -23,6 +26,8 @@ class Tca8418 final : public tt::hal::i2c::I2cDevice {
void write(uint8_t register_address, uint8_t data);
bool read(uint8_t register_address, uint8_t* data);
bool initMatrix(uint8_t rows, uint8_t columns);
public:
struct PressedKey {