Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic SSD1306 display support for ESP32 added #1847

Merged
merged 3 commits into from
Jan 5, 2024
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
44 changes: 40 additions & 4 deletions docs/use/displays.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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'
```
4 changes: 3 additions & 1 deletion main/ZdisplaySSD1306.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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) {
Expand Down