diff --git a/docs/use/displays.md b/docs/use/displays.md index f820cee6fb..e382050dd5 100644 --- a/docs/use/displays.md +++ b/docs/use/displays.md @@ -1,6 +1,6 @@ # Displays -## SSD1306 Display (Heltec SX127X and LILYGO® LoRa32 boards) +## SSD1306 Display (Heltec SX127X, LILYGO® LoRa32 boards, generic SSD1306 displays) Several options are available for the display of information on the SSD1306 display. Some options are exclusive to each other, and when a different option is enabled, the current option is disabled. The current SSD1306 display states are being published to the `SSD1306toMQTT` topic, e.g. @@ -69,7 +69,7 @@ you can also revert it back with `mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoSSD1306/config -m '{"log-oled":false}'` -The log level of the messages displayed is Errors and Warnings, and this can only be changed via the compiler directive `-DLOG_LEVEL_OLED=LOG_LEVEL_NOTICE`. +The log level of the messages displayed is Errors and Warnings, and this can only be changed via the compiler directive `-DLOG_LEVEL_OLED=LOG_LEVEL_NOTICE`. ### Displaying Module json messages (default) @@ -97,12 +97,48 @@ At any time, you can reload the stored configuration with the command: If you want to erase the stored configuration, use the command: -`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoSSD1306/config -m '{"erase":true}'` +`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoSSD1306/config -m '{"erase":true}'` Note that this will not change the running configuration, it only ensures that the default configuration is used at next startup. If you want to load the default configuration use the command: -`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoSSD1306/config -m '{"init":true}'` +`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoSSD1306/config -m '{"init":true}'` Note that this will not change the stored configuration, `erase` or `save` is still needed to overwrite the saved configuration. + +### Connecting a generic SSD1306 display to ESP32 +It is possible to connect a generic SSD1306 display with resolution 128*64 to the hardware setups. +This example describes how to do it with the ESP32 board. +- Connect the display to the ESP32 (display → ESP32): + - VCC → 5V (or 3.3V, check your display documentation) + - GND → GND + - SCL → pin 22 + - SDA → pin 21 +- Modify the environment definition in `environments.ini`. + - Add the display library: + ``` + lib_deps = + ${com-esp32.lib_deps} + ... + ${libraries.ssd1306} + ``` + - Add relevant build flags: + ``` + build_flags = + ${com-esp32.build_flags} + ... + ; *** Generic SSD1306 OLED Options ** + '-DZdisplaySSD1306="GenericSSD1306"' + '-DOLED_SDA=21' ; SSD1306 pin SDA + '-DOLED_SCL=22' ; SSD1306 pin SCL + '-DGenericSSD1306=true' + '-DJSON_TO_OLED=true' + '-DDISPLAY_PAGE_INTERVAL=30' + ; '-DLOG_TO_OLED=true' ; Enable log to OLED + ; '-DLOG_LEVEL_OLED=LOG_LEVEL_NOTICE' + ; '-DDISPLAY_IDLE_LOGO=false' + ; '-DDISPLAY_BRIGHTNESS=80' + ; '-DDISPLAY_METRIC=false' + ; '-DDISPLAY_FLIP=false' + ``` diff --git a/main/ZdisplaySSD1306.ino b/main/ZdisplaySSD1306.ino index 799690f093..b791df7e0a 100644 --- a/main/ZdisplaySSD1306.ino +++ b/main/ZdisplaySSD1306.ino @@ -302,6 +302,8 @@ OledSerial::OledSerial(int x) { // delay(50); // digitalWrite(OLED_RST, HIGH); display = new SSD1306Wire(0x3c, OLED_SDA, OLED_SCL, GEOMETRY_128_64); +# elif defined(GenericSSD1306) // a generic ssd1306 oled with of size 128*64 + display = new SSD1306Wire(0x3c, OLED_SDA, OLED_SCL, GEOMETRY_128_64); # endif } @@ -357,7 +359,7 @@ void OledSerial::flush(void) { } /* -Erase display and paint it with the color. Used to +Erase display and paint it with the color. Used to */ void OledSerial::fillScreen(OLEDDISPLAY_COLOR color) { if (xSemaphoreTake(semaphoreOLEDOperation, pdMS_TO_TICKS(30000)) == pdTRUE) {