Skip to content

Commit

Permalink
lcd to oled
Browse files Browse the repository at this point in the history
lcd to oled renaming
  • Loading branch information
DigiH committed Mar 3, 2023
1 parent 9c661c4 commit cff87dd
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 51 deletions.
18 changes: 9 additions & 9 deletions docs/use/displays.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Several options are available for the display of information on the SSD1306 disp

The current SSD1306 display states are being published to the `SSD1306toMQTT` topic, e.g.

`{"onstate":true,"brightness":50,"display-metric":true,"display-flip":true,"idlelogo":true,"log-lcd":false,"json-lcd":true}`
`{"onstate":true,"brightness":50,"display-metric":true,"display-flip":true,"idlelogo":true,"log-oled":false,"json-oled":true}`

### Display ON/OFF
To turn the SSD1306 display on or off.
Expand Down Expand Up @@ -59,27 +59,27 @@ or at runtime with

### Setting the log output

The display of serial log messages to the display can be enabled via compiler directive `-DLOG_TO_LCD=true` or via MQTT commands.
The display of serial log messages to the display can be enabled via compiler directive `-DLOG_TO_OLED=true` or via MQTT commands.

For example if you want to set the serial log to LCD
For example if you want to set the serial log to OLED

`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoSSD1306/config -m '{"log-lcd":true}'`
`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoSSD1306/config -m '{"log-oled":true}'`

you can also revert it back to the serial monitor:
you can also revert it back with

