From 89940b854c4a3977a7ed3bd0113528df6d0d7c35 Mon Sep 17 00:00:00 2001 From: Egor Date: Sun, 29 Sep 2024 01:35:25 -0700 Subject: [PATCH 1/2] SX1262 support --- include/LiLyGo.h | 26 ++++++++++++++++++++++---- include/global_config.h | 14 +++++++++++++- platformio.ini | 25 +++++++++++++++++++++++++ src/main.cpp | 12 +++++++++++- 4 files changed, 71 insertions(+), 6 deletions(-) diff --git a/include/LiLyGo.h b/include/LiLyGo.h index 0cc28df..c9c88ee 100644 --- a/include/LiLyGo.h +++ b/include/LiLyGo.h @@ -13,8 +13,11 @@ #else #define DISPLAY_WIDTH 128 #define DISPLAY_HEIGHT 64 -#include "OLEDDisplayUi.h" +// #include "OLEDDisplayUi.h" +// #include "SH1106Wire.h" +// #include "SSD1306Brzo.h" #include "SSD1306Wire.h" + #endif #define ARDUINO_heltec_wifi_32_lora_V3 #ifndef HELTEC_NO_RADIO_INSTANCE @@ -32,6 +35,10 @@ SX1280 radio = new Module(RADIO_CS_PIN, RADIO_DIO1_PIN, RADIO_RST_PIN, RADIO_BUS // Default SPI on pins from pins_arduino.h SX1262 radio = new Module(RADIO_CS_PIN, RADIO_DIO1_PIN, RADIO_RST_PIN, RADIO_BUSY_PIN); #endif // end USING_SX1262 +#ifdef USING_SX1276 +// Default SPI on pins from pins_arduino.h +SX1276 radio = new Module(RADIO_CS_PIN, RADIO_DIO1_PIN, RADIO_RST_PIN, RADIO_BUSY_PIN); +#endif // end USING_SX1276 #endif // end ARDUINO_heltec_wifi_32_lora_V3 #endif // end HELTEC_NO_RADIO_INSTANCE @@ -76,17 +83,28 @@ class PrintSplitter : public Print #else #define DISPLAY_GEOMETRY GEOMETRY_128_64 #endif -SSD1306Wire display(0x3c, 18, 17, DISPLAY_GEOMETRY); +#define SCREEN_ADDRESS 0x3C + +SSD1306Wire display(SCREEN_ADDRESS, I2C_SDA, I2C_SCL, DISPLAY_GEOMETRY); +// SH1106Wire display(0x3c, I2C_SDA, I2C_SCL, DISPLAY_GEOMETRY); PrintSplitter both(Serial, display); #else Print &both = Serial; #endif // some fake pin +#ifdef T3_V1_6_SX1276 +#define BUTTON_PIN 22 +#endif #define BUTTON BUTTON_PIN #include "HotButton.h" HotButton button(BUTTON); -void heltec_loop() { button.update(); } +void heltec_loop() +{ +#ifndef DT3_V1_6_SX1276 + button.update(); +#endif +} // This file contains a binary patch for the SX1262 #include "modules/SX126x/patches/SX126x_patch_scan.h" @@ -138,7 +156,7 @@ void heltec_setup() #ifndef HELTEC_NO_DISPLAY_INSTANCE heltec_display_power(true); display.init(); - display.setContrast(200); + // display.setContrast(200); display.flipScreenVertically(); #endif } diff --git a/include/global_config.h b/include/global_config.h index 1073b4d..a2014f7 100644 --- a/include/global_config.h +++ b/include/global_config.h @@ -1,6 +1,8 @@ #ifndef __GLOBAL_CONFIG_H__ #define __GLOBAL_CONFIG_H__ +#include "utilities.h" + #ifndef FREQ_BEGIN // frequency range in MHz to scan #define FREQ_BEGIN 850 @@ -25,14 +27,24 @@ #ifdef LILYGO #define BUZZER_PIN 45 #endif +#ifdef T3_V1_6_SX1276 +#define BUZZER_PIN 35 +#endif // REB trigger PIN #define REB_PIN 42 +#ifdef T3_V1_6_SX1276 +#define REB_PIN 35 +#endif #define WATERFALL_ENABLED true #define WATERFALL_START 37 #ifdef LILYGO -#define LED 46 +#define LED BOARD_LED #endif // end not LILYGO +#ifdef T3_V1_6_SX1276 +#define LED BOARD_LED +#endif + #endif diff --git a/platformio.ini b/platformio.ini index 84a0e9e..8cc17d2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -81,6 +81,31 @@ build_flags = -DARDUINO_LILYGO_T3_S3_V1_X -DARDUINO_USB_MODE=1 +[env:lilygo-T3-v1-6-xs1276] +platform = espressif32 +board = esp32dev +framework = arduino +upload_speed = 115200 +monitor_speed = 115200 +lib_deps = + ropg/Heltec_ESP32_LoRa_v3@^0.9.1 + RadioLib + U8g2 + XPowersLib +build_flags = + -DLILYGO + -DT3_V1_6_SX1276 + -DUSING_SX1276 + -DESP32 + -DARDUINO_ARCH_ESP32 + -DARDUINO_USB_CDC_ON_BOOT=0 ;; if not 0 - Serial issue + -DARDUINO_LILYGO_T3_V1_6 + -DARDUINO_USB_MODE=1 + +;; More old lylygo/titygo boeads defenitions you can find here: +;; https://github.com/PTR-projects/PTR_GroundStation_firmware/blob/main/platformio.ini +;; https://github.com/Xinyuan-LilyGO/LilyGo-LoRa-Series/blob/master/platformio.ini + [env:heltec_wifi_lora_32_V3-test-signal-generator] platform = espressif32 board = heltec_wifi_lora_32_V3 diff --git a/src/main.cpp b/src/main.cpp index f91b577..8ecbd0f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -395,6 +395,11 @@ void init_radio() both.println("Setting up radio"); #ifdef USING_SX1280PA // RADIOLIB_OR_HALT(radio.setBandwidth(RADIOLIB_SX128X_LORA_BW_406_25)); +#elif USING_SX1276 + // Receiver bandwidth in kHz. Allowed values + // are 2.6, 3.1, 3.9, 5.2, 6.3, 7.8, 10.4, 12.5, 15.6, 20.8, 25, 31.3, 41.7, + // 50, 62.5, 83.3, 100, 125, 166.7, 200 and 250 kHz. + RADIOLIB_OR_HALT(radio.setRxBandwidth(250)); #else RADIOLIB_OR_HALT(radio.setRxBandwidth(BANDWIDTH)); #endif @@ -420,6 +425,9 @@ void init_radio() { Serial.println("Error:startReceive:" + String(state)); } +#elif USING_SX1276 + // Sets carrier frequency. Allowed values range from 137.0 MHz to 1020.0 MHz. + radio.setFrequency(FREQ_BEGIN); #else radio.setFrequency(FREQ_BEGIN, true); #endif @@ -430,7 +438,7 @@ void init_radio() void setup(void) { #ifdef LILYGO - setupBoards(true); // true for disable U8g2 display library + setupBoards(); // true for disable U8g2 display library delay(500); Serial.println("Setup LiLyGO board is done"); #endif @@ -899,6 +907,8 @@ void loop(void) #ifdef USING_SX1280PA state = radio.setFrequency(freq); // 1280 doesn't have calibration radio.startReceive(RADIOLIB_SX128X_RX_TIMEOUT_INF); +#elif USING_SX1276 + state = radio.setFrequency(freq); #else state = radio.setFrequency(freq, false); // false = no calibration need here #endif From 207efeea37de0ea2ad01435e4513da5f4f9c2000 Mon Sep 17 00:00:00 2001 From: Egor Date: Tue, 1 Oct 2024 08:54:22 -0700 Subject: [PATCH 2/2] add 433 freq --- platformio.ini | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/platformio.ini b/platformio.ini index 8cc17d2..08579af 100644 --- a/platformio.ini +++ b/platformio.ini @@ -32,6 +32,21 @@ build_flags = -DHELTEC_POWER_BUTTON -DHELTEC +[env:heltec_wifi_lora_32_V3_433] +platform = espressif32 +board = heltec_wifi_lora_32_V3 +framework = arduino +upload_speed = 921600 +monitor_speed = 115200 +board_build.f_cpu = 240000000 +lib_deps = + ropg/Heltec_ESP32_LoRa_v3@^0.9.1 +build_flags = + -DHELTEC_POWER_BUTTON + -DHELTEC + -DFREQ_BEGIN=130 + -DFREQ_END=180 + -DRADIOLIB_CHECK_PARAMS=0 [env:lilygo-T3S3-v1-2-sx1262] platform = espressif32