mirror of
https://github.com/meshtastic/firmware.git
synced 2026-05-22 07:46:29 -04:00
Merge branch 'master' into master
This commit is contained in:
@@ -126,7 +126,7 @@ lib_deps =
|
||||
[device-ui_base]
|
||||
lib_deps =
|
||||
# renovate: datasource=git-refs depName=meshtastic/device-ui packageName=https://github.com/meshtastic/device-ui gitBranch=master
|
||||
https://github.com/meshtastic/device-ui/archive/5305670b68eb5b92d14e62b5b536969ca4bb441f.zip
|
||||
https://github.com/meshtastic/device-ui/archive/56e1da4e7d30abcd746a2092a30e422f8cf5fc2b.zip
|
||||
|
||||
; Common libs for environmental measurements in telemetry module
|
||||
[environmental_base]
|
||||
|
||||
@@ -95,7 +95,8 @@ class ScanI2C
|
||||
SFA30,
|
||||
CW2015,
|
||||
SCD30,
|
||||
ADS1115
|
||||
ADS1115,
|
||||
CST3530,
|
||||
} DeviceType;
|
||||
|
||||
// typedef uint8_t DeviceAddress;
|
||||
|
||||
@@ -589,21 +589,21 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
||||
{
|
||||
// T-Deck pro V1.1 new touch panel use CST3530
|
||||
int retry = 5;
|
||||
while(retry--) {
|
||||
while (retry--) {
|
||||
uint8_t buffer[7];
|
||||
uint8_t r_cmd[] = {0x0d0,0x03,0x00,0x00};
|
||||
uint8_t r_cmd[] = {0x0d0, 0x03, 0x00, 0x00};
|
||||
i2cBus->beginTransmission(addr.address);
|
||||
i2cBus->write(r_cmd, sizeof(r_cmd));
|
||||
if(i2cBus->endTransmission() == 0){
|
||||
i2cBus->requestFrom((int)addr.address,7);
|
||||
i2cBus->readBytes(buffer,7);
|
||||
if(buffer[2] == 0xCA && buffer[3] == 0xCA){
|
||||
if (i2cBus->endTransmission() == 0) {
|
||||
i2cBus->requestFrom((int)addr.address, 7);
|
||||
i2cBus->readBytes(buffer, 7);
|
||||
if (buffer[2] == 0xCA && buffer[3] == 0xCA) {
|
||||
logFoundDevice("CST3530", (uint8_t)addr.address);
|
||||
type = CST3530;
|
||||
break;
|
||||
}
|
||||
}
|
||||
uint8_t cmd1[] = {0xD0,0x00,0x04,0x00};
|
||||
uint8_t cmd1[] = {0xD0, 0x00, 0x04, 0x00};
|
||||
i2cBus->beginTransmission(addr.address);
|
||||
i2cBus->write(cmd1, sizeof(cmd1));
|
||||
i2cBus->endTransmission();
|
||||
|
||||
62
src/main.cpp
62
src/main.cpp
@@ -410,6 +410,68 @@ void setup()
|
||||
digitalWrite(BLE_LED, LED_STATE_OFF);
|
||||
#endif
|
||||
|
||||
#if defined(T_DECK)
|
||||
// GPIO10 manages all peripheral power supplies
|
||||
// Turn on peripheral power immediately after MUC starts.
|
||||
// If some boards are turned on late, ESP32 will reset due to low voltage.
|
||||
// ESP32-C3(Keyboard) , MAX98357A(Audio Power Amplifier) ,
|
||||
// TF Card , Display backlight(AW9364DNR) , AN48841B(Trackball) , ES7210(Decoder)
|
||||
pinMode(KB_POWERON, OUTPUT);
|
||||
digitalWrite(KB_POWERON, HIGH);
|
||||
// T-Deck has all three SPI peripherals (TFT, SD, LoRa) attached to the same SPI bus
|
||||
// We need to initialize all CS pins in advance otherwise there will be SPI communication issues
|
||||
// e.g. when detecting the SD card
|
||||
pinMode(LORA_CS, OUTPUT);
|
||||
digitalWrite(LORA_CS, HIGH);
|
||||
pinMode(SDCARD_CS, OUTPUT);
|
||||
digitalWrite(SDCARD_CS, HIGH);
|
||||
pinMode(TFT_CS, OUTPUT);
|
||||
digitalWrite(TFT_CS, HIGH);
|
||||
delay(100);
|
||||
#elif defined(T_DECK_PRO)
|
||||
pinMode(LORA_EN, OUTPUT);
|
||||
digitalWrite(LORA_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);
|
||||
#if PIN_EINK_RES >= 0
|
||||
pinMode(PIN_EINK_RES, OUTPUT);
|
||||
digitalWrite(PIN_EINK_RES, HIGH);
|
||||
#endif
|
||||
pinMode(CST328_PIN_RST, OUTPUT);
|
||||
digitalWrite(CST328_PIN_RST, HIGH);
|
||||
#elif defined(T_LORA_PAGER)
|
||||
pinMode(LORA_CS, OUTPUT);
|
||||
digitalWrite(LORA_CS, HIGH);
|
||||
pinMode(SDCARD_CS, OUTPUT);
|
||||
digitalWrite(SDCARD_CS, HIGH);
|
||||
pinMode(TFT_CS, OUTPUT);
|
||||
digitalWrite(TFT_CS, HIGH);
|
||||
pinMode(KB_INT, INPUT_PULLUP);
|
||||
// io expander
|
||||
io.begin(Wire, XL9555_SLAVE_ADDRESS0, SDA, SCL);
|
||||
io.pinMode(EXPANDS_DRV_EN, OUTPUT);
|
||||
io.digitalWrite(EXPANDS_DRV_EN, HIGH);
|
||||
io.pinMode(EXPANDS_AMP_EN, OUTPUT);
|
||||
io.digitalWrite(EXPANDS_AMP_EN, LOW);
|
||||
io.pinMode(EXPANDS_LORA_EN, OUTPUT);
|
||||
io.digitalWrite(EXPANDS_LORA_EN, HIGH);
|
||||
io.pinMode(EXPANDS_GPS_EN, OUTPUT);
|
||||
io.digitalWrite(EXPANDS_GPS_EN, HIGH);
|
||||
io.pinMode(EXPANDS_KB_EN, OUTPUT);
|
||||
io.digitalWrite(EXPANDS_KB_EN, HIGH);
|
||||
io.pinMode(EXPANDS_SD_EN, OUTPUT);
|
||||
io.digitalWrite(EXPANDS_SD_EN, HIGH);
|
||||
io.pinMode(EXPANDS_GPIO_EN, OUTPUT);
|
||||
io.digitalWrite(EXPANDS_GPIO_EN, HIGH);
|
||||
io.pinMode(EXPANDS_SD_PULLEN, INPUT);
|
||||
#elif defined(HACKADAY_COMMUNICATOR)
|
||||
pinMode(KB_INT, INPUT);
|
||||
#endif
|
||||
|
||||
concurrency::hasBeenSetup = true;
|
||||
#if HAS_SCREEN
|
||||
meshtastic_Config_DisplayConfig_OledType screen_model =
|
||||
|
||||
@@ -10,13 +10,14 @@ CSE_CST328 tsPanel = CSE_CST328(EINK_WIDTH, EINK_HEIGHT, &Wire, CST328_PIN_RST,
|
||||
|
||||
static bool is_cst3530 = false;
|
||||
volatile bool touch_isr = false;
|
||||
#define CST3530_ADDR 0x1A
|
||||
#define CST3530_ADDR 0x1A
|
||||
|
||||
bool read_cst3530_touch(int16_t *x, int16_t *y) {
|
||||
bool read_cst3530_touch(int16_t *x, int16_t *y)
|
||||
{
|
||||
uint8_t buffer[9] = {0};
|
||||
uint8_t r_cmd[] = {0xD0, 0x07, 0x00, 0x00};
|
||||
uint8_t clear_cmd[] = {0xD0, 0x00, 0x02, 0xAB};
|
||||
|
||||
uint8_t clear_cmd[] = {0xD0, 0x00, 0x02, 0xAB};
|
||||
|
||||
Wire.beginTransmission(CST3530_ADDR);
|
||||
Wire.write(r_cmd, sizeof(r_cmd));
|
||||
if (Wire.endTransmission() != 0) {
|
||||
@@ -41,13 +42,13 @@ bool read_cst3530_touch(int16_t *x, int16_t *y) {
|
||||
}
|
||||
|
||||
uint8_t touch_points = buffer[3] & 0x0F;
|
||||
if (touch_points == 0 || touch_points > 1) {
|
||||
if (touch_points == 0 || touch_points > 1) {
|
||||
LOG_DEBUG("CST3530 touch points invalid: %d", touch_points);
|
||||
return false;
|
||||
}
|
||||
|
||||
*x = buffer[4] + ((uint16_t)(buffer[7] & 0x0F) << 8);
|
||||
*y = buffer[5] + ((uint16_t)(buffer[7] & 0xF0) << 4);
|
||||
*x = buffer[4] + ((uint16_t)(buffer[7] & 0x0F) << 8);
|
||||
*y = buffer[5] + ((uint16_t)(buffer[7] & 0xF0) << 4);
|
||||
|
||||
// LOG_DEBUG("CST3530 touch: num:%d x=%d,y=%d", touch_points, *x, *y);
|
||||
|
||||
@@ -63,13 +64,13 @@ bool read_cst3530_touch(int16_t *x, int16_t *y) {
|
||||
bool readTouch(int16_t *x, int16_t *y)
|
||||
{
|
||||
|
||||
if(is_cst3530){
|
||||
if(touch_isr){
|
||||
if (is_cst3530) {
|
||||
if (touch_isr) {
|
||||
touch_isr = false;
|
||||
return read_cst3530_touch(x, y);
|
||||
}
|
||||
return false;
|
||||
}else{
|
||||
} else {
|
||||
if (tsPanel.getTouches()) {
|
||||
*x = tsPanel.getPoint(0).x;
|
||||
*y = tsPanel.getPoint(0).y;
|
||||
@@ -79,8 +80,8 @@ bool readTouch(int16_t *x, int16_t *y)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static void IRAM_ATTR touchInterruptHandler(){
|
||||
static void IRAM_ATTR touchInterruptHandler()
|
||||
{
|
||||
touch_isr = true;
|
||||
}
|
||||
|
||||
@@ -98,30 +99,30 @@ void lateInitVariant()
|
||||
|
||||
int retry = 5;
|
||||
uint8_t buffer[7];
|
||||
uint8_t r_cmd[] = {0x0d0,0x03,0x00,0x00};
|
||||
uint8_t r_cmd[] = {0x0d0, 0x03, 0x00, 0x00};
|
||||
|
||||
// Probe touch chip
|
||||
while(retry--) {
|
||||
while (retry--) {
|
||||
Wire.beginTransmission(CST3530_ADDR);
|
||||
Wire.write(r_cmd, sizeof(r_cmd));
|
||||
if(Wire.endTransmission() == 0){
|
||||
Wire.requestFrom((int)CST3530_ADDR,7);
|
||||
Wire.readBytes(buffer,7);
|
||||
if(buffer[2] == 0xCA && buffer[3] == 0xCA){
|
||||
if (Wire.endTransmission() == 0) {
|
||||
Wire.requestFrom((int)CST3530_ADDR, 7);
|
||||
Wire.readBytes(buffer, 7);
|
||||
if (buffer[2] == 0xCA && buffer[3] == 0xCA) {
|
||||
LOG_DEBUG("CST3530 detected");
|
||||
is_cst3530 = true;
|
||||
|
||||
// The CST3530 will automatically enter sleep mode;
|
||||
// polling should not be used, but rather an interrupt method should be employed.
|
||||
// The CST3530 will automatically enter sleep mode;
|
||||
// polling should not be used, but rather an interrupt method should be employed.
|
||||
pinMode(CST328_PIN_INT, INPUT);
|
||||
attachInterrupt(digitalPinToInterrupt(CST328_PIN_INT), touchInterruptHandler, FALLING);
|
||||
|
||||
break;
|
||||
}else{
|
||||
} else {
|
||||
LOG_DEBUG("CST3530 not response ~!");
|
||||
}
|
||||
}
|
||||
uint8_t cmd1[] = {0xD0,0x00,0x04,0x00};
|
||||
uint8_t cmd1[] = {0xD0, 0x00, 0x04, 0x00};
|
||||
Wire.beginTransmission(CST3530_ADDR);
|
||||
Wire.write(cmd1, sizeof(cmd1));
|
||||
Wire.endTransmission();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#define PIN_EINK_RES 16
|
||||
#define PIN_EINK_SCLK 36
|
||||
#define PIN_EINK_MOSI 47
|
||||
#define TFT_BL 45 // option , default not backlight
|
||||
#define TFT_BL 45 // option , default not backlight
|
||||
|
||||
#define I2C_SDA SDA
|
||||
#define I2C_SCL SCL
|
||||
|
||||
Reference in New Issue
Block a user