Merge pull request #258 from seagull9000/Heltec-Wireless-Tracker-support

Heltec Wireless Tracker support
This commit is contained in:
ripplebiz 2025-05-08 12:29:02 +10:00 committed by GitHub
commit 0e208f01cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 209 additions and 6 deletions

View file

@ -62,7 +62,9 @@
#ifdef DISPLAY_CLASS
#include "UITask.h"
#ifdef ST7789
#ifdef ST7735
#include <helpers/ui/ST7735Display.h>
#elif ST7789
#include <helpers/ui/ST7789Display.h>
#elif defined(HAS_GxEPD)
#include <helpers/ui/GxEPDDisplay.h>

View file

@ -3,6 +3,7 @@
#include <Arduino.h>
// LoRa radio module pins for Heltec V3
// Also for Heltec Wireless Tracker
#define P_LORA_DIO_1 14
#define P_LORA_NSS 8
#define P_LORA_RESET RADIOLIB_NC
@ -13,10 +14,12 @@
// built-ins
#define PIN_VBAT_READ 1
#define PIN_ADC_CTRL 37
#ifndef PIN_ADC_CTRL // set in platformio.ini for Heltec Wireless Tracker (2)
#define PIN_ADC_CTRL 37
#endif
#define PIN_ADC_CTRL_ACTIVE LOW
#define PIN_ADC_CTRL_INACTIVE HIGH
#define PIN_LED_BUILTIN 35
//#define PIN_LED_BUILTIN 35
#define PIN_VEXT_EN 36
#include "ESP32Board.h"

View file

@ -0,0 +1,125 @@
#ifdef ST7735
#include "ST7735Display.h"
#ifndef DISPLAY_ROTATION
#define DISPLAY_ROTATION 2
#endif
bool ST7735Display::i2c_probe(TwoWire& wire, uint8_t addr) {
return true;
/*
wire.beginTransmission(addr);
uint8_t error = wire.endTransmission();
return (error == 0);
*/
}
bool ST7735Display::begin() {
if(!_isOn) {
pinMode(PIN_TFT_VDD_CTL, OUTPUT);
pinMode(PIN_TFT_LEDA_CTL, OUTPUT);
digitalWrite(PIN_TFT_VDD_CTL, HIGH);
digitalWrite(PIN_TFT_LEDA_CTL, HIGH);
digitalWrite(PIN_TFT_RST, HIGH);
display.initR(INITR_MINI160x80_PLUGIN);
display.setRotation(DISPLAY_ROTATION);
display.setSPISpeed(40000000);
display.fillScreen(ST77XX_BLACK);
display.setTextColor(ST77XX_WHITE);
display.setTextSize(2);
display.cp437(true); // Use full 256 char 'Code Page 437' font
_isOn = true;
}
return true;
}
void ST7735Display::turnOn() {
ST7735Display::begin();
}
void ST7735Display::turnOff() {
digitalWrite(PIN_TFT_VDD_CTL, HIGH);
digitalWrite(PIN_TFT_LEDA_CTL, HIGH);
digitalWrite(PIN_TFT_RST, LOW);
digitalWrite(PIN_TFT_VDD_CTL, LOW);
digitalWrite(PIN_TFT_LEDA_CTL, LOW);
_isOn = false;
}
void ST7735Display::clear() {
//Serial.println("DBG: display.Clear");
display.fillScreen(ST77XX_BLACK);
}
void ST7735Display::startFrame(Color bkg) {
display.fillScreen(0x00);
display.setTextColor(ST77XX_WHITE);
display.setTextSize(1); // This one affects size of Please wait... message
display.cp437(true); // Use full 256 char 'Code Page 437' font
}
void ST7735Display::setTextSize(int sz) {
display.setTextSize(sz);
}
void ST7735Display::setColor(Color c) {
switch (c) {
case DisplayDriver::DARK :
_color = ST77XX_BLACK;
break;
case DisplayDriver::LIGHT :
_color = ST77XX_WHITE;
break;
case DisplayDriver::RED :
_color = ST77XX_RED;
break;
case DisplayDriver::GREEN :
_color = ST77XX_GREEN;
break;
case DisplayDriver::BLUE :
_color = ST77XX_BLUE;
break;
case DisplayDriver::YELLOW :
_color = ST77XX_YELLOW;
break;
case DisplayDriver::ORANGE :
_color = ST77XX_ORANGE;
break;
default:
_color = ST77XX_WHITE;
break;
}
display.setTextColor(_color);
}
void ST7735Display::setCursor(int x, int y) {
display.setCursor(x, y);
}
void ST7735Display::print(const char* str) {
display.print(str);
}
void ST7735Display::fillRect(int x, int y, int w, int h) {
display.fillRect(x, y, w, h, _color);
}
void ST7735Display::drawRect(int x, int y, int w, int h) {
display.drawRect(x, y, w, h, _color);
}
void ST7735Display::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
display.drawBitmap(x, y, bits, w, h, _color);
}
void ST7735Display::endFrame() {
// display.display();
}
#endif

