From 3b0658aaf524bd0b934dc4d537a270f98a39d74b Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 30 Oct 2022 21:15:43 +0100 Subject: [PATCH] Added display support for T-Beam, Heltec and LoRa32 boards --- Config.h | 2 +- Display.h | 29 +++++++++++++++++++++++++++-- Utilities.h | 1 - 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/Config.h b/Config.h index e7aaae7..d7a7fd6 100644 --- a/Config.h +++ b/Config.h @@ -170,7 +170,7 @@ const int pin_led_rx = 25; const int pin_led_tx = 25; #endif - #define HAS_DISPLAY true + #define HAS_DISPLAY true #define HAS_BLUETOOTH true #elif BOARD_MODEL == BOARD_RNODE_NG_20 const int pin_cs = 18; diff --git a/Display.h b/Display.h index 2697180..87e9484 100644 --- a/Display.h +++ b/Display.h @@ -4,8 +4,22 @@ #include #define DISP_W 128 #define DISP_H 64 -#define DISP_RST -1 -#define DISP_ADDR 0x3c +#if BOARD_MODEL == BOARD_RNODE_NG_20 || BOARD_MODEL == BOARD_LORA32_V2_0 + #define DISP_RST -1 + #define DISP_ADDR 0x3C +#elif BOARD_MODEL == BOARD_TBEAM + #define DISP_RST 23 + #define DISP_ADDR 0x3D +#elif BOARD_MODEL == BOARD_HELTEC32_V2 + #define DISP_RST 16 + #define DISP_ADDR 0x3C + #define SCL_OLED 15 + #define SDA_OLED 4 +#else + #define DISP_RST -1 + #define DISP_ADDR 0x3C +#endif + Adafruit_SSD1306 display(DISP_W, DISP_H, &Wire, DISP_RST); #define DISP_MODE_UNKNOWN 0x00 @@ -54,6 +68,8 @@ bool display_init() { digitalWrite(pin_display_en, LOW); delay(50); digitalWrite(pin_display_en, HIGH); + #elif BOARD_MODEL == BOARD_HELTEC32_V2 + Wire.begin(SDA_OLED, SCL_OLED); #endif if(!display.begin(SSD1306_SWITCHCAPVCC, DISP_ADDR)) { @@ -65,9 +81,18 @@ bool display_init() { #elif BOARD_MODEL == BOARD_RNODE_NG_21 disp_mode = DISP_MODE_PORTRAIT; display.setRotation(3); + #elif BOARD_MODEL == BOARD_LORA32_V2_0 + disp_mode = DISP_MODE_PORTRAIT; + display.setRotation(3); #elif BOARD_MODEL == BOARD_LORA32_V2_1 disp_mode = DISP_MODE_LANDSCAPE; display.setRotation(0); + #elif BOARD_MODEL == BOARD_TBEAM + disp_mode = DISP_MODE_LANDSCAPE; + display.setRotation(0); + #elif BOARD_MODEL == BOARD_HELTEC32_V2 + disp_mode = DISP_MODE_PORTRAIT; + display.setRotation(1); #else disp_mode = DISP_MODE_PORTRAIT; display.setRotation(3); diff --git a/Utilities.h b/Utilities.h index d5ed1e7..ad9f31f 100644 --- a/Utilities.h +++ b/Utilities.h @@ -461,7 +461,6 @@ void serial_write(uint8_t byte) { if (bt_state != BT_STATE_CONNECTED) { Serial.write(byte); } else { - Serial.printf("BT Echo: %02X\n", byte); SerialBT.write(byte); } #else