mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Merge pull request #1486 from Quency-D/fix-heltec-v4-tft
Add heltec v4-tft code.
This commit is contained in:
commit
fedf703262
8 changed files with 267 additions and 45 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue