From 92c7978b16c36cfe51dc9e7c0b059a02c7b14111 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Thu, 4 Jan 2024 21:56:17 -0300 Subject: [PATCH] heltec v3 plus GPS added --- platformio.ini | 11 ++++++----- src/LoRa_APRS_Tracker.cpp | 6 +++--- src/display.cpp | 3 +++ src/lora_utils.cpp | 12 ++++++------ src/msg_utils.cpp | 2 +- src/pins_config.h | 21 ++++++++++++++++----- src/power_utils.cpp | 11 +++++++---- 7 files changed, 42 insertions(+), 24 deletions(-) diff --git a/platformio.ini b/platformio.ini index 66aa194..a5d8050 100644 --- a/platformio.ini +++ b/platformio.ini @@ -52,10 +52,6 @@ build_flags = ${env.build_flags} -DARDUINO_USB_MODE=1 -DARDUINO_USB_CDC_ON_BOOT=1 - ;-UARDUINO_USB_CDC_ON_BOOT - ;-UARDUINO_USB_DFU_ON_BOOT - ;-UARDUINO_USB_MSC_ON_BOOT - ;-DCORE_DEBUG_LEVEL=0 [env:ttgo-t-beam-v1_2] board = ttgo-t-beam @@ -97,4 +93,9 @@ build_flags = -Werror -Wall -DTTGO_T_Beam_V0_7 board = esp32-s3-devkitc-1 build_flags = ${esp32s3_base.build_flags} -DTTGO_T_Beam_S3_SUPREME_V3 - -DBOARD_HAS_PSRAM \ No newline at end of file + -DBOARD_HAS_PSRAM + +[env:heltec_V3_GPS] +board = heltec_wifi_kit_32_V3 +build_flags = -DHELTEC_V3_GPS +board_build.mcu = esp32s3 \ No newline at end of file diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index f02f5f6..7d7b49e 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -27,7 +27,7 @@ Configuration Config; HardwareSerial neo6m_gps(1); TinyGPSPlus gps; -#ifndef TTGO_T_Beam_S3_SUPREME_V3 +#if !defined(TTGO_T_Beam_S3_SUPREME_V3) && !defined(HELTEC_V3_GPS) BluetoothSerial SerialBT; #endif #if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3) @@ -142,7 +142,7 @@ void setup() { if (Config.bluetoothType==0) { BLE_Utils::setup(); } else { - #ifndef TTGO_T_Beam_S3_SUPREME_V3 + #if !defined(TTGO_T_Beam_S3_SUPREME_V3) && !defined(HELTEC_V3_GPS) BLUETOOTH_Utils::setup(); #endif } @@ -193,7 +193,7 @@ void loop() { if (Config.bluetoothType==0) { BLE_Utils::sendToLoRa(); } else { - #ifndef TTGO_T_Beam_S3_SUPREME_V3 + #if !defined(TTGO_T_Beam_S3_SUPREME_V3) && !defined(HELTEC_V3_GPS) BLUETOOTH_Utils::sendToLoRa(); #endif } diff --git a/src/display.cpp b/src/display.cpp index e2f8b8f..b00a1cf 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -12,6 +12,9 @@ #if defined(TTGO_T_Beam_S3_SUPREME_V3) #undef ssd1306 #endif +#if defined(HELTEC_V3_GPS) +#define OLED_DISPLAY_HAS_RST_PIN +#endif #ifdef ssd1306 #include diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp index 88737a4..b789cd3 100644 --- a/src/lora_utils.cpp +++ b/src/lora_utils.cpp @@ -16,7 +16,7 @@ SX1268 radio = new Module(RADIO_CS_PIN, RADIO_DIO1_PIN, RADIO_RST_PIN, RADIO_BUS bool transmissionFlag = true; bool enableInterrupt = true; #endif -#if defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3) +#if defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3) || defined(HELTEC_V3_GPS) SX1262 radio = new Module(RADIO_CS_PIN, RADIO_DIO1_PIN, RADIO_RST_PIN, RADIO_BUSY_PIN); bool transmissionFlag = true; bool enableInterrupt = true; @@ -25,13 +25,13 @@ bool enableInterrupt = true; namespace LoRa_Utils { void setFlag(void) { - #if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3) + #if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3) || defined(HELTEC_V3_GPS) transmissionFlag = true; #endif } void setup() { - #if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3) + #if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3) || defined(HELTEC_V3_GPS) logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "Set SPI pins!"); SPI.begin(RADIO_SCLK_PIN, RADIO_MISO_PIN, RADIO_MOSI_PIN); float freq = (float)Config.loramodule.frequency/1000000; @@ -46,7 +46,7 @@ namespace LoRa_Utils { radio.setSpreadingFactor(Config.loramodule.spreadingFactor); radio.setBandwidth(Config.loramodule.signalBandwidth); radio.setCodingRate(Config.loramodule.codingRate4); - #if defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3) + #if defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3) || defined(HELTEC_V3_GPS) state = radio.setOutputPower(Config.loramodule.power + 2); // values available: 10, 17, 22 --> if 20 in tracker_conf.json it will be updated to 22. #endif #ifdef ESP32_DIY_1W_LoRa_GPS @@ -99,7 +99,7 @@ namespace LoRa_Utils { if (Config.notification.buzzerActive && Config.notification.txBeep) { NOTIFICATION_Utils::beaconTxBeep(); } - #if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3) + #if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3) || defined(HELTEC_V3_GPS) int state = radio.transmit("\x3c\xff\x01" + newPacket); if (state == RADIOLIB_ERR_NONE) { //Serial.println(F("success!")); @@ -146,7 +146,7 @@ namespace LoRa_Utils { logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa Rx", "---> %s", packet.c_str()); } #endif - #if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3) + #if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3) || defined(HELTEC_V3_GPS) if (transmissionFlag) { transmissionFlag = false; radio.startReceive(); diff --git a/src/msg_utils.cpp b/src/msg_utils.cpp index 2c3cb8f..a7fb812 100644 --- a/src/msg_utils.cpp +++ b/src/msg_utils.cpp @@ -169,7 +169,7 @@ namespace MSG_Utils { if (Config.bluetoothType==0) { BLE_Utils::sendToPhone(packet.text.substring(3)); } else { - #ifndef TTGO_T_Beam_S3_SUPREME_V3 + #if !defined(TTGO_T_Beam_S3_SUPREME_V3) && !defined(HELTEC_V3_GPS) BLUETOOTH_Utils::sendPacket(packet.text.substring(3)); #endif } diff --git a/src/pins_config.h b/src/pins_config.h index 6bacddb..0641cfe 100644 --- a/src/pins_config.h +++ b/src/pins_config.h @@ -5,7 +5,7 @@ #undef OLED_SCL #undef OLED_RST -#ifndef TTGO_T_Beam_S3_SUPREME_V3 +#if !defined(TTGO_T_Beam_S3_SUPREME_V3) && !defined(HELTEC_V3_GPS) #define OLED_SDA 21 #define OLED_SCL 22 #define OLED_RST 16 @@ -67,17 +67,13 @@ #define BUTTON_PIN -1 #endif - #if defined(TTGO_T_Beam_S3_SUPREME_V3) #define OLED_SDA 17 #define OLED_SCL 18 #define OLED_RST 16 - #define GPS_RX 8 #define GPS_TX 9 - #define BUTTON_PIN 0 - #define RADIO_SCLK_PIN 12 #define RADIO_MISO_PIN 13 #define RADIO_MOSI_PIN 11 @@ -86,7 +82,22 @@ #define RADIO_RST_PIN 5 #define RADIO_DIO1_PIN 1 #define RADIO_BUSY_PIN 4 +#endif +#if defined(HELTEC_V3_GPS) +#define OLED_SDA 17 +#define OLED_SCL 18 +#define OLED_RST 21 +#define GPS_RX 19 +#define GPS_TX 20 +#define BUTTON_PIN 0 +#define RADIO_SCLK_PIN 9 +#define RADIO_MISO_PIN 11 +#define RADIO_MOSI_PIN 10 +#define RADIO_CS_PIN 8 +#define RADIO_RST_PIN 12 +#define RADIO_DIO1_PIN 14 +#define RADIO_BUSY_PIN 13 #endif diff --git a/src/power_utils.cpp b/src/power_utils.cpp index 0f09ca4..840680a 100644 --- a/src/power_utils.cpp +++ b/src/power_utils.cpp @@ -49,6 +49,9 @@ namespace POWER_Utils { #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3) return PMU.getBattVoltage() / 1000.0; #endif + #if defined(HELTEC_V3_GPS) + return 0; // Add measurement later + #endif } String getBatteryInfoVoltage() { @@ -76,7 +79,7 @@ namespace POWER_Utils { } bool isCharging() { - #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) + #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(HELTEC_V3_GPS) return 0; #endif #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3) @@ -93,7 +96,7 @@ namespace POWER_Utils { } double getBatteryChargeDischargeCurrent() { - #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) + #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(HELTEC_V3_GPS) return 0; #endif #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) @@ -108,7 +111,7 @@ namespace POWER_Utils { } bool isBatteryConnected() { - #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) + #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(HELTEC_V3_GPS) if(getBatteryVoltage() > 1.0) { return true; } else { @@ -207,7 +210,7 @@ namespace POWER_Utils { } bool begin(TwoWire &port) { - #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) + #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(HELTEC_V3_GPS) return true; // nor powerManagment chip for this boards (only a few measure battery voltage). #endif #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268)