ssd1306 display of module messages (#1383)

* ssd1306 display of module messages

Supported Modules Include
- rtl_433
- bme280

* Switch to use convertTemp_CtoF
This commit is contained in:
Northern Man authored and GitHub committed 2023-01-11 20:31:12 -06:00
1 parent 5fcf02af5a
commit 9d6f7a0764
8 files changed
+477 -59

No files matched your search

+78 -12
View File
@@ -40,6 +40,34 @@
#include "SSD1306Wire.h"
/*-------------------DEFINE LOG LEVEL----------------------*/
#ifndef LOG_LEVEL_LCD
# define LOG_LEVEL_LCD 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
#endif
#ifndef JSON_TO_LCD
# define JSON_TO_LCD true // Default to displaying JSON messages on the display
#endif
#ifndef DISPLAY_PAGE_INTERVAL
# define DISPLAY_PAGE_INTERVAL 3 // Number of seconds between json message displays
#endif
#ifndef DISPLAY_IDLE_LOGO
# define DISPLAY_IDLE_LOGO true // Display the OMG logo when idle
#endif
#ifndef DISPLAY_METRIC
# define DISPLAY_METRIC true // Units used for display of sensor data
#endif
/*------------------- DEFAULT DISPLAY GEOMETRY ----------------------*/
#define OLED_TEXT_BUFFER 1000
#define OLED_TEXT_ROWS 5
#define OLED_WIDTH 128
@@ -55,21 +83,18 @@
# define OLED_HEIGHT 64
#endif
#define OLED_TEXT_WIDTH OLED_WIDTH / 4 // This is an approx amount
/*-------------------DEFINE MQTT TOPIC FOR CONFIG----------------------*/
#define subjectMQTTtoSSD1306set "/commands/MQTTtoSSD1306"
#define subjectSSD1306toMQTTset "/SSD1306toMQTT"
/*-------------------EXTERNAL FUNCTIONS----------------------*/
extern void setupSSD1306();
extern void loopSSD1306();
extern void MQTTtoSSD1306(char*, JsonObject&);
size_t OledPrint(String msg);
/*-------------------DEFINE LOG LEVEL----------------------*/
#ifndef LOG_LEVEL_LCD
# define LOG_LEVEL_LCD 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
#endif
/*-------------------DEFINE MQTT TOPIC FOR CONFIG----------------------*/
#define subjectMQTTtoSSD1306set "/commands/MQTTtoSSD1306"
#define subjectSSD1306toMQTTset "/SSD1306toMQTT"
// Simple construct for displaying message in lcd and oled displays
@@ -81,6 +106,28 @@ void ssd1306Print(char*, char*, char*);
void ssd1306Print(char*, char*);
void ssd1306Print(char*);
#define pubOled(...) ssd1306PubPrint(__VA_ARGS__)
void ssd1306PubPrint(const char*, JsonObject&);
// Structure for queueing OMG messages to the display
/*
Structure for queueing OMG messages to the display.
Length of each line is OLED_TEXT_WIDTH
- title
- line1
- line2
- line3
- line4
*/
struct displayQueueMessage {
char title[OLED_TEXT_WIDTH];
char line1[OLED_TEXT_WIDTH];
char line2[OLED_TEXT_WIDTH];
char line3[OLED_TEXT_WIDTH];
char line4[OLED_TEXT_WIDTH];
};
// This pattern was borrowed from HardwareSerial and modified to support the ssd1306 display
class OledSerial : public Stream {
@@ -91,6 +138,7 @@ public:
OledSerial(int);
void begin();
void drawLogo(int logoSize, int circle1X, int circle1Y, bool circle1, bool circle2, bool circle3, bool line1, bool line2, bool name);
boolean displayPage(displayQueueMessage*);
SSD1306Wire* display;
@@ -132,4 +180,22 @@ protected:
extern OledSerial Oled;
/*------------------- Unit Conversion Functions ----------------------*/
#define convert_kmph2mph(kmph) (kmph * (1.0f / 1.609344f))
#define convert_mph2kmph(mph) (mph * 1.609344f)
#define convert_mm2inch(mm) (mm * 0.039370f)
#define convert_inch2mm(inch) (inch * 25.4f)
#define convert_kpa2psi(kpa) (kpa * (1.0f / 6.89475729f))
#define convert_psi2kpa(psi) (psi * 6.89475729f)
#define convert_hpa2inhg(hpa) (hpa * (1.0f / 33.8639f))
#define convert_inhg2hpa(inhg) (inhg * 33.8639f)
#endif