mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-16 06:47:52 +00:00
initial draft
This commit is contained in:
committed by
Thomas Göttgens
parent
070deb290f
commit
f6ee533f41
@@ -158,6 +158,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define LTR390UV_ADDR 0x53
|
||||
#define XPOWERS_AXP192_AXP2101_ADDRESS 0x34 // same adress as TCA8418
|
||||
#define PCT2075_ADDR 0x37
|
||||
#define BQ27220_ADDR 0x55 // same address as TDECK_KB
|
||||
#define BQ25896_ADDR 0x6B
|
||||
#define LTR553ALS_ADDR 0x23
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// ACCELEROMETER
|
||||
@@ -171,6 +174,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define BMX160_ADDR 0x69
|
||||
#define ICM20948_ADDR 0x69
|
||||
#define ICM20948_ADDR_ALT 0x68
|
||||
#define BHI260AP_ADDR 0x28
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// LED
|
||||
@@ -192,6 +196,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// Touchscreen
|
||||
// -----------------------------------------------------------------------------
|
||||
#define FT6336U_ADDR 0x48
|
||||
#define CST328_ADDR 0x1A
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// BIAS-T Generator
|
||||
|
||||
@@ -72,6 +72,11 @@ class ScanI2C
|
||||
LTR390UV,
|
||||
TCA8418KB,
|
||||
PCT2075,
|
||||
CST328,
|
||||
BQ25896,
|
||||
BQ27220,
|
||||
LTR553ALS,
|
||||
BHI260AP
|
||||
} DeviceType;
|
||||
|
||||
// typedef uint8_t DeviceAddress;
|
||||
|
||||
@@ -206,7 +206,17 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
||||
}
|
||||
break;
|
||||
|
||||
SCAN_SIMPLE_CASE(TDECK_KB_ADDR, TDECKKB, "T-Deck keyboard", (uint8_t)addr.address);
|
||||
case TDECK_KB_ADDR:
|
||||
// Do we have the T-Deck keyboard or the T-Deck Pro battery sensor?
|
||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x40), 2); // MACData
|
||||
if (registerValue != 0) {
|
||||
logFoundDevice("BQ27220", (uint8_t)addr.address);
|
||||
type = BQ27220;
|
||||
} else {
|
||||
logFoundDevice("TDECKKB", (uint8_t)addr.address);
|
||||
type = TDECKKB;
|
||||
}
|
||||
break;
|
||||
SCAN_SIMPLE_CASE(BBQ10_KB_ADDR, BBQ10KB, "BB Q10", (uint8_t)addr.address);
|
||||
|
||||
SCAN_SIMPLE_CASE(ST7567_ADDRESS, SCREEN_ST7567, "ST7567", (uint8_t)addr.address);
|
||||
@@ -396,6 +406,12 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
||||
logFoundDevice("BQ24295", (uint8_t)addr.address);
|
||||
break;
|
||||
}
|
||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x14), 1); // get ID
|
||||
if ((registerValue & 0b00000011) == 0b00000010) {
|
||||
type = BQ25896;
|
||||
logFoundDevice("BQ25896", (uint8_t)addr.address);
|
||||
break;
|
||||
}
|
||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x0F), 1); // get ID
|
||||
if (registerValue == 0x6A) {
|
||||
type = LSM6DS3;
|
||||
@@ -435,6 +451,9 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
||||
SCAN_SIMPLE_CASE(DFROBOT_RAIN_ADDR, DFROBOT_RAIN, "DFRobot Rain Gauge", (uint8_t)addr.address);
|
||||
SCAN_SIMPLE_CASE(LTR390UV_ADDR, LTR390UV, "LTR390UV", (uint8_t)addr.address);
|
||||
SCAN_SIMPLE_CASE(PCT2075_ADDR, PCT2075, "PCT2075", (uint8_t)addr.address);
|
||||
SCAN_SIMPLE_CASE(CST328_ADDR, CST328, "CST328", (uint8_t)addr.address);
|
||||
SCAN_SIMPLE_CASE(LTR553ALS_ADDR, LTR553ALS, "LTR553ALS", (uint8_t)addr.address);
|
||||
SCAN_SIMPLE_CASE(BHI260AP_ADDR, BHI260AP, "BHI260AP", (uint8_t)addr.address);
|
||||
#ifdef HAS_TPS65233
|
||||
SCAN_SIMPLE_CASE(TPS65233_ADDR, TPS65233, "TPS65233", (uint8_t)addr.address);
|
||||
#endif
|
||||
|
||||
@@ -203,7 +203,7 @@ bool EInkDisplay::connect()
|
||||
adafruitDisplay->setRotation(0);
|
||||
adafruitDisplay->setPartialWindow(0, 0, EINK_WIDTH, EINK_HEIGHT);
|
||||
}
|
||||
#elif defined(M5_COREINK)
|
||||
#elif defined(M5_COREINK) || defined(T_DECK_PRO)
|
||||
auto lowLevel = new EINK_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY);
|
||||
adafruitDisplay = new GxEPD2_BW<EINK_DISPLAY_MODEL, EINK_DISPLAY_MODEL::HEIGHT>(*lowLevel);
|
||||
adafruitDisplay->init(115200, true, 40, false, SPI, SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
||||
|
||||
@@ -103,10 +103,70 @@ enum {
|
||||
_TCA8418_COL9 // Pin ID for column 9
|
||||
};
|
||||
|
||||
#if defined(T_DECK_PRO)
|
||||
#define _TCA8418_COLS 10
|
||||
#define _TCA8418_ROWS 4
|
||||
#define _TCA8418_NUM_KEYS 35
|
||||
|
||||
#define _TCA8418_LONG_PRESS_THRESHOLD 2000
|
||||
#define _TCA8418_MULTI_TAP_THRESHOLD 1500
|
||||
|
||||
// Num chars per key, Modulus for rotating through characters
|
||||
uint8_t TCA8418TapMod[_TCA8418_NUM_KEYS] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3};
|
||||
|
||||
// https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
|
||||
unsigned char TCA8418TapMap[_TCA8418_NUM_KEYS][3] = {{'p', 'P', '@'},
|
||||
{'o', 'O', '+'},
|
||||
{'i', 'I', '-'},
|
||||
{'u', 'U', '_'},
|
||||
{'y', 'Y', ')'},
|
||||
{'t', 'T', '('},
|
||||
{'r', 'R', '3'},
|
||||
{'e', 'E', '2'},
|
||||
{'w', 'W', '1'},
|
||||
{'q', 'Q', '#'},
|
||||
{_TCA8418_BSP, 0x00, 0x00},
|
||||
{'l', 'L', '"'},
|
||||
{'k', 'K', '\''},
|
||||
{'j', 'J', ';'},
|
||||
{'h', 'H', ':'},
|
||||
{'g', 'G', '/'},
|
||||
{'f', 'F', '6'},
|
||||
{'d', 'D', '5'},
|
||||
{'s', 'S', '4'},
|
||||
{'a', 'A', '*'},
|
||||
{0x0d, 0x00, 0x00},
|
||||
{'$', 0x00, 0x00},
|
||||
{'m', 'M', '.'},
|
||||
{'n', 'N', ','},
|
||||
{'b', 'B', '!'},
|
||||
{'v', 'V', '?'},
|
||||
{'c', 'C', '9'},
|
||||
{'x', 'X', '8'},
|
||||
{'z', 'Z', '7'},
|
||||
{0xa4, 0x00, 0x00},
|
||||
{0xa1, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00},
|
||||
{0x20, 0x00, 0x00},
|
||||
{0x00, 0x00, '0'},
|
||||
{0xa0, 0x00, 0x00}};
|
||||
|
||||
unsigned char TCA8418LongPressMap[_TCA8418_NUM_KEYS] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, _TCA8418_ESC, // p,o,i,u,y,t,r,e,w,q
|
||||
0x00, 0x00, 0x00, 0xb5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // bsp,l,k,j,h,g,f,d,s,a
|
||||
0x00, 0x00, 0xb7, 0xb6, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, // ent,$,m,n,b,v,c,x,z,alt
|
||||
0x00, 0x00, 0x00, 0x00, 0x00 // rShift,sym,space,mic,lShift
|
||||
};
|
||||
|
||||
#else
|
||||
#define _TCA8418_COLS 3
|
||||
#define _TCA8418_ROWS 4
|
||||
#define _TCA8418_NUM_KEYS 12
|
||||
|
||||
#define _TCA8418_LONG_PRESS_THRESHOLD 2000
|
||||
#define _TCA8418_MULTI_TAP_THRESHOLD 750
|
||||
|
||||
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
|
||||
|
||||
@@ -139,9 +199,7 @@ unsigned char TCA8418LongPressMap[_TCA8418_NUM_KEYS] = {
|
||||
_TCA8418_NONE, // 0
|
||||
_TCA8418_NONE, // #
|
||||
};
|
||||
|
||||
#define _TCA8418_LONG_PRESS_THRESHOLD 2000
|
||||
#define _TCA8418_MULTI_TAP_THRESHOLD 750
|
||||
#endif
|
||||
|
||||
TCA8418Keyboard::TCA8418Keyboard() : m_wire(nullptr), m_addr(0), readCallback(nullptr), writeCallback(nullptr)
|
||||
{
|
||||
@@ -182,10 +240,14 @@ void TCA8418Keyboard::reset()
|
||||
// set default all GIO pins to INPUT
|
||||
writeRegister(_TCA8418_REG_GPIO_DIR_1, 0x00);
|
||||
writeRegister(_TCA8418_REG_GPIO_DIR_2, 0x00);
|
||||
#ifndef T_DECK_PRO
|
||||
// Set COL9 as GPIO output
|
||||
writeRegister(_TCA8418_REG_GPIO_DIR_3, 0x02);
|
||||
// Switch off keyboard backlight (COL9 = LOW)
|
||||
writeRegister(_TCA8418_REG_GPIO_DAT_OUT_3, 0x00);
|
||||
#else
|
||||
writeRegister(_TCA8418_REG_GPIO_DIR_3, 0x00);
|
||||
#endif
|
||||
|
||||
// add all pins to key events
|
||||
writeRegister(_TCA8418_REG_GPI_EM_1, 0xFF);
|
||||
@@ -516,11 +578,19 @@ void TCA8418Keyboard::disableDebounce()
|
||||
|
||||
void TCA8418Keyboard::setBacklight(bool on)
|
||||
{
|
||||
#ifdef T_DECK_PRO
|
||||
if (on) {
|
||||
digitalWrite(KB_BL_PIN, HIGH);
|
||||
} else {
|
||||
digitalWrite(KB_BL_PIN, LOW);
|
||||
}
|
||||
#else
|
||||
if (on) {
|
||||
digitalWrite(_TCA8418_COL9, HIGH);
|
||||
} else {
|
||||
digitalWrite(_TCA8418_COL9, LOW);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t TCA8418Keyboard::readRegister(uint8_t reg) const
|
||||
|
||||
13
src/main.cpp
13
src/main.cpp
@@ -363,6 +363,19 @@ void setup()
|
||||
pinMode(TFT_CS, OUTPUT);
|
||||
digitalWrite(TFT_CS, HIGH);
|
||||
delay(100);
|
||||
#elif defined(T_DECK_PRO)
|
||||
pinMode(LORA_EN, OUTPUT);
|
||||
digitalWrite(LORA_EN, HIGH);
|
||||
// pinMode(BOARD_1V8_EN, OUTPUT);
|
||||
// digitalWrite(BOARD_1V8_EN, HIGH);
|
||||
// pinMode(BOARD_6609_EN, OUTPUT);
|
||||
// digitalWrite(BOARD_6609_EN, HIGH);
|
||||
pinMode(LORA_CS, OUTPUT);
|
||||
digitalWrite(LORA_CS, HIGH);
|
||||
pinMode(SDCARD_CS, OUTPUT);
|
||||
digitalWrite(SDCARD_CS, HIGH);
|
||||
pinMode(PIN_EINK_CS, OUTPUT);
|
||||
digitalWrite(PIN_EINK_CS, HIGH);
|
||||
#endif
|
||||
|
||||
concurrency::hasBeenSetup = true;
|
||||
|
||||
46
src/platform/extra_variants/t_deck_pro/variant.cpp
Normal file
46
src/platform/extra_variants/t_deck_pro/variant.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "configuration.h"
|
||||
|
||||
#ifdef T_DECK_PRO
|
||||
|
||||
#include "input/TouchScreenImpl1.h"
|
||||
#include <CSE_CST328.h>
|
||||
#include <Wire.h>
|
||||
|
||||
CSE_CST328 tsPanel = CSE_CST328(EINK_WIDTH, EINK_HEIGHT, &Wire, CST328_PIN_RST, CST328_PIN_INT);
|
||||
|
||||
volatile bool intReceived = false;
|
||||
|
||||
void touchISR()
|
||||
{
|
||||
// Detach the interrupt to prevent multiple interrupts
|
||||
detachInterrupt(digitalPinToInterrupt(CST328_PIN_INT));
|
||||
intReceived = true;
|
||||
}
|
||||
|
||||
bool readTouch(int16_t *x, int16_t *y)
|
||||
{
|
||||
if (1 /* intReceived */) {
|
||||
intReceived = false;
|
||||
// Reattach the interrupt for the next touch
|
||||
// attachInterrupt (digitalPinToInterrupt(CST328_PIN_INT), touchISR, FALLING);
|
||||
|
||||
// Read the touch point
|
||||
// if (tsPanel.isTouched(0)) {
|
||||
if (tsPanel.getTouches()) {
|
||||
*x = tsPanel.getPoint(0).x;
|
||||
*y = tsPanel.getPoint(0).y;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// T-Deck Pro specific init
|
||||
void lateInitVariant()
|
||||
{
|
||||
tsPanel.begin();
|
||||
// attachInterrupt (digitalPinToInterrupt(CST328_PIN_INT), touchISR, FALLING);
|
||||
touchScreenImpl1 = new TouchScreenImpl1(EINK_WIDTH, EINK_HEIGHT, readTouch);
|
||||
touchScreenImpl1->init();
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user