From 932550c19302cf714ecfc498554b8ef3df7f234d Mon Sep 17 00:00:00 2001 From: mverch67 Date: Tue, 27 Aug 2024 16:56:57 +0200 Subject: [PATCH 1/4] t3s3 e-paper support --- src/graphics/EInkDisplay2.cpp | 2 +- src/graphics/EInkDisplay2.h | 2 +- src/platform/esp32/architecture.h | 2 + variants/tlora_t3s3_epaper/pins_arduino.h | 26 +++++++++ variants/tlora_t3s3_epaper/platformio.ini | 23 ++++++++ variants/tlora_t3s3_epaper/variant.h | 69 +++++++++++++++++++++++ 6 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 variants/tlora_t3s3_epaper/pins_arduino.h create mode 100644 variants/tlora_t3s3_epaper/platformio.ini create mode 100644 variants/tlora_t3s3_epaper/variant.h diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp index 4b845bd511..c4cb10f827 100644 --- a/src/graphics/EInkDisplay2.cpp +++ b/src/graphics/EInkDisplay2.cpp @@ -157,7 +157,7 @@ bool EInkDisplay::connect() } #elif defined(HELTEC_WIRELESS_PAPER_V1_0) || defined(HELTEC_WIRELESS_PAPER) || defined(HELTEC_VISION_MASTER_E213) || \ - defined(HELTEC_VISION_MASTER_E290) + defined(HELTEC_VISION_MASTER_E290) || defined(TLORA_T3S3_EPAPER) { // Start HSPI hspi = new SPIClass(HSPI); diff --git a/src/graphics/EInkDisplay2.h b/src/graphics/EInkDisplay2.h index 26091b2cd2..af631150e2 100644 --- a/src/graphics/EInkDisplay2.h +++ b/src/graphics/EInkDisplay2.h @@ -68,7 +68,7 @@ class EInkDisplay : public OLEDDisplay // If display uses HSPI #if defined(HELTEC_WIRELESS_PAPER) || defined(HELTEC_WIRELESS_PAPER_V1_0) || defined(HELTEC_VISION_MASTER_E213) || \ - defined(HELTEC_VISION_MASTER_E290) + defined(HELTEC_VISION_MASTER_E290) || defined(TLORA_T3S3_EPAPER) SPIClass *hspi = NULL; #endif diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h index 3761235a0e..f86b342ce8 100644 --- a/src/platform/esp32/architecture.h +++ b/src/platform/esp32/architecture.h @@ -122,6 +122,8 @@ #define HW_VENDOR meshtastic_HardwareModel_HELTEC_WIRELESS_PAPER #elif defined(TLORA_T3S3_V1) #define HW_VENDOR meshtastic_HardwareModel_TLORA_T3_S3 +#elif defined(TLORA_T3S3_EPAPER) +#define HW_VENDOR meshtastic_HardwareModel_TLORA_T3_S3 #elif defined(CDEBYTE_EORA_S3) #define HW_VENDOR meshtastic_HardwareModel_CDEBYTE_EORA_S3 #elif defined(BETAFPV_2400_TX) diff --git a/variants/tlora_t3s3_epaper/pins_arduino.h b/variants/tlora_t3s3_epaper/pins_arduino.h new file mode 100644 index 0000000000..ca44959c86 --- /dev/null +++ b/variants/tlora_t3s3_epaper/pins_arduino.h @@ -0,0 +1,26 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +// The default Wire will be mapped to PMU and RTC +static const uint8_t SDA = 18; +static const uint8_t SCL = 12; // t3s3 e-Paper has no pin 17 as t3s3 v1, so use another free pin next to it + +// Default SPI will be mapped to Radio +static const uint8_t SS = 7; +static const uint8_t MOSI = 6; +static const uint8_t MISO = 3; +static const uint8_t SCK = 5; + +#define SPI_MOSI (11) +#define SPI_SCK (14) +#define SPI_MISO (2) +#define SPI_CS (13) + +#define SDCARD_CS SPI_CS + +#endif /* Pins_Arduino_h */ diff --git a/variants/tlora_t3s3_epaper/platformio.ini b/variants/tlora_t3s3_epaper/platformio.ini new file mode 100644 index 0000000000..8228f09f1b --- /dev/null +++ b/variants/tlora_t3s3_epaper/platformio.ini @@ -0,0 +1,23 @@ +[env:tlora-t3s3-epaper] +extends = esp32s3_base +board = tlora-t3s3-v1 +board_check = true +upload_protocol = esptool + +build_flags = + ${esp32_base.build_flags} -D TLORA_T3S3_EPAPER -I variants/tlora_t3s3_epaper + -DGPS_POWER_TOGGLE + -DEINK_DISPLAY_MODEL=GxEPD2_213_BN + -DEINK_WIDTH=250 + -DEINK_HEIGHT=122 + -DUSE_EINK_DYNAMICDISPLAY ; Enable Dynamic EInk + -DEINK_LIMIT_FASTREFRESH=10 ; How many consecutive fast-refreshes are permitted + -DEINK_LIMIT_RATE_BACKGROUND_SEC=30 ; Minimum interval between BACKGROUND updates + -DEINK_LIMIT_RATE_RESPONSIVE_SEC=1 ; Minimum interval between RESPONSIVE updates +; -D EINK_LIMIT_GHOSTING_PX=2000 ; (Optional) How much image ghosting is tolerated + -DEINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached. + -DEINK_HASQUIRK_GHOSTING ; Display model is identified as "prone to ghosting" + -DEINK_HASQUIRK_WEAKFASTREFRESH ; Pixels set with fast-refresh are easy to clear, disrupted by sunlight +lib_deps = + ${esp32s3_base.lib_deps} + https://github.com/meshtastic/GxEPD2#b202ebfec6a4821e098cf7a625ba0f6f2400292d diff --git a/variants/tlora_t3s3_epaper/variant.h b/variants/tlora_t3s3_epaper/variant.h new file mode 100644 index 0000000000..461ce0c312 --- /dev/null +++ b/variants/tlora_t3s3_epaper/variant.h @@ -0,0 +1,69 @@ +#define HAS_SDCARD +#define SDCARD_USE_SPI1 + +// Display (E-Ink) +#define USE_EINK +#define PIN_EINK_CS 15 +#define PIN_EINK_BUSY 48 +#define PIN_EINK_DC 16 +#define PIN_EINK_RES 47 +#define PIN_EINK_SCLK 14 +#define PIN_EINK_MOSI 11 + +#define BATTERY_PIN 1 // A battery voltage measurement pin, voltage divider connected here to +// measure battery voltage ratio of voltage divider = 2.0 (assumption) +#define ADC_MULTIPLIER 2.11 // 2.0 + 10% for correction of display undervoltage. +#define ADC_CHANNEL ADC1_GPIO1_CHANNEL + +#define I2C_SDA SDA +#define I2C_SCL SCL + +// external qwiic connector +#define GPS_RX_PIN 44 +#define GPS_TX_PIN 43 + +#define LED_PIN 37 +#define BUTTON_PIN 0 +#define BUTTON_NEED_PULLUP + +// TTGO uses a common pinout for their SX1262 vs RF95 modules - both can be enabled and +// we will probe at runtime for RF95 and if not found then probe for SX1262 +#define USE_RF95 // RFM95/SX127x +#define USE_SX1262 +#define USE_SX1280 + +#define LORA_SCK 5 +#define LORA_MISO 3 +#define LORA_MOSI 6 +#define LORA_CS 7 +#define LORA_RESET 8 + +// per SX1276_Receive_Interrupt/utilities.h +#define LORA_DIO0 9 +#define LORA_DIO1 33 // TCXO_EN ? +#define LORA_DIO2 34 +#define LORA_RXEN 21 +#define LORA_TXEN 10 + +// per SX1262_Receive_Interrupt/utilities.h +#ifdef USE_SX1262 +#define SX126X_CS LORA_CS +#define SX126X_DIO1 33 +#define SX126X_BUSY 34 +#define SX126X_RESET LORA_RESET +#define SX126X_DIO2_AS_RF_SWITCH +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 +#endif + +// per SX128x_Receive_Interrupt/utilities.h +#ifdef USE_SX1280 +#define SX128X_CS LORA_CS +#define SX128X_DIO1 9 +#define SX128X_DIO2 33 +#define SX128X_DIO3 34 +#define SX128X_BUSY 36 +#define SX128X_RESET LORA_RESET +#define SX128X_RXEN 21 +#define SX128X_TXEN 10 +#define SX128X_MAX_POWER 3 +#endif From 5a2e1032e91bbebad5c0362d238f5802235288a4 Mon Sep 17 00:00:00 2001 From: mverch67 Date: Tue, 27 Aug 2024 18:13:19 +0200 Subject: [PATCH 2/4] remove GPS autodetect (which leads to crashes during startup when no GPS present) --- variants/tlora_t3s3_epaper/variant.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/variants/tlora_t3s3_epaper/variant.h b/variants/tlora_t3s3_epaper/variant.h index 461ce0c312..fd03378068 100644 --- a/variants/tlora_t3s3_epaper/variant.h +++ b/variants/tlora_t3s3_epaper/variant.h @@ -19,8 +19,8 @@ #define I2C_SCL SCL // external qwiic connector -#define GPS_RX_PIN 44 -#define GPS_TX_PIN 43 +// #define GPS_RX_PIN 44 +// #define GPS_TX_PIN 43 #define LED_PIN 37 #define BUTTON_PIN 0 From a0c730474d0244cfa6bd419f01c0b10d29834e21 Mon Sep 17 00:00:00 2001 From: mverch67 Date: Thu, 29 Aug 2024 10:18:19 +0200 Subject: [PATCH 3/4] update EINK defines --- variants/tlora_t3s3_epaper/platformio.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/variants/tlora_t3s3_epaper/platformio.ini b/variants/tlora_t3s3_epaper/platformio.ini index 8228f09f1b..ceb4fbaf5e 100644 --- a/variants/tlora_t3s3_epaper/platformio.ini +++ b/variants/tlora_t3s3_epaper/platformio.ini @@ -14,10 +14,10 @@ build_flags = -DEINK_LIMIT_FASTREFRESH=10 ; How many consecutive fast-refreshes are permitted -DEINK_LIMIT_RATE_BACKGROUND_SEC=30 ; Minimum interval between BACKGROUND updates -DEINK_LIMIT_RATE_RESPONSIVE_SEC=1 ; Minimum interval between RESPONSIVE updates -; -D EINK_LIMIT_GHOSTING_PX=2000 ; (Optional) How much image ghosting is tolerated - -DEINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached. - -DEINK_HASQUIRK_GHOSTING ; Display model is identified as "prone to ghosting" - -DEINK_HASQUIRK_WEAKFASTREFRESH ; Pixels set with fast-refresh are easy to clear, disrupted by sunlight + -DEINK_HASQUIRK_VICIOUSFASTREFRESH ; Identify that pixels drawn by fast-refresh are harder to clear + ;-DEINK_LIMIT_GHOSTING_PX=2000 ; (Optional) How much image ghosting is tolerated + ;-DEINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached. + lib_deps = ${esp32s3_base.lib_deps} https://github.com/meshtastic/GxEPD2#b202ebfec6a4821e098cf7a625ba0f6f2400292d From 5c6e5e33f09a8c8f48a29776c485c2a2f1b34267 Mon Sep 17 00:00:00 2001 From: mverch67 Date: Thu, 29 Aug 2024 10:38:14 +0200 Subject: [PATCH 4/4] keep definitions for external GPS connector but disable GPS auto scan by default --- src/mesh/NodeDB.cpp | 2 +- variants/tlora_t3s3_epaper/variant.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 004f27a0d3..40f2575671 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -307,7 +307,7 @@ void NodeDB::installDefaultConfig() #else config.device.disable_triple_click = true; #endif -#if !HAS_GPS || defined(T_DECK) +#if !HAS_GPS || defined(T_DECK) || defined(TLORA_T3S3_EPAPER) config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT; #elif !defined(GPS_RX_PIN) if (config.position.rx_gpio == 0) diff --git a/variants/tlora_t3s3_epaper/variant.h b/variants/tlora_t3s3_epaper/variant.h index fd03378068..461ce0c312 100644 --- a/variants/tlora_t3s3_epaper/variant.h +++ b/variants/tlora_t3s3_epaper/variant.h @@ -19,8 +19,8 @@ #define I2C_SCL SCL // external qwiic connector -// #define GPS_RX_PIN 44 -// #define GPS_TX_PIN 43 +#define GPS_RX_PIN 44 +#define GPS_TX_PIN 43 #define LED_PIN 37 #define BUTTON_PIN 0