Skip to content

Commit 81778b6

Browse files
New Display Structure to enable Display Rotation, different Styles etc.
1 parent f639b45 commit 81778b6

14 files changed

+610
-43
lines changed

firmware-esp8266.ino

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
SOURCE: https://github.com/sensate-io/firmware-esp8266.git
1212
1313
@section HISTORY
14+
v40 - New Display Structure to enable Display Rotation, different Styles etc.
1415
v39 - ReAdded Support for VEML6075 and SI1145 UVI Sensors, added auto-reinit if sensor fails
1516
v38 - Changed automatic Update to only if required Update, removed VEML6075 and SI1145 UV Sensors
1617
v36 - Greatly improved reliability of connectivity
@@ -29,10 +30,12 @@
2930
#include "src/communication/WiFiManager.h"
3031
#include "src/controller/OTA.h"
3132
#include "src/communication/RestServer.h"
33+
#include "src/output/VisualisationHelper.h"
3234

35+
VisualisationHelper* vHelper;
3336
Display* display = NULL;
3437

35-
int currentVersion = 39;
38+
int currentVersion = 40;
3639
boolean printMemory = false;
3740

3841
String board = "Generic";
@@ -96,6 +99,8 @@ void setup()
9699

97100
restoreBridgeConfig();
98101

102+
vHelper = new VisualisationHelper();
103+
99104
doPowerSavingInit(true);
100105

101106
Serial.println("Display Type:"+String(displayType));
@@ -173,6 +178,7 @@ void runTick() {
173178
switch(state)
174179
{
175180
case Operating:
181+
loopDisplay(currentMillis);
176182
loopSensor(currentMillis);
177183
break;
178184
}

src/controller/Bridge.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
SOURCE: https://github.com/sensate-io/firmware-esp8266.git
1212
1313
@section HISTORY
14+
v40 - New Display Structure to enable Display Rotation, different Styles etc.
1415
v36 - Greatly improved reliability of connectivity
1516
v35 - Added Support for VEML6075 and SI1145 UVI Sensors
1617
v34 - Added Generic Analog Sensor Support
@@ -76,6 +77,8 @@ int configRetry = 0;
7677
int postSensorDataRetry = 0;
7778
int sensorCycle = 1;
7879

80+
extern VisualisationHelper* vHelper;
81+
7982
std::unique_ptr<BearSSL::WiFiClientSecure>sslClient(new BearSSL::WiFiClientSecure);
8083

8184
bool initSSL()
@@ -401,6 +404,7 @@ bool getBridgeConfig() {
401404
else
402405
{
403406
portNumber++;
407+
configureDisplayValueData(portRow, configEntry);
404408
}
405409

406410
if (configEntry.containsKey("et"))
@@ -417,6 +421,7 @@ bool getBridgeConfig() {
417421
display->clear(false);
418422
display->drawProductLogo();
419423
display->drawString(0, 10, "Waiting for sensors...");
424+
initVisualisationHelper(bridgeConfig);
420425
}
421426

422427
}
@@ -536,6 +541,29 @@ void configureBridge(JsonObject& bridgeConfig) {
536541
doPowerSavingInit(false);
537542
}
538543

544+
void initVisualisationHelper(JsonObject& bridgeConfig) {
545+
546+
int simultanValueCount;
547+
548+
if(displayHeight==64)
549+
simultanValueCount = 4;
550+
else if(displayHeight==32)
551+
simultanValueCount = 2;
552+
553+
unsigned long displayCycleInterval = bridgeConfig["di"];
554+
555+
if(displayCycleInterval==0)
556+
{
557+
Serial.println("Display cycle disabled (Interval = 0)");
558+
}
559+
else
560+
{
561+
vHelper->enableDisplayCycle(millis(), simultanValueCount, displayCycleInterval);
562+
}
563+
564+
}
565+
566+
539567
void storeDisplayAndPowerConfig(boolean withPowerSettings) {
540568

541569
EEPROM.begin(314);
@@ -644,6 +672,11 @@ void tryInitMQTT() {
644672

645673
}
646674

675+
void configureDisplayValueData(int portNumber, JsonObject& portConfig) {
676+
677+
vHelper->getDisplayDataModel()->setData(portNumber, new DisplayValueData(portNumber, portConfig["n"], portConfig["sn"], "WAIT"));
678+
679+
}
647680

648681
void configureExpansionPort(int portNumber, JsonObject& portConfig) {
649682
Serial.println("Configure Expansion Port: ");
@@ -873,6 +906,13 @@ void addSensor(Sensor *sensor)
873906
}
874907
}
875908

909+
void loopDisplay(unsigned long currentTimeMs) {
910+
if(display!=NULL)
911+
{
912+
display->drawData(currentTimeMs);
913+
}
914+
}
915+
876916
void loopSensor(int currentTimeMs) {
877917

878918
Data *data[maxSensorCount];
@@ -986,6 +1026,7 @@ void trySleep(long microseconds)
9861026

9871027
if(powerMode==2 && microseconds>0)
9881028
{
1029+
loopDisplay(millis());
9891030
doPowerSaving();
9901031
Serial.println("Going to deep sleep for "+String(microseconds));
9911032
ESP.deepSleep(microseconds);

src/controller/Bridge.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
SOURCE: https://github.com/sensate-io/firmware-esp8266.git
1212
1313
@section HISTORY
14+
v40 - New Display Structure to enable Display Rotation, different Styles etc.
1415
v36 - Greatly improved reliability of connectivity
1516
v35 - Added Support for VEML6075 and SI1145 UVI Sensors
1617
v33 - Added Digital Sensor Switch Support
@@ -44,6 +45,7 @@
4445
#include "../input/onewire/SensorDHT.h"
4546
#include "../input/onewire/SensorDallas.h"
4647
#include "../output/display/DisplayOLED128.h"
48+
#include "../output/VisualisationHelper.h"
4749

4850
bool initSSL();
4951
bool registerBridge();
@@ -52,10 +54,13 @@ void restart();
5254

5355
bool getBridgeConfig();
5456
void configureBridge(JsonObject&);
57+
void initVisualisationHelper(JsonObject&);
58+
void configureDisplayValueData(int, JsonObject&);
5559
void configureExpansionPort(int, JsonObject&);
5660
void configurePort(int, JsonObject&);
5761
void addSensor(Sensor *);
5862
void loopSensor(int);
63+
void loopDisplay(unsigned long);
5964
boolean postSensorData(Data* data[], int);
6065
void checkStatus();
6166
void trySleep(long);

0 commit comments

Comments
 (0)