From 54240c0d8743ed4e27b315fe385c32819081c89a Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 16 Oct 2023 10:54:43 -0500 Subject: [PATCH 1/2] WIP LoRAType --- src/graphics/EInkDisplay2.cpp | 18 +++++++++++---- src/main.cpp | 10 +++++++++ src/platform/esp32/architecture.h | 2 ++ variants/lora_type/platformio.ini | 15 +++++++++++++ variants/lora_type/variant.h | 37 +++++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 variants/lora_type/platformio.ini create mode 100644 variants/lora_type/variant.h diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp index 61d0eea5af..91365ce601 100644 --- a/src/graphics/EInkDisplay2.cpp +++ b/src/graphics/EInkDisplay2.cpp @@ -7,9 +7,9 @@ #include "main.h" #include -// #ifdef HELTEC_WIRELESS_PAPER -// SPIClass *hspi = NULL; -// #endif +#if defined(HELTEC_WIRELESS_PAPER)// || defined(LORA_TYPE) +SPIClass *hspi = NULL; +#endif #define COLORED GxEPD_BLACK #define UNCOLORED GxEPD_WHITE @@ -40,6 +40,10 @@ // 4.2 inch 300x400 - GxEPD2_420_M01 #define TECHO_DISPLAY_MODEL GxEPD2_420_M01 +#elif defined(LORA_TYPE) +// 1.54 inch 200x200 - GxEPD2_154_M09 +#define TECHO_DISPLAY_MODEL GxEPD2_154_GDEY0154D67 + #elif defined(M5_COREINK) // M5Stack CoreInk // 1.54 inch 200x200 - GxEPD2_154_M09 @@ -146,7 +150,7 @@ bool EInkDisplay::forceDisplay(uint32_t msecLimit) // 4.2 inch 300x400 - GxEPD2_420_M01 adafruitDisplay->nextPage(); -#elif defined(PCA10059) || defined(M5_COREINK) +#elif defined(PCA10059) || defined(M5_COREINK) || defined(LORA_TYPE) adafruitDisplay->nextPage(); #elif defined(PRIVATE_HW) || defined(my) @@ -247,6 +251,12 @@ bool EInkDisplay::connect() adafruitDisplay->setRotation(3); adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight); } +#elif defined(LORA_TYPE) + auto lowLevel = new TECHO_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY); + adafruitDisplay = new GxEPD2_BW(*lowLevel); + adafruitDisplay->init(115200, true, 40, false, SPI, SPISettings(4000000, MSBFIRST, SPI_MODE0)); + adafruitDisplay->setRotation(3); + adafruitDisplay->setPartialWindow(0, 0, EPD_WIDTH, EPD_HEIGHT); #elif defined(M5_COREINK) auto lowLevel = new TECHO_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY); adafruitDisplay = new GxEPD2_BW(*lowLevel); diff --git a/src/main.cpp b/src/main.cpp index 9b7d811c46..573a9aa5bc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -615,9 +615,14 @@ void setup() SPI.begin(); #else // ESP32 +#ifdef LORA_TYPE + SPI.begin(PIN_EINK_SCLK, 15, PIN_EINK_MOSI, PIN_EINK_CS); +#else SPI.begin(RF95_SCK, RF95_MISO, RF95_MOSI, RF95_NSS); +#endif LOG_WARN("SPI.begin(SCK=%d, MISO=%d, MOSI=%d, NSS=%d)\n", RF95_SCK, RF95_MISO, RF95_MOSI, RF95_NSS); SPI.setFrequency(4000000); + #endif // Initialize the screen first so we can show the logo while we start up everything else. @@ -661,8 +666,13 @@ void setup() digitalWrite(SX126X_ANT_SW, 1); #endif + #ifdef HW_SPI1_DEVICE LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI1, spiSettings); +#elif LORA_TYPE + SPIClass radioSPI(VSPI); + radioSPI.begin(RF95_SCK, RF95_MISO, RF95_MOSI, RF95_NSS); + LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(radioSPI, spiSettings); #else // HW_SPI1_DEVICE LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); #endif diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h index 163cc8b844..8954235642 100644 --- a/src/platform/esp32/architecture.h +++ b/src/platform/esp32/architecture.h @@ -121,6 +121,8 @@ #define HW_VENDOR meshtastic_HardwareModel_PICOMPUTER_S3 #elif defined(HELTEC_HT62) #define HW_VENDOR meshtastic_HardwareModel_HELTEC_HT62 +#elif defined(LORA_TYPE) +#define HW_VENDOR meshtastic_HardwareModel_LORA_TYPE #endif // ----------------------------------------------------------------------------- diff --git a/variants/lora_type/platformio.ini b/variants/lora_type/platformio.ini new file mode 100644 index 0000000000..51e9836d5a --- /dev/null +++ b/variants/lora_type/platformio.ini @@ -0,0 +1,15 @@ +[env:lora_type] +extends = esp32_base +board = esp32doit-devkit-v1 +board_level = extra +build_flags = + ${esp32_base.build_flags} + -DLORA_TYPE + -DEBYTE_E22 + -Ivariants/lora_type + -DEPD_HEIGHT=200 + -DEPD_WIDTH=200 + -DM5_COREINK +lib_deps = + ${esp32_base.lib_deps} + zinggjm/GxEPD2@^1.4.9 \ No newline at end of file diff --git a/variants/lora_type/variant.h b/variants/lora_type/variant.h new file mode 100644 index 0000000000..c47f7e1b1d --- /dev/null +++ b/variants/lora_type/variant.h @@ -0,0 +1,37 @@ +#define BUTTON_PIN 39 // The middle button GPIO on the T-Beam +#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define ADC_CHANNEL ADC1_GPIO35_CHANNEL +#define ADC_MULTIPLIER 2.0 // (R1 = 27k, R2 = 100k) +#define LED_PIN 33 // add status LED (compatible with core-pcb and DIY targets) + +#define LORA_DIO0 RADIOLIB_NC // a No connect on the SX1262/SX1268 module +#define LORA_RESET 16 // RST for SX1276, and for SX1262/SX1268 +#define LORA_DIO1 4 // IRQ for SX1262/SX1268 +#define LORA_DIO2 26 // BUSY for SX1262/SX1268 +#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262/SX1268, if DIO3 is high the TXCO is enabled + +#define RF95_SCK 18 +#define RF95_MISO 19 +#define RF95_MOSI 23 +#define RF95_NSS 5 + +#define USE_SX1262 + +#define SX126X_CS 5 // NSS for SX126X +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY LORA_DIO2 +#define SX126X_RESET LORA_RESET +#define SX126X_RXEN 25 +#define SX126X_TXEN RADIOLIB_NC +#define SX126X_DIO2_AS_RF_SWITCH + +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 + +#define USE_EINK +#define PIN_EINK_EN -1 // N/C +#define PIN_EINK_CS 15 // EPD_CS +#define PIN_EINK_BUSY 27 // EPD_BUSY +#define PIN_EINK_DC 12 // EPD_D/C +#define PIN_EINK_RES 32 // Connected but not needed +#define PIN_EINK_SCLK 14 // EPD_SCLK +#define PIN_EINK_MOSI 13 // GxEPD2_EPDEPD_MOSI From e46a55c1272ff5aa78b56862109b8ba6b901c34c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 8 Oct 2024 14:10:26 +0200 Subject: [PATCH 2/2] Update platformio.ini --- variants/lora_type/platformio.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/variants/lora_type/platformio.ini b/variants/lora_type/platformio.ini index 51e9836d5a..49ada3bef9 100644 --- a/variants/lora_type/platformio.ini +++ b/variants/lora_type/platformio.ini @@ -9,7 +9,8 @@ build_flags = -Ivariants/lora_type -DEPD_HEIGHT=200 -DEPD_WIDTH=200 + -DEINK_DISPLAY_MODEL=GxEPD2_154_GDEY0154D67 -DM5_COREINK lib_deps = ${esp32_base.lib_deps} - zinggjm/GxEPD2@^1.4.9 \ No newline at end of file + zinggjm/GxEPD2@^1.4.9