From 4355b195261577fa77408257ba02c93695a28822 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Mon, 3 Jun 2024 14:59:47 -0400 Subject: [PATCH] first test Heltec Wireless Paper --- platformio.ini | 13 ++++ src/battery_utils.cpp | 4 +- src/boards_pinout.h | 13 +++- src/display.cpp | 154 ++++++++++++++++++++++++------------------ src/lora_utils.cpp | 2 +- src/power_utils.cpp | 2 +- 6 files changed, 117 insertions(+), 71 deletions(-) diff --git a/platformio.ini b/platformio.ini index c920c598..2e4b49cd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -107,6 +107,19 @@ lib_deps = ${common.lib_deps} +[env:heltec_wireless_paper] +board = esp32-s3-devkitc-1 +board_build.mcu = esp32s3 +build_flags = + -Werror -Wall + -DHELTEC_WP + -DHAS_SX1262 + -DHAS_EPAPER + -DELEGANTOTA_USE_ASYNC_WEBSERVER=1 +lib_deps = + ${common.lib_deps} + + [env:heltec_ht-ct62] board = heltec_wireless_stick_lite board_build.mcu = esp32c3 diff --git a/src/battery_utils.cpp b/src/battery_utils.cpp index b33f12e5..0b1d9681 100644 --- a/src/battery_utils.cpp +++ b/src/battery_utils.cpp @@ -36,7 +36,7 @@ namespace BATTERY_Utils { int sample; int sampleSum = 0; #ifdef ADC_CTRL - #if defined(HELTEC_WSL_V3) || defined(HELTEC_WIRELESS_TRACKER) + #if defined(HELTEC_WSL_V3) || defined(HELTEC_WIRELESS_TRACKER) || defined(HELTEC_WP) digitalWrite(ADC_CTRL, HIGH); #endif #if defined(HELTEC_V3) || defined(HELTEC_V2) @@ -56,7 +56,7 @@ namespace BATTERY_Utils { } #ifdef ADC_CTRL - #if defined(HELTEC_WSL_V3) || defined(HELTEC_WIRELESS_TRACKER) + #if defined(HELTEC_WSL_V3) || defined(HELTEC_WIRELESS_TRACKER) || defined(HELTEC_WP) digitalWrite(ADC_CTRL, LOW); #endif #if defined(HELTEC_V3) || defined(HELTEC_V2) diff --git a/src/boards_pinout.h b/src/boards_pinout.h index a7a55508..cbc6a490 100644 --- a/src/boards_pinout.h +++ b/src/boards_pinout.h @@ -18,12 +18,12 @@ #define RADIO_BUSY_PIN 26 // GPIO26 - SX1278 IRQ ---->DIO0 #endif -#if defined(HELTEC_V3) || defined(HELTEC_WSL_V3) || defined(HELTEC_WIRELESS_TRACKER) || defined(HELTEC_WS) +#if defined(HELTEC_V3) || defined(HELTEC_WSL_V3) || defined(HELTEC_WIRELESS_TRACKER) || defined(HELTEC_WS) || defined(HELTEC_WP) #define RADIO_SCLK_PIN 9 // SX1262 SCK #define RADIO_MISO_PIN 11 // SX1262 MISO #define RADIO_MOSI_PIN 10 // SX1262 MOSI #define RADIO_CS_PIN 8 // SX1262 NSS - #define RADIO_RST_PIN 12 // SX1262 RST + #define RADIO_RST_PIN 12 // SX1262 RST #define RADIO_DIO1_PIN 14 // SX1262 DIO1 #define RADIO_BUSY_PIN 13 // SX1262 BUSY #endif @@ -176,6 +176,15 @@ #define BOARD_I2C_SCL 6 #endif +#ifdef HELTEC_WP + #define INTERNAL_LED_PIN 18 + #define BATTERY_PIN 20 + #define ADC_CTRL 19 + #define VEXT_CTRL 45 + #define BOARD_I2C_SDA 37 + #define BOARD_I2C_SCL 36 +#endif + #ifdef ESP32_C3_DIY_LoRa #define OLED_SDA 8 #define OLED_SCL 9 diff --git a/src/display.cpp b/src/display.cpp index ee904bd2..abbf0dbc 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -16,12 +16,16 @@ #define lineSpacing 9 #endif #else - #include - #include - #if defined(HELTEC_V3) - #define OLED_DISPLAY_HAS_RST_PIN - #endif - Adafruit_SSD1306 display(128, 64, &Wire, OLED_RST); + #ifdef HAS_EPAPER + // + #else + #include + #include + #if defined(HELTEC_V3) + #define OLED_DISPLAY_HAS_RST_PIN + #endif + Adafruit_SSD1306 display(128, 64, &Wire, OLED_RST); + #endif #endif #endif @@ -48,29 +52,33 @@ void setup_display() { } tft.setTextFont(0); tft.fillScreen(TFT_BLACK); - #else - #ifdef OLED_DISPLAY_HAS_RST_PIN - pinMode(OLED_RST, OUTPUT); - digitalWrite(OLED_RST, LOW); - delay(20); - digitalWrite(OLED_RST, HIGH); - #endif - Wire.begin(OLED_SDA, OLED_SCL); + #else + #ifdef HAS_EPAPER + // + #else + #ifdef OLED_DISPLAY_HAS_RST_PIN + pinMode(OLED_RST, OUTPUT); + digitalWrite(OLED_RST, LOW); + delay(20); + digitalWrite(OLED_RST, HIGH); + #endif + Wire.begin(OLED_SDA, OLED_SCL); - if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { - Serial.println(F("SSD1306 allocation failed")); - for(;;); // Don't proceed, loop forever - } - if (Config.display.turn180) { - display.setRotation(2); - } - display.clearDisplay(); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(0, 0); - display.ssd1306_command(SSD1306_SETCONTRAST); - display.ssd1306_command(1); - display.display(); + if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { + Serial.println(F("SSD1306 allocation failed")); + for(;;); // Don't proceed, loop forever + } + if (Config.display.turn180) { + display.setRotation(2); + } + display.clearDisplay(); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(0, 0); + display.ssd1306_command(SSD1306_SETCONTRAST); + display.ssd1306_command(1); + display.display(); + #endif #endif delay(1000); #endif @@ -82,13 +90,21 @@ void display_toggle(bool toggle) { #ifdef HAS_TFT digitalWrite(TFT_BL, HIGH); #else - display.ssd1306_command(SSD1306_DISPLAYON); + #ifdef HAS_EPAPER + // + #else + display.ssd1306_command(SSD1306_DISPLAYON); + #endif #endif } else { #ifdef HAS_TFT digitalWrite(TFT_BL, LOW); #else - display.ssd1306_command(SSD1306_DISPLAYOFF); + #ifdef HAS_EPAPER + // + #else + display.ssd1306_command(SSD1306_DISPLAYOFF); + #endif #endif } #endif @@ -139,20 +155,24 @@ void show_display(const String& header, const String& line1, const String& line2 tft.setCursor(0, ((lineSpacing * 4) - 2)); tft.print(line3); #else - display.clearDisplay(); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(0, 0); - display.println(header); - display.setCursor(0, 8); - display.println(line1); - display.setCursor(0, 16); - display.println(line2); - display.setCursor(0, 24); - display.println(line3); - display.ssd1306_command(SSD1306_SETCONTRAST); - display.ssd1306_command(1); - display.display(); + #ifdef HAS_EPAPER + // + #else + display.clearDisplay(); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(0, 0); + display.println(header); + display.setCursor(0, 8); + display.println(line1); + display.setCursor(0, 16); + display.println(line2); + display.setCursor(0, 24); + display.println(line3); + display.ssd1306_command(SSD1306_SETCONTRAST); + display.ssd1306_command(1); + display.display(); + #endif #endif delay(wait); #endif @@ -182,27 +202,31 @@ void show_display(const String& header, const String& line1, const String& line2 tft.setCursor(0, ((lineSpacing * 7) - 2)); tft.print(line6); #else - display.clearDisplay(); - display.setTextColor(WHITE); - display.setTextSize(2); - display.setCursor(0, 0); - display.println(header); - display.setTextSize(1); - display.setCursor(0, 16); - display.println(line1); - display.setCursor(0, 24); - display.println(line2); - display.setCursor(0, 32); - display.println(line3); - display.setCursor(0, 40); - display.println(line4); - display.setCursor(0, 48); - display.println(line5); - display.setCursor(0, 56); - display.println(line6); - display.ssd1306_command(SSD1306_SETCONTRAST); - display.ssd1306_command(1); - display.display(); + #ifdef HAS_EPAPER + // + #else + display.clearDisplay(); + display.setTextColor(WHITE); + display.setTextSize(2); + display.setCursor(0, 0); + display.println(header); + display.setTextSize(1); + display.setCursor(0, 16); + display.println(line1); + display.setCursor(0, 24); + display.println(line2); + display.setCursor(0, 32); + display.println(line3); + display.setCursor(0, 40); + display.println(line4); + display.setCursor(0, 48); + display.println(line5); + display.setCursor(0, 56); + display.println(line6); + display.ssd1306_command(SSD1306_SETCONTRAST); + display.ssd1306_command(1); + display.display(); + #endif #endif delay(wait); #endif diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp index 2cbc6506..e7a4943a 100644 --- a/src/lora_utils.cpp +++ b/src/lora_utils.cpp @@ -75,7 +75,7 @@ namespace LoRa_Utils { state = radio.setOutputPower(Config.loramodule.power); // max value 20dB for 400M30S as it has Low Noise Amp radio.setCurrentLimit(100); // to be validated (80 , 100)? #endif - #if defined(HELTEC_V3) || defined(HELTEC_WSL_V3) || defined(HELTEC_WS) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262) + #if defined(HAS_SX1262) || defined(TTGO_T_Beam_V1_0_SX1268) state = radio.setOutputPower(Config.loramodule.power + 2); // values available: 10, 17, 22 --> if 20 in tracker_conf.json it will be updated to 22. radio.setCurrentLimit(140); #endif diff --git a/src/power_utils.cpp b/src/power_utils.cpp index 1056f981..bdf0d1e5 100644 --- a/src/power_utils.cpp +++ b/src/power_utils.cpp @@ -160,7 +160,7 @@ namespace POWER_Utils { pinMode(ADC_CTRL, OUTPUT); #endif - #ifdef HELTEC_WIRELESS_TRACKER + #if defined(HELTEC_WIRELESS_TRACKER) || defined(HELTEC_WP) Wire.begin(BOARD_I2C_SDA, BOARD_I2C_SCL); #endif