Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions examples/simple_repeater/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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...");
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();

Expand Down
10 changes: 7 additions & 3 deletions examples/simple_room_server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#ifdef DISPLAY_CLASS
#include "UITask.h"
static UITask ui_task(display);
static bool display_ready = false;
#endif

StdRNG fast_rng;
Expand All @@ -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...");
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 20 additions & 2 deletions src/helpers/ui/SH1106Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 6 additions & 2 deletions src/helpers/ui/SH1106Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions variants/lilygo_tbeam_supreme_SX1262/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading