Merge pull request #1486 from Quency-D/fix-heltec-v4-tft

Add heltec v4-tft code.
This commit is contained in:
ripplebiz 2026-01-27 19:47:20 +11:00 committed by GitHub
commit fedf703262
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 267 additions and 45 deletions

View file

@ -7,6 +7,10 @@ bool SSD1306Display::i2c_probe(TwoWire& wire, uint8_t addr) {
}
bool SSD1306Display::begin() {
if (!_isOn) {
if (_peripher_power) _peripher_power->claim();
_isOn = true;
}
#ifdef DISPLAY_ROTATION
display.setRotation(DISPLAY_ROTATION);
#endif
@ -15,12 +19,18 @@ bool SSD1306Display::begin() {
void SSD1306Display::turnOn() {
display.ssd1306_command(SSD1306_DISPLAYON);
_isOn = true;
if (!_isOn) {
if (_peripher_power) _peripher_power->claim();
_isOn = true;
}
}
void SSD1306Display::turnOff() {
display.ssd1306_command(SSD1306_DISPLAYOFF);
_isOn = false;
if (_isOn) {
if (_peripher_power) _peripher_power->release();
_isOn = false;
}
}
void SSD1306Display::clear() {

View file

@ -5,6 +5,7 @@
#include <Adafruit_GFX.h>
#define SSD1306_NO_SPLASH
#include <Adafruit_SSD1306.h>
#include <helpers/RefCountedDigitalPin.h>
#ifndef PIN_OLED_RESET
#define PIN_OLED_RESET 21 // Reset pin # (or -1 if sharing Arduino reset pin)
@ -18,10 +19,16 @@ class SSD1306Display : public DisplayDriver {
Adafruit_SSD1306 display;
bool _isOn;
uint8_t _color;
RefCountedDigitalPin* _peripher_power;
bool i2c_probe(TwoWire& wire, uint8_t addr);
public:
SSD1306Display() : DisplayDriver(128, 64), display(128, 64, &Wire, PIN_OLED_RESET) { _isOn = false; }
SSD1306Display(RefCountedDigitalPin* peripher_power=NULL) : DisplayDriver(128, 64),
display(128, 64, &Wire, PIN_OLED_RESET),
_peripher_power(peripher_power)
{
_isOn = false;
}
bool begin();
bool isOn() override { return _isOn; }

View file

@ -28,11 +28,14 @@ bool ST7789LCDDisplay::begin() {
digitalWrite(PIN_TFT_LEDA_CTL, HIGH);
}
if (PIN_TFT_RST != -1) {
pinMode(PIN_TFT_RST, OUTPUT);
digitalWrite(PIN_TFT_RST, LOW);
delay(10);
digitalWrite(PIN_TFT_RST, HIGH);
}
// Im not sure if this is just a t-deck problem or not, if your display is slow try this.
#ifdef LILYGO_TDECK
#if defined(LILYGO_TDECK) || defined(HELTEC_LORA_V4_TFT)
displaySPI.begin(PIN_TFT_SCL, -1, PIN_TFT_SDA, PIN_TFT_CS);
#endif

View file

@ -8,7 +8,7 @@
#include <helpers/RefCountedDigitalPin.h>
class ST7789LCDDisplay : public DisplayDriver {
#ifdef LILYGO_TDECK
#if defined(LILYGO_TDECK) || defined(HELTEC_LORA_V4_TFT)
SPIClass displaySPI;
#endif
Adafruit_ST7789 display;
@ -25,7 +25,7 @@ public:
{
_isOn = false;
}
#elif LILYGO_TDECK
#elif defined(LILYGO_TDECK) || defined(HELTEC_LORA_V4_TFT)
ST7789LCDDisplay(RefCountedDigitalPin* peripher_power=NULL) : DisplayDriver(128, 64),
displaySPI(HSPI),
display(&displaySPI, PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_RST),