|
| GfxPanel (String name, GfxDrivers::DisplayType displayType, uint16_t resX, uint16_t resY, uint8_t i2cAddress, TwoWire *pWire=&Wire, String locale="C") |
|
| GfxPanel (String name, GfxDrivers::DisplayType displayType, uint16_t resX, uint16_t resY, uint8_t csPin, uint8_t dcPin, uint8_t rstPin=-1, String locale="C") |
|
void | setSlotCaption (uint16_t slot, String caption) |
|
void | publishSlotCaption (uint16_t slot) |
|
void | setSlotText (uint16_t slot, String text) |
|
void | publishSlotText (uint16_t slot) |
|
void | setSlotTopic (uint16_t slot, String topic) |
|
void | publishSlotTopic (uint16_t slot) |
|
void | setSlotFormat (uint16_t slot, String format) |
|
void | publishSlotFormat (uint16_t slot) |
|
void | setSlotHistorySampleRateMs (uint16_t slot, uint32_t rate) |
|
void | publishSlotHistorySampleRateMs (uint16_t slot) |
|
void | begin (ustd::Scheduler *_pSched, bool _useCanvas=false) |
|
void | begin (ustd::Scheduler *_pSched, String combined_layout, ustd::array< String > _topics, ustd::array< String > _captions, bool _useCanvas=false) |
|
void | begin (ustd::Scheduler *_pSched, String combined_layout, uint16_t _slots, const char *_topics[], const char *_captions[], bool _useCanvas=false) |
|
gfx_panel mupplet for oled and tft panels to display sensor values
The mup_gfx_panel mupplet supports SSD1306 oled and ST7735 tft style displays.
Hardware: ST7735 tft display.
Hardware: SSD1306 oled display.
Messages sent by gamma_gdk101 mupplet:
messages are prefixed by omu/<hostname>
:
topic | message body | comment |
<mupplet-name>/display/slot/<slot_index> /caption | caption text | caption text for slot_index |
<mupplet-name>/display/slot/<slot_index> /topic | topic | subscription topic for slot_index |
<mupplet-name>/display/slot/<slot_index> /text | main slot text | text for slot_index |
<mupplet-name>/display/slot/<slot_index> /format | format specifier | slot format specifier for slot_index |
Messages received by gfx_panel mupplet:
Need to be prefixed by <hostname>/
:
topic | message body | comment |
<mupplet-name>/display/slot/<slot_index>/caption/set | <new-caption-text> | Causes caption text of slot 0..<slots be set to <new-caption-text>. |
<mupplet-name>/display/slot/<slot_index>/caption/get | | Returns the caption text of slot 0..<slots. |
<mupplet-name>/display/slot/<slot_index>/text/set | <new-slot-text> | String. Causes slot text of slot 0..<slots be set to <new-slot-text>. |
<mupplet-name>/display/slot/<slot_index>/text/get | | Returns the slot text of slot 0..<slots. |
<mupplet-name>/display/slot/<slot_index>/topic/set | <new-subs-topic> | String. Causes new subscription of <new-subs-topic> for slot 0..<slots. |
<mupplet-name>/display/slot/<slot_index>/topic/get | | Returns the subscription topic of slot 0..<slots. |
<mupplet-name>/display/slot/<slot_index>/format/set | <format-spec> | String. Sets <format-spec> for slot 0..<slots. |
<mupplet-name>/display/slot/<slot_index>/format/get | | Returns the format-spec of slot 0..<slots. |
Sample code
#include "ustd_platform.h"
#include "scheduler.h"
#include "net.h"
#include "mqtt.h"
#include "ota.h"
#include "jsonfile.h"
#include "mup_gfx_panelxx.h"
void appLoop();
ustd::Scheduler sched(10, 16, 32);
ustd::Net net(LED_BUILTIN);
ustd::Mqtt mqtt;
ustd::Ota ota;
ustd::GfxPanel displayTft(
"display1", ustd::GfxDrivers::DisplayType::ST7735, 128, 128, D4, D3, (uint8_t)-1,
"DE");
ustd::GfxPanel displayOled(
"display2", ustd::GfxDrivers::DisplayType::SSD1306, 128,64, 0x3c, &Wire,
"DE");
void setup() {
con.begin(&sched);
net.begin(&sched);
mqtt.begin(&sched);
ota.begin(&sched);
displayTft.begin(&sched,&mqtt);
displayOled.begin(&sched,&mqtt);
sched.add(appLoop, "main", 1000000);
}
void appLoop() {
}
void loop() {
sched.loop();
}
gfx_panel mupplet for oled and tft panels to display sensor values
Definition: mup_gfx_panel.h:463
The data area of the ESP32 or ESP8266 must contain a json file with the name of SensorDisplay Object given as first parameter to the object instantiation, "display1" or "display2" in the example above. The file display1,2.json
should contain:
{
"layout": "S|ff",
"topics": ["clock/timeinfo", "!hastates/sensor/temperature/state", "!hastates/sensor/netatmo_temperature2/state"],
"captions": ["Time", "Out C", "Studio C"],
}
layout
contains a string defining 1-n lines separated by |, marking display-slots by S
for string (message as-is), or I
(int),P
(val * 100 as %),F
(one decimal float),D
(two decimals),T
(three decimals) for numbers, G
for graphical plot. Uppercase letters generate a 64x32 slot, lowercase letters generate a 32x32 slot. topics
gives a list of MQTT topics that are going to be displayed. A layout S|ff|G
has four display slots (line 1: large string, line 2: two small numbers), line 3: large plot and requires 4 topics and 4 captions. A topic starting with '!' creates an external MQTT subscription (which allows displaying values from external devices), while topics without starting '!' subscribe to device-local messages only via muwerk's scheduler. A special topic clock/timeinfo
is provided by this mupplet and displays day of week and time. captions
are the small-print titles for each display slot. Default is bold font. '_' switches between bold and normal font.