Skip to content

Commit 0de2b4f

Browse files
Move Supreme OLED address to variant config
Keep SH1106Display generic by relying on DISPLAY_ADDRESS while the T-Beam Supreme variant declares its 0x3D OLED address.
1 parent b8b6598 commit 0de2b4f

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

src/helpers/ui/SH1106Display.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,10 @@ bool SH1106Display::i2c_probe(TwoWire &wire, uint8_t addr)
1111

1212
bool SH1106Display::begin()
1313
{
14-
// Address selection: on some board revisions (notably the LilyGo T-Beam
15-
// Supreme V3) the OLED lives at 0x3D because 0x3C is occupied by a
16-
// magnetometer (QMC6310N). 0x3D is only ever used by the OLED, so prefer it
17-
// when present, otherwise fall back to the standard 0x3C (DISPLAY_ADDRESS).
18-
uint8_t addr = 0;
19-
if (i2c_probe(Wire, 0x3D)) {
20-
addr = 0x3D;
21-
} else if (i2c_probe(Wire, DISPLAY_ADDRESS)) {
22-
addr = DISPLAY_ADDRESS;
23-
}
24-
return addr && display.begin(addr, true);
14+
// Wire must already be initialised by board.begin() before this is called.
15+
// Boards with non-standard SH1106 addresses should define DISPLAY_ADDRESS
16+
// in their variant/platformio configuration.
17+
return i2c_probe(Wire, DISPLAY_ADDRESS) && display.begin(DISPLAY_ADDRESS, true);
2518
}
2619

2720
void SH1106Display::turnOn()

variants/lilygo_tbeam_supreme_SX1262/platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ build_flags =
1818
-D RADIO_CLASS=CustomSX1262
1919
-D WRAPPER_CLASS=CustomSX1262Wrapper
2020
-D DISPLAY_CLASS=SH1106Display
21+
-D DISPLAY_ADDRESS=0x3D
2122
-D LORA_TX_POWER=22
2223
-D P_LORA_TX_LED=6
2324
-D PIN_BOARD_SDA=17

0 commit comments

Comments
 (0)