View file

@ -0,0 +1,36 @@
#pragma once
#include "DisplayDriver.h"
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
class ST7735Display : public DisplayDriver {
Adafruit_ST7735 display;
bool _isOn;
uint16_t _color;
bool i2c_probe(TwoWire& wire, uint8_t addr);
public:
#ifdef USE_PIN_TFT
ST7735Display() : DisplayDriver(80, 160), display(PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_SDA, PIN_TFT_SCL, PIN_TFT_RST) { _isOn = false; }
#else
ST7735Display() : DisplayDriver(80, 160), display(&SPI1, PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_RST) { _isOn = false; }
#endif
bool begin();
bool isOn() override { return _isOn; }
void turnOn() override;
void turnOff() override;
void clear() override;
void startFrame(Color bkg = DARK) override;
void setTextSize(int sz) override;
void setColor(Color c) override;
void setCursor(int x, int y) override;
void print(const char* str) override;
void fillRect(int x, int y, int w, int h) override;
void drawRect(int x, int y, int w, int h) override;
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override;
void endFrame() override;
};

View file

@ -8,9 +8,9 @@ build_flags =
-D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D LORA_TX_POWER=22
-D P_LORA_TX_LED=35
-D PIN_BOARD_SDA=17
-D PIN_BOARD_SCL=18
-D P_LORA_TX_LED=35 ; Heltec WT redefines this
-D PIN_BOARD_SDA=17 ; Heltec WT redefines this
-D PIN_BOARD_SCL=18 ; Heltec WT redefines this
-D PIN_USER_BTN=0
-D SX126X_DIO2_AS_RF_SWITCH=true
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
@ -187,3 +187,40 @@ build_src_filter = ${Heltec_lora32_v3.build_src_filter}
lib_deps =
${Heltec_lora32_v3.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:Heltec_Wireless_Tracker_companion_radio_ble]
extends = Heltec_lora32_v3
build_flags =
${Heltec_lora32_v3.build_flags}
-I src/helpers/ui
; -D ARDUINO_USB_CDC_ON_BOOT=1 ; need for debugging
-D ST7735
-D PIN_ADC_CTRL=2 ; redefines the V3 pin
-D DISPLAY_ROTATION=1
-D DISPLAY_CLASS=ST7735Display
-D USE_PIN_TFT=1
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
-D BLE_PIN_CODE=123456 ; HWT will use display for pin
; -D BLE_DEBUG_LOGGING=1
-D P_LORA_TX_LED=18
-D PIN_TFT_SDA=42 ; SDIN
-D PIN_TFT_SCL=41 ; SCLK
-D PIN_TFT_DC=40 ; RS (register select)
-D PIN_TFT_RST=39 ; RES
-D PIN_TFT_CS=38
-D PIN_TFT_VDD_CTL=3 ; Vext is connected to VDD which is also connected to LEDA
-D PIN_TFT_LEDA_CTL=21 ; LEDK (switches on/off via mosfet to create the ground)
; -D ENABLE_PRIVATE_KEY_IMPORT=1
; -D ENABLE_PRIVATE_KEY_EXPORT=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_lora32_v3.build_src_filter}
+<helpers/esp32/*.cpp>
+<../examples/companion_radio>
+<helpers/ui/ST7735Display.cpp>
lib_deps =
${Heltec_lora32_v3.lib_deps}
densaugeo/base64 @ ~1.4.0
adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0