mirror of
https://github.com/agessaman/MeshCore.git
synced 2026-08-28 02:54:05 +00:00
fix(observer): recover T-Beam Supreme display startup
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include "UITask.h"
|
||||
static UITask ui_task(board, display);
|
||||
static bool display_ready = false;
|
||||
#endif
|
||||
|
||||
#ifdef ETHERNET_ENABLED
|
||||
@@ -52,7 +53,8 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
if (display.begin()) {
|
||||
display_ready = display.begin();
|
||||
if (display_ready) {
|
||||
display.startFrame();
|
||||
display.setCursor(0, 0);
|
||||
display.print("Please wait...");
|
||||
@@ -112,7 +114,9 @@ void setup() {
|
||||
the_mesh.begin(fs);
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.begin(the_mesh.getNodePrefs(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION);
|
||||
if (display_ready) {
|
||||
ui_task.begin(the_mesh.getNodePrefs(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ETHERNET_ENABLED
|
||||
@@ -193,7 +197,7 @@ void loop() {
|
||||
the_mesh.loop();
|
||||
sensors.loop();
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.loop();
|
||||
if (display_ready) ui_task.loop();
|
||||
#endif
|
||||
rtc_clock.tick();
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include "UITask.h"
|
||||
static UITask ui_task(display);
|
||||
static bool display_ready = false;
|
||||
#endif
|
||||
|
||||
StdRNG fast_rng;
|
||||
@@ -37,7 +38,8 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
if (display.begin()) {
|
||||
display_ready = display.begin();
|
||||
if (display_ready) {
|
||||
display.startFrame();
|
||||
display.setCursor(0, 0);
|
||||
display.print("Please wait...");
|
||||
@@ -88,7 +90,9 @@ void setup() {
|
||||
the_mesh.begin(fs);
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.begin(the_mesh.getNodePrefs(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION);
|
||||
if (display_ready) {
|
||||
ui_task.begin(the_mesh.getNodePrefs(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ETHERNET_ENABLED
|
||||
@@ -151,7 +155,7 @@ void loop() {
|
||||
the_mesh.loop();
|
||||
sensors.loop();
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.loop();
|
||||
if (display_ready) ui_task.loop();
|
||||
#endif
|
||||
rtc_clock.tick();
|
||||
#ifdef HAS_EXTERNAL_WATCHDOG
|
||||
|
||||
@@ -24,18 +24,36 @@ bool SH1106Display::begin()
|
||||
{
|
||||
// Wire must already be initialised by board.begin() before this is called.
|
||||
// Boards with non-standard SH1106 addresses should define DISPLAY_ADDRESS
|
||||
// in their variant/platformio configuration.
|
||||
return i2c_probe(Wire, DISPLAY_ADDRESS) && display.begin(DISPLAY_ADDRESS, true);
|
||||
// in their variant/platformio configuration. Some board revisions may have
|
||||
// different solder-bridge address configurations, so variants can also
|
||||
// provide DISPLAY_ADDRESS_ALT as a fallback.
|
||||
_initialized = false;
|
||||
if (i2c_probe(Wire, DISPLAY_ADDRESS) && display.begin(DISPLAY_ADDRESS, true)) {
|
||||
_initialized = true;
|
||||
}
|
||||
#ifdef DISPLAY_ADDRESS_ALT
|
||||
if (!_initialized && DISPLAY_ADDRESS_ALT != DISPLAY_ADDRESS &&
|
||||
i2c_probe(Wire, DISPLAY_ADDRESS_ALT) &&
|
||||
display.begin(DISPLAY_ADDRESS_ALT, true)) {
|
||||
_initialized = true;
|
||||
}
|
||||
#endif
|
||||
return _initialized;
|
||||
}
|
||||
|
||||
void SH1106Display::turnOn()
|
||||
{
|
||||
if (!_initialized) return;
|
||||
display.oled_command(SH110X_DISPLAYON);
|
||||
_isOn = true;
|
||||
}
|
||||
|
||||
void SH1106Display::turnOff()
|
||||
{
|
||||
if (!_initialized) {
|
||||
_isOn = false;
|
||||
return;
|
||||
}
|
||||
display.oled_command(SH110X_DISPLAYOFF);
|
||||
_isOn = false;
|
||||
}
|
||||
|
||||
@@ -17,16 +17,20 @@
|
||||
class SH1106Display : public DisplayDriver
|
||||
{
|
||||
Adafruit_SH1106G display;
|
||||
bool _initialized;
|
||||
bool _isOn;
|
||||
uint8_t _color;
|
||||
|
||||
bool i2c_probe(TwoWire &wire, uint8_t addr);
|
||||
|
||||
public:
|
||||
SH1106Display() : DisplayDriver(128, 64), display(128, 64, &Wire, PIN_OLED_RESET) { _isOn = false; }
|
||||
SH1106Display() : DisplayDriver(128, 64), display(128, 64, &Wire, PIN_OLED_RESET) {
|
||||
_initialized = false;
|
||||
_isOn = false;
|
||||
}
|
||||
bool begin();
|
||||
|
||||
bool isOn() override { return _isOn; }
|
||||
bool isOn() override { return _initialized && _isOn; }
|
||||
void turnOn() override;
|
||||
void turnOff() override;
|
||||
void clear() override;
|
||||
|
||||
@@ -20,6 +20,7 @@ build_flags =
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D DISPLAY_CLASS=SH1106Display
|
||||
-D DISPLAY_ADDRESS=0x3D
|
||||
-D DISPLAY_ADDRESS_ALT=0x3C
|
||||
-D LORA_TX_POWER=22
|
||||
-D P_LORA_TX_LED=6
|
||||
-D PIN_BOARD_SDA=17
|
||||
|
||||
Reference in New Issue
Block a user