diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 22ff92feb..17e2fbf5a 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -93,6 +93,7 @@ jobs: - board: heltec-v3 - board: heltec-wsl-v3 - board: heltec-wireless-tracker + - board: heltec-wireless-tracker-V1-0 - board: heltec-wireless-paper - board: tbeam-s3-core - board: tlora-t3s3-v1 diff --git a/protobufs b/protobufs index 5f28be497..4432d3bfc 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 5f28be497a5518334c86378335e8ffcd177ed661 +Subproject commit 4432d3bfc155107e27079d96ddba16b52f2d9ea3 diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index ef3f6182c..9475e0296 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -90,11 +90,9 @@ class LGFX : public lgfx::LGFX_Device auto cfg = _light_instance.config(); // Gets a structure for backlight settings. #ifdef ST7735_BL_V03 - if (heltec_version == 3) { - cfg.pin_bl = ST7735_BL_V03; - } else { - cfg.pin_bl = ST7735_BL_V05; - } + cfg.pin_bl = ST7735_BL_V03; +#elif defined(ST7735_BL_V05) + cfg.pin_bl = ST7735_BL_V05; #else cfg.pin_bl = ST7735_BL; // Pin number to which the backlight is connected #endif @@ -471,30 +469,27 @@ void TFTDisplay::sendCommand(uint8_t com) display(true); if (settingsMap[displayBacklight] > 0) digitalWrite(settingsMap[displayBacklight], TFT_BACKLIGHT_ON); -#elif defined(ST7735_BACKLIGHT_EN_V03) && defined(TFT_BACKLIGHT_ON) - if (heltec_version == 3) { - digitalWrite(ST7735_BACKLIGHT_EN_V03, TFT_BACKLIGHT_ON); - } else { - digitalWrite(ST7735_BACKLIGHT_EN_V05, TFT_BACKLIGHT_ON); - } +#elif defined(ST7735_BL_V03) + digitalWrite(ST7735_BL_V03, TFT_BACKLIGHT_ON); +#elif defined(ST7735_BL_V05) + pinMode(ST7735_BL_V05, OUTPUT); + digitalWrite(ST7735_BL_V05, TFT_BACKLIGHT_ON); #endif #if defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) digitalWrite(TFT_BL, TFT_BACKLIGHT_ON); #endif + #ifdef VTFT_CTRL_V03 - if (heltec_version == 3) { - digitalWrite(VTFT_CTRL_V03, LOW); - } else { - digitalWrite(VTFT_CTRL_V05, LOW); - } + digitalWrite(VTFT_CTRL_V03, LOW); #endif + #ifdef VTFT_CTRL digitalWrite(VTFT_CTRL, LOW); #endif #ifdef RAK14014 #elif !defined(M5STACK) - tft->setBrightness(128); + tft->setBrightness(172); #endif break; } @@ -503,22 +498,17 @@ void TFTDisplay::sendCommand(uint8_t com) tft->clear(); if (settingsMap[displayBacklight] > 0) digitalWrite(settingsMap[displayBacklight], !TFT_BACKLIGHT_ON); -#elif defined(ST7735_BACKLIGHT_EN_V03) && defined(TFT_BACKLIGHT_ON) - if (heltec_version == 3) { - digitalWrite(ST7735_BACKLIGHT_EN_V03, !TFT_BACKLIGHT_ON); - } else { - digitalWrite(ST7735_BACKLIGHT_EN_V05, !TFT_BACKLIGHT_ON); - } +#elif defined(ST7735_BL_V03) + digitalWrite(ST7735_BL_V03, !TFT_BACKLIGHT_ON); +#elif defined(ST7735_BL_V05) + pinMode(ST7735_BL_V05, OUTPUT); + digitalWrite(ST7735_BL_V05, !TFT_BACKLIGHT_ON); #endif #if defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) digitalWrite(TFT_BL, !TFT_BACKLIGHT_ON); #endif #ifdef VTFT_CTRL_V03 - if (heltec_version == 3) { - digitalWrite(VTFT_CTRL_V03, HIGH); - } else { - digitalWrite(VTFT_CTRL_V05, HIGH); - } + digitalWrite(VTFT_CTRL_V03, HIGH); #endif #ifdef VTFT_CTRL digitalWrite(VTFT_CTRL, HIGH); @@ -588,14 +578,11 @@ bool TFTDisplay::connect() LOG_INFO("Power to TFT Backlight\n"); #endif -#ifdef ST7735_BACKLIGHT_EN_V03 - if (heltec_version == 3) { - pinMode(ST7735_BACKLIGHT_EN_V03, OUTPUT); - digitalWrite(ST7735_BACKLIGHT_EN_V03, TFT_BACKLIGHT_ON); - } else { - pinMode(ST7735_BACKLIGHT_EN_V05, OUTPUT); - digitalWrite(ST7735_BACKLIGHT_EN_V05, TFT_BACKLIGHT_ON); - } +#ifdef ST7735_BL_V03 + digitalWrite(ST7735_BL_V03, TFT_BACKLIGHT_ON); +#elif defined(ST7735_BL_V05) + pinMode(ST7735_BL_V05, OUTPUT); + digitalWrite(ST7735_BL_V05, TFT_BACKLIGHT_ON); #endif tft->init(); diff --git a/src/main.cpp b/src/main.cpp index 2af912d15..fbfb983d2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -159,25 +159,6 @@ const char *getDeviceName() return name; } -#ifdef VEXT_ENABLE_V03 - -#include - -static uint32_t calibrate_one(rtc_cal_sel_t cal_clk, const char *name) -{ - const uint32_t cal_count = 1000; - uint32_t cali_val; - for (int i = 0; i < 5; ++i) { - cali_val = rtc_clk_cal(cal_clk, cal_count); - } - return cali_val; -} - -int heltec_version = 3; - -#define CALIBRATE_ONE(cali_clk) calibrate_one(cali_clk, #cali_clk) -#endif - static int32_t ledBlinker() { static bool ledOn; @@ -243,61 +224,31 @@ void setup() digitalWrite(PIN_EINK_PWR_ON, HIGH); #endif -#if defined(LORA_TCXO_GPIO) - pinMode(LORA_TCXO_GPIO, OUTPUT); - digitalWrite(LORA_TCXO_GPIO, HIGH); -#endif - -#ifdef ST7735_BL_V03 // Heltec Wireless Tracker PCB Change Detect/Hack - - rtc_clk_32k_enable(true); - CALIBRATE_ONE(RTC_CAL_RTC_MUX); - if (CALIBRATE_ONE(RTC_CAL_32K_XTAL) != 0) { - rtc_clk_slow_freq_set(RTC_SLOW_FREQ_32K_XTAL); - CALIBRATE_ONE(RTC_CAL_RTC_MUX); - CALIBRATE_ONE(RTC_CAL_32K_XTAL); - } - - if (rtc_clk_slow_freq_get() != RTC_SLOW_FREQ_32K_XTAL) { - heltec_version = 3; - } else { - heltec_version = 5; - } -#endif - #if defined(VEXT_ENABLE_V03) - if (heltec_version == 3) { - pinMode(VEXT_ENABLE_V03, OUTPUT); - digitalWrite(VEXT_ENABLE_V03, 0); // turn on the display power - LOG_DEBUG("HELTEC Detect Tracker V1.0\n"); - } else { - pinMode(VEXT_ENABLE_V05, OUTPUT); - digitalWrite(VEXT_ENABLE_V05, 1); // turn on the display power - LOG_DEBUG("HELTEC Detect Tracker V1.1\n"); - } + pinMode(VEXT_ENABLE_V03, OUTPUT); + pinMode(ST7735_BL_V03, OUTPUT); + digitalWrite(VEXT_ENABLE_V03, 0); // turn on the display power and antenna boost + digitalWrite(ST7735_BL_V03, 1); // display backligth on + LOG_DEBUG("HELTEC Detect Tracker V1.0\n"); +#elif defined(VEXT_ENABLE_V05) + pinMode(VEXT_ENABLE_V05, OUTPUT); + pinMode(ST7735_BL_V05, OUTPUT); + digitalWrite(VEXT_ENABLE_V05, 1); // turn on the lora antenna boost + digitalWrite(ST7735_BL_V05, 1); // turn on display backligth + LOG_DEBUG("HELTEC Detect Tracker V1.1\n"); #elif defined(VEXT_ENABLE) pinMode(VEXT_ENABLE, OUTPUT); digitalWrite(VEXT_ENABLE, 0); // turn on the display power #endif #if defined(VGNSS_CTRL_V03) - if (heltec_version == 3) { - pinMode(VGNSS_CTRL_V03, OUTPUT); - digitalWrite(VGNSS_CTRL_V03, LOW); - } else { - pinMode(VGNSS_CTRL_V05, OUTPUT); - digitalWrite(VGNSS_CTRL_V05, LOW); - } + pinMode(VGNSS_CTRL_V03, OUTPUT); + digitalWrite(VGNSS_CTRL_V03, LOW); #endif #if defined(VTFT_CTRL_V03) - if (heltec_version == 3) { - pinMode(VTFT_CTRL_V03, OUTPUT); - digitalWrite(VTFT_CTRL_V03, LOW); - } else { - pinMode(VTFT_CTRL_V05, OUTPUT); - digitalWrite(VTFT_CTRL_V05, LOW); - } + pinMode(VTFT_CTRL_V03, OUTPUT); + digitalWrite(VTFT_CTRL_V03, LOW); #endif #if defined(VGNSS_CTRL) diff --git a/src/main.h b/src/main.h index 1a93298aa..5af0b4082 100644 --- a/src/main.h +++ b/src/main.h @@ -70,8 +70,6 @@ extern uint32_t shutdownAtMsec; extern uint32_t serialSinceMsec; -extern int heltec_version; - // If a thread does something that might need for it to be rescheduled ASAP it can set this flag // This will suppress the current delay and instead try to run ASAP. extern bool runASAP; diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h index 9fa4a5dd7..22d34aa33 100644 --- a/src/platform/esp32/architecture.h +++ b/src/platform/esp32/architecture.h @@ -106,7 +106,11 @@ #elif defined(HELTEC_WSL_V3) #define HW_VENDOR meshtastic_HardwareModel_HELTEC_WSL_V3 #elif defined(HELTEC_WIRELESS_TRACKER) +#ifdef HELTEC_TRACKER_V1_0 +#define HW_VENDOR meshtastic_HardwareModel_HELTEC_WIRELESS_TRACKER_V1_0 +#else #define HW_VENDOR meshtastic_HardwareModel_HELTEC_WIRELESS_TRACKER +#endif #elif defined(HELTEC_WIRELESS_PAPER_V1_0) #define HW_VENDOR meshtastic_HardwareModel_HELTEC_WIRELESS_PAPER_V1_0 #elif defined(HELTEC_WIRELESS_PAPER) diff --git a/src/sleep.cpp b/src/sleep.cpp index 464486d00..0f71ab25b 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -203,11 +203,10 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false) #endif #if defined(VEXT_ENABLE_V03) - if (heltec_version == 3) { - digitalWrite(VEXT_ENABLE_V03, 1); // turn off the display power - } else { - digitalWrite(VEXT_ENABLE_V05, 0); // turn off the display power - } + digitalWrite(VEXT_ENABLE_V03, 1); // turn off the display power +#elif defined(VEXT_ENABLE_V05) + digitalWrite(VEXT_ENABLE_V05, 0); // turn off the lora amplifier power + digitalWrite(ST7735_BL_V05, 0); // turn off the display power #elif defined(VEXT_ENABLE) digitalWrite(VEXT_ENABLE, 1); // turn off the display power #endif diff --git a/variants/heltec_wireless_tracker/pins_arduino.h b/variants/heltec_wireless_tracker/pins_arduino.h index e4d2631e7..5c0b529b0 100644 --- a/variants/heltec_wireless_tracker/pins_arduino.h +++ b/variants/heltec_wireless_tracker/pins_arduino.h @@ -5,8 +5,8 @@ #include #define WIFI_LoRa_32_V3 true -#define DISPLAY_HEIGHT 64 -#define DISPLAY_WIDTH 128 +#define DISPLAY_HEIGHT 80 +#define DISPLAY_WIDTH 160 #define USB_VID 0x303a #define USB_PID 0x1001 @@ -26,8 +26,8 @@ static const uint8_t LED_BUILTIN = 18; static const uint8_t TX = 43; static const uint8_t RX = 44; -static const uint8_t SDA = 41; -static const uint8_t SCL = 42; +static const uint8_t SDA = 45; +static const uint8_t SCL = 46; static const uint8_t SS = 8; static const uint8_t MOSI = 10; diff --git a/variants/heltec_wireless_tracker/platformio.ini b/variants/heltec_wireless_tracker/platformio.ini index fa79eeb6a..3259d563c 100644 --- a/variants/heltec_wireless_tracker/platformio.ini +++ b/variants/heltec_wireless_tracker/platformio.ini @@ -5,7 +5,9 @@ upload_protocol = esp-builtin build_flags = ${esp32s3_base.build_flags} -I variants/heltec_wireless_tracker - -DGPS_POWER_TOGGLE + -D HELTEC_TRACKER_V1_1 + -D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. + ;-D DEBUG_DISABLED ; uncomment this line to disable DEBUG output lib_deps = ${esp32s3_base.lib_deps} diff --git a/variants/heltec_wireless_tracker/variant.h b/variants/heltec_wireless_tracker/variant.h index ba2a0676a..167345e1a 100644 --- a/variants/heltec_wireless_tracker/variant.h +++ b/variants/heltec_wireless_tracker/variant.h @@ -1,5 +1,11 @@ #define LED_PIN 18 +#define HELTEC_TRACKER_V1_X + +// I2C +#define I2C_SDA SDA +#define I2C_SCL SCL + // ST7735S TFT LCD #define ST7735S 1 // there are different (sub-)versions of ST7735 #define ST7735_CS 38 @@ -9,25 +15,19 @@ #define ST7735_RESET 39 #define ST7735_MISO -1 #define ST7735_BUSY -1 -#define ST7735_BL_V03 45 #define ST7735_BL_V05 21 /* V1.1 PCB marking */ #define ST7735_SPI_HOST SPI3_HOST -#define ST7735_BACKLIGHT_EN_V03 45 -#define ST7735_BACKLIGHT_EN_V05 21 #define SPI_FREQUENCY 40000000 #define SPI_READ_FREQUENCY 16000000 #define SCREEN_ROTATE -#define TFT_HEIGHT 160 -#define TFT_WIDTH 80 +#define TFT_HEIGHT DISPLAY_WIDTH +#define TFT_WIDTH DISPLAY_HEIGHT #define TFT_OFFSET_X 26 -#define TFT_OFFSET_Y 0 -#define VTFT_CTRL_V03 46 // Heltec Tracker needs this pulled low for TFT -#define VTFT_CTRL_V05 -1 -#define SCREEN_TRANSITION_FRAMERATE 1 // fps +#define TFT_OFFSET_Y -1 +#define SCREEN_TRANSITION_FRAMERATE 3 // fps #define DISPLAY_FORCE_SMALL_FONTS -#define VEXT_ENABLE_V03 Vext // active low, powers the oled display and the lora antenna boost -#define VEXT_ENABLE_V05 3 // active HIGH, powers the oled display +#define VEXT_ENABLE_V05 3 // active HIGH, powers the lora antenna boost #define BUTTON_PIN 0 #define BATTERY_PIN 1 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage @@ -44,11 +44,6 @@ #define PIN_GPS_RESET 35 #define PIN_GPS_PPS 36 -#define VGNSS_CTRL_V03 37 // Heltec Tracker needs this pulled low for GPS -#define VGNSS_CTRL_V05 -1 // Heltec Tracker needs this pulled low for GPS -#define PIN_GPS_EN VGNSS_CTRL_V03 -#define GPS_EN_ACTIVE LOW - #define GPS_RESET_MODE LOW #define GPS_UC6580 diff --git a/variants/heltec_wireless_tracker_V1_0/pins_arduino.h b/variants/heltec_wireless_tracker_V1_0/pins_arduino.h new file mode 100644 index 000000000..5c0b529b0 --- /dev/null +++ b/variants/heltec_wireless_tracker_V1_0/pins_arduino.h @@ -0,0 +1,80 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include "soc/soc_caps.h" +#include + +#define WIFI_LoRa_32_V3 true +#define DISPLAY_HEIGHT 80 +#define DISPLAY_WIDTH 160 + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +#define EXTERNAL_NUM_INTERRUPTS 46 +#define NUM_DIGITAL_PINS 48 +#define NUM_ANALOG_INPUTS 20 + +static const uint8_t LED_BUILTIN = 18; +#define BUILTIN_LED LED_BUILTIN // backward compatibility +#define LED_BUILTIN LED_BUILTIN + +#define analogInputToDigitalPin(p) (((p) < 20) ? (analogChannelToDigitalPin(p)) : -1) +#define digitalPinToInterrupt(p) (((p) < 48) ? (p) : -1) +#define digitalPinHasPWM(p) (p < 46) + +static const uint8_t TX = 43; +static const uint8_t RX = 44; + +static const uint8_t SDA = 45; +static const uint8_t SCL = 46; + +static const uint8_t SS = 8; +static const uint8_t MOSI = 10; +static const uint8_t MISO = 11; +static const uint8_t SCK = 9; + +static const uint8_t A0 = 1; +static const uint8_t A1 = 2; +static const uint8_t A2 = 3; +static const uint8_t A3 = 4; +static const uint8_t A4 = 5; +static const uint8_t A5 = 6; +static const uint8_t A6 = 7; +static const uint8_t A7 = 8; +static const uint8_t A8 = 9; +static const uint8_t A9 = 10; +static const uint8_t A10 = 11; +static const uint8_t A11 = 12; +static const uint8_t A12 = 13; +static const uint8_t A13 = 14; +static const uint8_t A14 = 15; +static const uint8_t A15 = 16; +static const uint8_t A16 = 17; +static const uint8_t A17 = 18; +static const uint8_t A18 = 19; +static const uint8_t A19 = 20; + +static const uint8_t T1 = 1; +static const uint8_t T2 = 2; +static const uint8_t T3 = 3; +static const uint8_t T4 = 4; +static const uint8_t T5 = 5; +static const uint8_t T6 = 6; +static const uint8_t T7 = 7; +static const uint8_t T8 = 8; +static const uint8_t T9 = 9; +static const uint8_t T10 = 10; +static const uint8_t T11 = 11; +static const uint8_t T12 = 12; +static const uint8_t T13 = 13; +static const uint8_t T14 = 14; + +static const uint8_t Vext = 36; +static const uint8_t LED = 18; + +static const uint8_t RST_LoRa = 12; +static const uint8_t BUSY_LoRa = 13; +static const uint8_t DIO0 = 14; + +#endif /* Pins_Arduino_h */ diff --git a/variants/heltec_wireless_tracker_V1_0/platformio.ini b/variants/heltec_wireless_tracker_V1_0/platformio.ini new file mode 100644 index 000000000..034360c3d --- /dev/null +++ b/variants/heltec_wireless_tracker_V1_0/platformio.ini @@ -0,0 +1,14 @@ +[env:heltec-wireless-tracker-V1-0] +extends = esp32s3_base +board = heltec_wireless_tracker +upload_protocol = esp-builtin + +build_flags = + ${esp32s3_base.build_flags} -I variants/heltec_wireless_tracker_V1_0 + -D HELTEC_TRACKER_V1_0 + -D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. + ;-D DEBUG_DISABLED ; uncomment this line to disable DEBUG output + +lib_deps = + ${esp32s3_base.lib_deps} + lovyan03/LovyanGFX@^1.1.8 \ No newline at end of file diff --git a/variants/heltec_wireless_tracker_V1_0/variant.h b/variants/heltec_wireless_tracker_V1_0/variant.h new file mode 100644 index 000000000..84e77a6b9 --- /dev/null +++ b/variants/heltec_wireless_tracker_V1_0/variant.h @@ -0,0 +1,71 @@ +#define LED_PIN 18 + +#define HELTEC_TRACKER_V1_X + +// I2C +#define I2C_SDA SDA +#define I2C_SCL SCL + +// ST7735S TFT LCD +#define ST7735S 1 // there are different (sub-)versions of ST7735 +#define ST7735_CS 38 +#define ST7735_RS 40 // DC +#define ST7735_SDA 42 // MOSI +#define ST7735_SCK 41 +#define ST7735_RESET 39 +#define ST7735_MISO -1 +#define ST7735_BUSY -1 +#define ST7735_BL_V03 45 +#define ST7735_SPI_HOST SPI3_HOST +#define SPI_FREQUENCY 40000000 +#define SPI_READ_FREQUENCY 16000000 +#define SCREEN_ROTATE +#define TFT_HEIGHT DISPLAY_WIDTH +#define TFT_WIDTH DISPLAY_HEIGHT +#define TFT_OFFSET_X 26 +#define TFT_OFFSET_Y -1 +#define VTFT_CTRL_V03 46 // Heltec Tracker needs this pulled low for TFT +#define SCREEN_TRANSITION_FRAMERATE 3 // fps +#define DISPLAY_FORCE_SMALL_FONTS + +#define VEXT_ENABLE_V03 Vext // active low, powers the oled display and the lora antenna boost +#define BUTTON_PIN 0 + +#define BATTERY_PIN 1 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define ADC_CHANNEL ADC1_GPIO1_CHANNEL +#define ADC_ATTENUATION ADC_ATTEN_DB_2_5 // lower dB for high resistance voltage divider +#define ADC_MULTIPLIER 4.9 + +#undef GPS_RX_PIN +#undef GPS_TX_PIN +#define GPS_RX_PIN 33 +#define GPS_TX_PIN 34 +#define PIN_GPS_RESET 35 +#define PIN_GPS_PPS 36 + +#define VGNSS_CTRL_V03 37 // Heltec Tracker needs this pulled low for GPS +#define PIN_GPS_EN VGNSS_CTRL_V03 +#define GPS_EN_ACTIVE LOW + +#define GPS_RESET_MODE LOW +#define GPS_UC6580 + +#define USE_SX1262 +#define LORA_DIO0 -1 // a No connect on the SX1262 module +#define LORA_RESET 12 +#define LORA_DIO1 14 // SX1262 IRQ +#define LORA_DIO2 13 // SX1262 BUSY +#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262, if DIO3 is high the TXCO is enabled + +#define LORA_SCK 9 +#define LORA_MISO 11 +#define LORA_MOSI 10 +#define LORA_CS 8 + +#define SX126X_CS LORA_CS +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY LORA_DIO2 +#define SX126X_RESET LORA_RESET + +#define SX126X_DIO2_AS_RF_SWITCH +#define SX126X_DIO3_TCXO_VOLTAGE 1.8