From 7897e9a5be5a6438481bb137fd2435a998e4537d Mon Sep 17 00:00:00 2001 From: SQ2CPA Date: Thu, 21 Mar 2024 13:01:42 +0100 Subject: [PATCH] feat: heltec wireless stick lite board --- platformio.ini | 9 ++++----- src/display.cpp | 20 ++++++++++++++++++++ src/lora_utils.cpp | 2 +- src/pins_config.h | 16 +++++++++++++++- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/platformio.ini b/platformio.ini index 6053a42c..77490b1d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -88,8 +88,7 @@ board = heltec_wifi_lora_32_V3 board_build.mcu = esp32s3 build_flags = -Werror -Wall -DHELTEC_WS -DELEGANTOTA_USE_ASYNC_WEBSERVER=1 -;[env:heltec_wireless_stick_lite] -;board = heltec_wireless_stick_lite -;board_build.mcu = esp32c3 -;board_build.f_cpu = 240000000L -;build_flags = -Werror -Wall -DHELTEC_WSL -DELEGANTOTA_USE_ASYNC_WEBSERVER=1 \ No newline at end of file +[env:heltec_wireless_stick_lite] +board = heltec_wireless_stick_lite +board_build.mcu = esp32c3 +build_flags = -Werror -Wall -DHELTEC_WSL -DELEGANTOTA_USE_ASYNC_WEBSERVER=1 \ No newline at end of file diff --git a/src/display.cpp b/src/display.cpp index 511baeca..c838bfc4 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -5,11 +5,14 @@ #include "pins_config.h" #include "display.h" +#ifdef HAS_DISPLAY Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RST); +#endif extern Configuration Config; void setup_display() { + #ifdef HAS_DISPLAY Wire.begin(OLED_SDA, OLED_SCL); if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { @@ -27,17 +30,21 @@ void setup_display() { display.ssd1306_command(1); display.display(); delay(1000); + #endif } void display_toggle(bool toggle) { + #ifdef HAS_DISPLAY if (toggle) { display.ssd1306_command(SSD1306_DISPLAYON); } else { display.ssd1306_command(SSD1306_DISPLAYOFF); } + #endif } void show_display(String line1, int wait) { + #ifdef HAS_DISPLAY display.clearDisplay(); display.setTextColor(WHITE); display.setTextSize(1); @@ -47,9 +54,11 @@ void show_display(String line1, int wait) { display.ssd1306_command(1); display.display(); delay(wait); + #endif } void show_display(String line1, String line2, int wait) { + #ifdef HAS_DISPLAY display.clearDisplay(); display.setTextColor(WHITE); display.setTextSize(1); @@ -61,9 +70,11 @@ void show_display(String line1, String line2, int wait) { display.ssd1306_command(1); display.display(); delay(wait); + #endif } void show_display(String line1, String line2, String line3, int wait) { + #ifdef HAS_DISPLAY display.clearDisplay(); display.setTextColor(WHITE); display.setTextSize(1); @@ -77,9 +88,11 @@ void show_display(String line1, String line2, String line3, int wait) { display.ssd1306_command(1); display.display(); delay(wait); + #endif } void show_display(String line1, String line2, String line3, String line4, int wait) { + #ifdef HAS_DISPLAY display.clearDisplay(); display.setTextColor(WHITE); display.setTextSize(1); @@ -95,9 +108,11 @@ void show_display(String line1, String line2, String line3, String line4, int wa display.ssd1306_command(1); display.display(); delay(wait); + #endif } void show_display(String line1, String line2, String line3, String line4, String line5, int wait) { + #ifdef HAS_DISPLAY display.clearDisplay(); display.setTextColor(WHITE); display.setTextSize(1); @@ -115,9 +130,11 @@ void show_display(String line1, String line2, String line3, String line4, String display.ssd1306_command(1); display.display(); delay(wait); + #endif } void show_display(String line1, String line2, String line3, String line4, String line5, String line6, int wait) { + #ifdef HAS_DISPLAY display.clearDisplay(); display.setTextColor(WHITE); display.setTextSize(1); @@ -137,9 +154,11 @@ void show_display(String line1, String line2, String line3, String line4, String display.ssd1306_command(1); display.display(); delay(wait); + #endif } void show_display(String line1, String line2, String line3, String line4, String line5, String line6, String line7, int wait) { + #ifdef HAS_DISPLAY display.clearDisplay(); display.setTextColor(WHITE); display.setTextSize(2); @@ -162,4 +181,5 @@ void show_display(String line1, String line2, String line3, String line4, String display.ssd1306_command(1); display.display(); delay(wait); + #endif } \ No newline at end of file diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp index 8030f8b9..ab4ab784 100644 --- a/src/lora_utils.cpp +++ b/src/lora_utils.cpp @@ -10,7 +10,7 @@ extern Configuration Config; -#if defined(HELTEC_V3) || defined(HELTEC_WS) || defined(TTGO_T_Beam_V1_2_SX1262) +#if defined(HELTEC_V3) || defined(HELTEC_WS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(HELTEC_WSL) SX1262 radio = new Module(RADIO_CS_PIN, RADIO_DIO1_PIN, RADIO_RST_PIN, RADIO_BUSY_PIN); bool transmissionFlag = true; bool enableInterrupt = true; diff --git a/src/pins_config.h b/src/pins_config.h index 525b9c38..f7a1f0cc 100644 --- a/src/pins_config.h +++ b/src/pins_config.h @@ -7,7 +7,7 @@ #undef OLED_SCL #undef OLED_RST -#if defined(HELTEC_V3) || defined(HELTEC_WS) || defined(ESP32_DIY_1W_LoRa) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(OE5HWN_MeshCom) +#if defined(HELTEC_V3) || defined(HELTEC_WS) || defined(ESP32_DIY_1W_LoRa) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(OE5HWN_MeshCom) || defined(HELTEC_WSL) #define HAS_SX126X #endif @@ -79,6 +79,16 @@ #define RADIO_TXEN 13 #endif +#ifdef HELTEC_WSL +#define RADIO_SCLK_PIN 10 // SX1262 SCK +#define RADIO_MISO_PIN 6 // SX1262 MISO +#define RADIO_MOSI_PIN 7 // SX1262 MOSI +#define RADIO_CS_PIN 8 // SX1262 NSS +#define RADIO_RST_PIN 5 // SX1262 RST +#define RADIO_DIO1_PIN 3 // SX1262 DIO1 +#define RADIO_BUSY_PIN 4 // SX1262 BUSY +#endif + // OLED #if defined(TTGO_T_LORA32_V2_1) || defined(ESP32_DIY_LoRa) || defined(ESP32_DIY_1W_LoRa) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(OE5HWN_MeshCom) @@ -99,6 +109,10 @@ #define OLED_RST 21 #endif +#ifndef HELTEC_WSL +#define HAS_DISPLAY +#endif + // Leds and other stuff #if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(HELTEC_V3) || defined(HELTEC_WS) || defined(ESP32_DIY_LoRa) || defined(ESP32_DIY_1W_LoRa)