`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoSSD1306/config -m '{"log-lcd":false}'`
`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_LCD=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)

The display of messages from various modules is also supported. Currently supported modules include `ZgatewayRTL_433`, `ZgatewayBT` and `ZsensorBME280`.

This can be enabled with the compiler directive `-DJSON_TO_LCD=true`.
This can be enabled with the compiler directive `-DJSON_TO_OLED=true`.

You can also change it by MQTT. For example if you want to display module json messages:

`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoSSD1306/config -m '{"json-lcd":true}'`
`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoSSD1306/config -m '{"json-oled":true}'`

And to disable the display of module json messages:

Expand Down
24 changes: 12 additions & 12 deletions environments.ini
Original file line number Diff line number Diff line change
Expand Up @@ -740,9 +740,9 @@ build_flags =
'-DZradioSX127x="SX127x"'
; *** ssd1306 Display Options ***
'-DZdisplaySSD1306="HELTEC_SSD1306"'
; '-DLOG_TO_LCD=false' ; Enable log to LCD
; '-DJSON_TO_LCD=true'
; '-DLOG_LEVEL_LCD=LOG_LEVEL_NOTICE'
; '-DLOG_TO_OLED=false' ; Enable log to OLED
; '-DJSON_TO_OLED=true'
; '-DLOG_LEVEL_OLED=LOG_LEVEL_NOTICE'
; '-DDISPLAY_IDLE_LOGO=false'
; '-DDISPLAY_BRIGHTNESS=80'
; '-DDISPLAY_METRIC=false'
Expand Down Expand Up @@ -793,9 +793,9 @@ build_flags =
'-DZradioSX127x="SX127x"'
; *** ssd1306 Display Options ***
'-DZdisplaySSD1306="LilyGo_SSD1306"'
; '-DLOG_TO_LCD=true' ; Enable log to LCD
; '-DJSON_TO_LCD=true'
; '-DLOG_LEVEL_LCD=LOG_LEVEL_NOTICE'
; '-DLOG_TO_OLED=true' ; Enable log to OLED
; '-DJSON_TO_OLED=true'
; '-DLOG_LEVEL_OLED=LOG_LEVEL_NOTICE'
; '-DDISPLAY_IDLE_LOGO=false'
; '-DDISPLAY_BRIGHTNESS=80'
; '-DDISPLAY_METRIC=false'
Expand Down Expand Up @@ -960,9 +960,9 @@ build_flags =
'-DLED_SEND_RECEIVE_ON=1'
; *** ssd1306 Display Options ***
'-DZdisplaySSD1306="HELTEC_SSD1306"'
; '-DLOG_TO_LCD=true' ; Enable log to LCD
; '-DJSON_TO_LCD=true'
; '-DLOG_LEVEL_LCD=LOG_LEVEL_NOTICE'
; '-DLOG_TO_OLED=true' ; Enable log to OLED
; '-DJSON_TO_OLED=true'
; '-DLOG_LEVEL_OLED=LOG_LEVEL_NOTICE'
; '-DDISPLAY_IDLE_LOGO=false'
; '-DDISPLAY_BRIGHTNESS=80'
; '-DDISPLAY_METRIC=false'
Expand All @@ -988,9 +988,9 @@ build_flags =
'-DLED_SEND_RECEIVE_ON=1'
; *** ssd1306 Display Options ***
'-DZdisplaySSD1306="HELTEC_SSD1306"'
; '-DLOG_TO_LCD=true' ; Enable log to LCD
; '-DJSON_TO_LCD=true'
; '-DLOG_LEVEL_LCD=LOG_LEVEL_NOTICE'
; '-DLOG_TO_OLED=true' ; Enable log to OLED
; '-DJSON_TO_OLED=true'
; '-DLOG_LEVEL_OLED=LOG_LEVEL_NOTICE'
; '-DDISPLAY_IDLE_LOGO=false'
; '-DDISPLAY_BRIGHTNESS=80'
; '-DDISPLAY_METRIC=false'
Expand Down
48 changes: 24 additions & 24 deletions main/ZdisplaySSD1306.ino
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@

SemaphoreHandle_t semaphoreOLEDOperation;
QueueHandle_t displayQueue;
boolean logToLCDDisplay = LOG_TO_LCD;
boolean jsonDisplay = JSON_TO_LCD;
boolean logToOLEDDisplay = LOG_TO_OLED;
boolean jsonDisplay = JSON_TO_OLED;
boolean displayMetric = DISPLAY_METRIC;
boolean displayFlip = DISPLAY_FLIP;
boolean displayState = DISPLAY_STATE;
Expand All @@ -52,9 +52,9 @@ uint8_t displayBrightness = round(DISPLAY_BRIGHTNESS * 2.55);
/*
Toogle log display
*/
void logToLCD(bool display) {
logToLCDDisplay = display;
display ? Log.begin(LOG_LEVEL_LCD, &Oled) : Log.begin(LOG_LEVEL, &Serial); // Log on LCD following LOG_LEVEL_LCD
void logToOLED(bool display) {
logToOLEDDisplay = display;
display ? Log.begin(LOG_LEVEL_OLED, &Oled) : Log.begin(LOG_LEVEL, &Serial); // Log on OLED following LOG_LEVEL_OLED
}

/*
Expand All @@ -63,8 +63,8 @@ module setup, for use in Arduino setup
void setupSSD1306() {
Log.trace(F("Setup SSD1306 Display" CR));
Log.trace(F("ZdisplaySSD1306 command topic: %s" CR), subjectMQTTtoSSD1306set);
Log.trace(F("ZdisplaySSD1306 log-lcd: %T" CR), logToLCDDisplay);
Log.trace(F("ZdisplaySSD1306 json-lcd: %T" CR), jsonDisplay);
Log.trace(F("ZdisplaySSD1306 log-oled: %T" CR), logToOLEDDisplay);
Log.trace(F("ZdisplaySSD1306 json-oled: %T" CR), jsonDisplay);
Log.trace(F("ZdisplaySSD1306 DISPLAY_PAGE_INTERVAL: %d" CR), DISPLAY_PAGE_INTERVAL);
Log.trace(F("ZdisplaySSD1306 DISPLAY_IDLE_LOGO: %T" CR), DISPLAY_IDLE_LOGO);
Log.trace(F("ZdisplaySSD1306 DISPLAY_METRIC: %T" CR), displayMetric);
Expand All @@ -73,8 +73,8 @@ void setupSSD1306() {
Oled.begin();
Log.notice(F("Setup SSD1306 Display end" CR));

# if LOG_TO_LCD
Log.begin(LOG_LEVEL_LCD, &Oled); // Log on LCD following LOG_LEVEL_LCD
# if LOG_TO_OLED
Log.begin(LOG_LEVEL_OLED, &Oled); // Log on OLED following LOG_LEVEL_OLED
jsonDisplay = false;
# else
jsonDisplay = true;
Expand Down Expand Up @@ -117,43 +117,43 @@ void loopSSD1306() {

/*
Handler for mqtt commands sent to the module
- log-lcd: boolean
- log-oled: boolean
Enable / Disable display of log messages on display
*/
void MQTTtoSSD1306(char* topicOri, JsonObject& SSD1306data) { // json object decoding
bool success = false;
if (cmpToMainTopic(topicOri, subjectMQTTtoSSD1306set)) {
Log.trace(F("MQTTtoSSD1306 json set" CR));
// Log display set between SSD1306 lcd (true) and serial monitor (false)
// Log display set between SSD1306 OLED (true) and serial monitor (false)
if (SSD1306data.containsKey("onstate")) {
if (displayState != SSD1306data["onstate"]) {
displayState = SSD1306data["onstate"];
Oled.begin();
}
displayState = SSD1306data["onstate"];
Log.notice(F("Set display state: %T" CR), logToLCDDisplay);
Log.notice(F("Set display state: %T" CR), logToOLEDDisplay);
success = true;
} else if (SSD1306data.containsKey("brightness")) {
displayBrightness = SSD1306data["brightness"];
displayBrightness = round(displayBrightness * 2.55);
Oled.display->setBrightness(displayBrightness);
Log.notice(F("Set brightness: %d" CR), displayBrightness);
success = true;
} else if (SSD1306data.containsKey("log-lcd")) {
logToLCDDisplay = SSD1306data["log-lcd"];
Log.notice(F("Set lcd log: %T" CR), logToLCDDisplay);
logToLCD(logToLCDDisplay);
if (logToLCDDisplay) {
} else if (SSD1306data.containsKey("log-oled")) {
logToOLEDDisplay = SSD1306data["log-oled"];
Log.notice(F("Set OLED log: %T" CR), logToOLEDDisplay);
logToOLED(logToOLEDDisplay);
if (logToOLEDDisplay) {
jsonDisplay = false;
}
success = true;
} else if (SSD1306data.containsKey("json-lcd")) {
jsonDisplay = SSD1306data["json-lcd"];
} else if (SSD1306data.containsKey("json-oled")) {
jsonDisplay = SSD1306data["json-oled"];
if (jsonDisplay) {
logToLCDDisplay = false;
logToLCD(logToLCDDisplay);
logToOLEDDisplay = false;
logToOLED(logToOLEDDisplay);
}
Log.notice(F("Set json-lcd: %T" CR), jsonDisplay);
Log.notice(F("Set json-oled: %T" CR), jsonDisplay);
success = true;
} else if (SSD1306data.containsKey("display-metric")) {
displayMetric = SSD1306data["display-metric"];
Expand Down Expand Up @@ -920,8 +920,8 @@ void stateSSD1306Display() {
DISPLAYdata["display-metric"] = (bool)displayMetric;
DISPLAYdata["display-flip"] = (bool)displayFlip;
DISPLAYdata["idlelogo"] = (bool)idlelogo;
DISPLAYdata["log-lcd"] = (bool)logToLCDDisplay;
DISPLAYdata["json-lcd"] = (bool)jsonDisplay;
DISPLAYdata["log-oled"] = (bool)logToOLEDDisplay;
DISPLAYdata["json-oled"] = (bool)jsonDisplay;
pub(subjectSSD1306toMQTT, DISPLAYdata);
}

Expand Down
12 changes: 6 additions & 6 deletions main/config_SSD1306.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@

/*-------------------DEFINE LOG LEVEL----------------------*/

#ifndef LOG_LEVEL_LCD
# define LOG_LEVEL_LCD LOG_LEVEL_WARNING // Default to only display Warning level messages
#ifndef LOG_LEVEL_OLED
# define LOG_LEVEL_OLED LOG_LEVEL_WARNING // Default to only display Warning level messages
#endif

#ifndef LOG_TO_LCD
# define LOG_TO_LCD false // Default to not display log messages on display
#ifndef LOG_TO_OLED
# define LOG_TO_OLED false // Default to not display log messages on display
#endif

#ifndef JSON_TO_LCD
# define JSON_TO_LCD true // Default to displaying JSON messages on the display
#ifndef JSON_TO_OLED
# define JSON_TO_OLED true // Default to displaying JSON messages on the display
#endif

#ifndef DISPLAY_PAGE_INTERVAL
Expand Down

0 comments on commit cff87dd

Please sign in to comment.