mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-25 23:06:11 +02:00
MonochromeDisplay in Display umbenannt
This commit is contained in:
parent
18ea8b5925
commit
ce20d7c1b4
3 changed files with 296 additions and 303 deletions
87
src/app.cpp
87
src/app.cpp
|
@ -4,13 +4,14 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
|
||||||
#include "utils/sun.h"
|
#include "utils/sun.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
app::app() : ah::Scheduler() {}
|
app::app() : ah::Scheduler() {}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::setup() {
|
void app::setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
@ -24,7 +25,7 @@ void app::setup() {
|
||||||
mSettings.setup();
|
mSettings.setup();
|
||||||
mSettings.getPtr(mConfig);
|
mSettings.getPtr(mConfig);
|
||||||
DPRINT(DBG_INFO, F("Settings valid: "));
|
DPRINT(DBG_INFO, F("Settings valid: "));
|
||||||
if(mSettings.getValid())
|
if (mSettings.getValid())
|
||||||
DBGPRINTLN(F("true"));
|
DBGPRINTLN(F("true"));
|
||||||
else
|
else
|
||||||
DBGPRINTLN(F("false"));
|
DBGPRINTLN(F("false"));
|
||||||
|
@ -32,16 +33,16 @@ void app::setup() {
|
||||||
mSys.enableDebug();
|
mSys.enableDebug();
|
||||||
mSys.setup(mConfig->nrf.amplifierPower, mConfig->nrf.pinIrq, mConfig->nrf.pinCe, mConfig->nrf.pinCs);
|
mSys.setup(mConfig->nrf.amplifierPower, mConfig->nrf.pinIrq, mConfig->nrf.pinCe, mConfig->nrf.pinCs);
|
||||||
|
|
||||||
#if defined(AP_ONLY)
|
#if defined(AP_ONLY)
|
||||||
mInnerLoopCb = std::bind(&app::loopStandard, this);
|
mInnerLoopCb = std::bind(&app::loopStandard, this);
|
||||||
#else
|
#else
|
||||||
mInnerLoopCb = std::bind(&app::loopWifi, this);
|
mInnerLoopCb = std::bind(&app::loopWifi, this);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mWifi.setup(mConfig, &mTimestamp, std::bind(&app::onWifi, this, std::placeholders::_1));
|
mWifi.setup(mConfig, &mTimestamp, std::bind(&app::onWifi, this, std::placeholders::_1));
|
||||||
#if !defined(AP_ONLY)
|
#if !defined(AP_ONLY)
|
||||||
everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL");
|
everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mSys.addInverters(&mConfig->inst);
|
mSys.addInverters(&mConfig->inst);
|
||||||
|
|
||||||
|
@ -52,23 +53,23 @@ void app::setup() {
|
||||||
mMiPayload.setup(this, &mSys, &mStat, mConfig->nrf.maxRetransPerPyld, &mTimestamp);
|
mMiPayload.setup(this, &mSys, &mStat, mConfig->nrf.maxRetransPerPyld, &mTimestamp);
|
||||||
mMiPayload.enableSerialDebug(mConfig->serial.debug);
|
mMiPayload.enableSerialDebug(mConfig->serial.debug);
|
||||||
|
|
||||||
//DBGPRINTLN("--- after payload");
|
// DBGPRINTLN("--- after payload");
|
||||||
//DBGPRINTLN(String(ESP.getFreeHeap()));
|
// DBGPRINTLN(String(ESP.getFreeHeap()));
|
||||||
//DBGPRINTLN(String(ESP.getHeapFragmentation()));
|
// DBGPRINTLN(String(ESP.getHeapFragmentation()));
|
||||||
//DBGPRINTLN(String(ESP.getMaxFreeBlockSize()));
|
// DBGPRINTLN(String(ESP.getMaxFreeBlockSize()));
|
||||||
|
|
||||||
if(!mSys.Radio.isChipConnected())
|
if (!mSys.Radio.isChipConnected())
|
||||||
DPRINTLN(DBG_WARN, F("WARNING! your NRF24 module can't be reached, check the wiring"));
|
DPRINTLN(DBG_WARN, F("WARNING! your NRF24 module can't be reached, check the wiring"));
|
||||||
|
|
||||||
// when WiFi is in client mode, then enable mqtt broker
|
// when WiFi is in client mode, then enable mqtt broker
|
||||||
#if !defined(AP_ONLY)
|
#if !defined(AP_ONLY)
|
||||||
mMqttEnabled = (mConfig->mqtt.broker[0] > 0);
|
mMqttEnabled = (mConfig->mqtt.broker[0] > 0);
|
||||||
if (mMqttEnabled) {
|
if (mMqttEnabled) {
|
||||||
mMqtt.setup(&mConfig->mqtt, mConfig->sys.deviceName, mVersion, &mSys, &mTimestamp);
|
mMqtt.setup(&mConfig->mqtt, mConfig->sys.deviceName, mVersion, &mSys, &mTimestamp);
|
||||||
mMqtt.setSubscriptionCb(std::bind(&app::mqttSubRxCb, this, std::placeholders::_1));
|
mMqtt.setSubscriptionCb(std::bind(&app::mqttSubRxCb, this, std::placeholders::_1));
|
||||||
mPayload.addAlarmListener(std::bind(&PubMqttType::alarmEventListener, &mMqtt, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
mPayload.addAlarmListener(std::bind(&PubMqttType::alarmEventListener, &mMqtt, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
setupLed();
|
setupLed();
|
||||||
|
|
||||||
mWeb.setup(this, &mSys, mConfig);
|
mWeb.setup(this, &mSys, mConfig);
|
||||||
|
@ -77,18 +78,17 @@ void app::setup() {
|
||||||
mApi.setup(this, &mSys, mWeb.getWebSrvPtr(), mConfig);
|
mApi.setup(this, &mSys, mWeb.getWebSrvPtr(), mConfig);
|
||||||
|
|
||||||
// Plugins
|
// Plugins
|
||||||
if(mConfig->plugin.display.type != 0)
|
if (mConfig->plugin.display.type != 0)
|
||||||
mMonoDisplay.setup(&mConfig->plugin.display, &mSys, &mTimestamp, 0xff, mVersion);
|
mDisplay.setup(&mConfig->plugin.display, &mSys, &mTimestamp, 0xff, mVersion);
|
||||||
|
|
||||||
mPubSerial.setup(mConfig, &mSys, &mTimestamp);
|
mPubSerial.setup(mConfig, &mSys, &mTimestamp);
|
||||||
|
|
||||||
regularTickers();
|
regularTickers();
|
||||||
|
|
||||||
|
// DBGPRINTLN("--- end setup");
|
||||||
//DBGPRINTLN("--- end setup");
|
// DBGPRINTLN(String(ESP.getFreeHeap()));
|
||||||
//DBGPRINTLN(String(ESP.getFreeHeap()));
|
// DBGPRINTLN(String(ESP.getHeapFragmentation()));
|
||||||
//DBGPRINTLN(String(ESP.getHeapFragmentation()));
|
// DBGPRINTLN(String(ESP.getMaxFreeBlockSize()));
|
||||||
//DBGPRINTLN(String(ESP.getMaxFreeBlockSize()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -115,8 +115,8 @@ void app::loopStandard(void) {
|
||||||
mStat.frmCnt++;
|
mStat.frmCnt++;
|
||||||
|
|
||||||
Inverter<> *iv = mSys.findInverter(&p->packet[1]);
|
Inverter<> *iv = mSys.findInverter(&p->packet[1]);
|
||||||
if(NULL != iv) {
|
if (NULL != iv) {
|
||||||
if(IV_HM == iv->ivGen)
|
if (IV_HM == iv->ivGen)
|
||||||
mPayload.add(iv, p);
|
mPayload.add(iv, p);
|
||||||
else
|
else
|
||||||
mMiPayload.add(iv, p);
|
mMiPayload.add(iv, p);
|
||||||
|
@ -130,7 +130,7 @@ void app::loopStandard(void) {
|
||||||
mPayload.loop();
|
mPayload.loop();
|
||||||
mMiPayload.loop();
|
mMiPayload.loop();
|
||||||
|
|
||||||
if(mMqttEnabled)
|
if (mMqttEnabled)
|
||||||
mMqtt.loop();
|
mMqtt.loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,12 +151,11 @@ void app::onWifi(bool gotIp) {
|
||||||
mMqttReconnect = true;
|
mMqttReconnect = true;
|
||||||
mSunrise = 0; // needs to be set to 0, to reinstall sunrise and ivComm tickers!
|
mSunrise = 0; // needs to be set to 0, to reinstall sunrise and ivComm tickers!
|
||||||
once(std::bind(&app::tickNtpUpdate, this), 2, "ntp2");
|
once(std::bind(&app::tickNtpUpdate, this), 2, "ntp2");
|
||||||
if(WIFI_AP == WiFi.getMode()) {
|
if (WIFI_AP == WiFi.getMode()) {
|
||||||
mMqttEnabled = false;
|
mMqttEnabled = false;
|
||||||
everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL");
|
everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL");
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
mInnerLoopCb = std::bind(&app::loopWifi, this);
|
mInnerLoopCb = std::bind(&app::loopWifi, this);
|
||||||
everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL");
|
everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL");
|
||||||
}
|
}
|
||||||
|
@ -167,8 +166,8 @@ void app::regularTickers(void) {
|
||||||
DPRINTLN(DBG_DEBUG, F("regularTickers"));
|
DPRINTLN(DBG_DEBUG, F("regularTickers"));
|
||||||
everySec(std::bind(&WebType::tickSecond, &mWeb), "webSc");
|
everySec(std::bind(&WebType::tickSecond, &mWeb), "webSc");
|
||||||
// Plugins
|
// Plugins
|
||||||
if(mConfig->plugin.display.type != 0)
|
if (mConfig->plugin.display.type != 0)
|
||||||
everySec(std::bind(&MonoDisplayType::tickerSecond, &mMonoDisplay), "disp");
|
everySec(std::bind(&DisplayType::tickerSecond, &mDisplay), "disp");
|
||||||
every(std::bind(&PubSerialType::tick, &mPubSerial), mConfig->serial.interval, "uart");
|
every(std::bind(&PubSerialType::tick, &mPubSerial), mConfig->serial.interval, "uart");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,10 +183,10 @@ void app::tickNtpUpdate(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// only install schedulers once even if NTP wasn't successful in first loop
|
// only install schedulers once even if NTP wasn't successful in first loop
|
||||||
if(mMqttReconnect) { // @TODO: mMqttReconnect is variable which scope has changed
|
if (mMqttReconnect) { // @TODO: mMqttReconnect is variable which scope has changed
|
||||||
if(mConfig->inst.rstValsNotAvail)
|
if (mConfig->inst.rstValsNotAvail)
|
||||||
everyMin(std::bind(&app::tickMinute, this), "tMin");
|
everyMin(std::bind(&app::tickMinute, this), "tMin");
|
||||||
if(mConfig->inst.rstYieldMidNight) {
|
if (mConfig->inst.rstYieldMidNight) {
|
||||||
uint32_t localTime = gTimezone.toLocal(mTimestamp);
|
uint32_t localTime = gTimezone.toLocal(mTimestamp);
|
||||||
uint32_t midTrig = gTimezone.toUTC(localTime - (localTime % 86400) + 86400); // next midnight local time
|
uint32_t midTrig = gTimezone.toUTC(localTime - (localTime % 86400) + 86400); // next midnight local time
|
||||||
onceAt(std::bind(&app::tickMidnight, this), midTrig, "midNi");
|
onceAt(std::bind(&app::tickMidnight, this), midTrig, "midNi");
|
||||||
|
@ -196,14 +195,14 @@ void app::tickNtpUpdate(void) {
|
||||||
|
|
||||||
nxtTrig = isOK ? 43200 : 60; // depending on NTP update success check again in 12 h or in 1 min
|
nxtTrig = isOK ? 43200 : 60; // depending on NTP update success check again in 12 h or in 1 min
|
||||||
|
|
||||||
if((mSunrise == 0) && (mConfig->sun.lat) && (mConfig->sun.lon)) {
|
if ((mSunrise == 0) && (mConfig->sun.lat) && (mConfig->sun.lon)) {
|
||||||
mCalculatedTimezoneOffset = (int8_t)((mConfig->sun.lon >= 0 ? mConfig->sun.lon + 7.5 : mConfig->sun.lon - 7.5) / 15) * 3600;
|
mCalculatedTimezoneOffset = (int8_t)((mConfig->sun.lon >= 0 ? mConfig->sun.lon + 7.5 : mConfig->sun.lon - 7.5) / 15) * 3600;
|
||||||
tickCalcSunrise();
|
tickCalcSunrise();
|
||||||
}
|
}
|
||||||
|
|
||||||
// immediately start communicating
|
// immediately start communicating
|
||||||
// @TODO: leads to reboot loops? not sure #674
|
// @TODO: leads to reboot loops? not sure #674
|
||||||
if(isOK && mSendFirst) {
|
if (isOK && mSendFirst) {
|
||||||
mSendFirst = false;
|
mSendFirst = false;
|
||||||
once(std::bind(&app::tickSend, this), 2, "senOn");
|
once(std::bind(&app::tickSend, this), 2, "senOn");
|
||||||
}
|
}
|
||||||
|
@ -259,7 +258,7 @@ void app::tickSun(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::tickComm(void) {
|
void app::tickComm(void) {
|
||||||
if((!mIVCommunicationOn) && (mConfig->inst.rstValsCommStop))
|
if ((!mIVCommunicationOn) && (mConfig->inst.rstValsCommStop))
|
||||||
once(std::bind(&app::tickZeroValues, this), mConfig->nrf.sendInterval, "tZero");
|
once(std::bind(&app::tickZeroValues, this), mConfig->nrf.sendInterval, "tZero");
|
||||||
|
|
||||||
if (mMqttEnabled) {
|
if (mMqttEnabled) {
|
||||||
|
@ -292,7 +291,7 @@ void app::tickMinute(void) {
|
||||||
if (NULL == iv)
|
if (NULL == iv)
|
||||||
continue; // skip to next inverter
|
continue; // skip to next inverter
|
||||||
|
|
||||||
if(!iv->isAvailable(mTimestamp) && !iv->isProducing(mTimestamp) && iv->config->enabled)
|
if (!iv->isAvailable(mTimestamp) && !iv->isProducing(mTimestamp) && iv->config->enabled)
|
||||||
mPayload.zeroInverterValues(iv);
|
mPayload.zeroInverterValues(iv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -321,7 +320,7 @@ void app::tickMidnight(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::tickSend(void) {
|
void app::tickSend(void) {
|
||||||
if(!mSys.Radio.isChipConnected()) {
|
if (!mSys.Radio.isChipConnected()) {
|
||||||
DPRINTLN(DBG_WARN, F("NRF24 not connected!"));
|
DPRINTLN(DBG_WARN, F("NRF24 not connected!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -341,8 +340,8 @@ void app::tickSend(void) {
|
||||||
} while ((NULL == iv) && ((maxLoop--) > 0));
|
} while ((NULL == iv) && ((maxLoop--) > 0));
|
||||||
|
|
||||||
if (NULL != iv) {
|
if (NULL != iv) {
|
||||||
if(iv->config->enabled) {
|
if (iv->config->enabled) {
|
||||||
if(iv->ivGen == IV_HM)
|
if (iv->ivGen == IV_HM)
|
||||||
mPayload.ivSend(iv);
|
mPayload.ivSend(iv);
|
||||||
else
|
else
|
||||||
mMiPayload.ivSend(iv);
|
mMiPayload.ivSend(iv);
|
||||||
|
@ -391,11 +390,11 @@ void app::setupLed(void) {
|
||||||
* PIN ---- |<----- 3.3V
|
* PIN ---- |<----- 3.3V
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
if(mConfig->led.led0 != 0xff) {
|
if (mConfig->led.led0 != 0xff) {
|
||||||
pinMode(mConfig->led.led0, OUTPUT);
|
pinMode(mConfig->led.led0, OUTPUT);
|
||||||
digitalWrite(mConfig->led.led0, HIGH); // LED off
|
digitalWrite(mConfig->led.led0, HIGH); // LED off
|
||||||
}
|
}
|
||||||
if(mConfig->led.led1 != 0xff) {
|
if (mConfig->led.led1 != 0xff) {
|
||||||
pinMode(mConfig->led.led1, OUTPUT);
|
pinMode(mConfig->led.led1, OUTPUT);
|
||||||
digitalWrite(mConfig->led.led1, HIGH); // LED off
|
digitalWrite(mConfig->led.led1, HIGH); // LED off
|
||||||
}
|
}
|
||||||
|
@ -403,10 +402,10 @@ void app::setupLed(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::updateLed(void) {
|
void app::updateLed(void) {
|
||||||
if(mConfig->led.led0 != 0xff) {
|
if (mConfig->led.led0 != 0xff) {
|
||||||
Inverter<> *iv = mSys.getInverterByPos(0);
|
Inverter<> *iv = mSys.getInverterByPos(0);
|
||||||
if (NULL != iv) {
|
if (NULL != iv) {
|
||||||
if(iv->isProducing(mTimestamp))
|
if (iv->isProducing(mTimestamp))
|
||||||
digitalWrite(mConfig->led.led0, LOW); // LED on
|
digitalWrite(mConfig->led.led0, LOW); // LED on
|
||||||
else
|
else
|
||||||
digitalWrite(mConfig->led.led0, HIGH); // LED off
|
digitalWrite(mConfig->led.led0, HIGH); // LED off
|
||||||
|
|
42
src/app.h
42
src/app.h
|
@ -6,30 +6,25 @@
|
||||||
#ifndef __APP_H__
|
#ifndef __APP_H__
|
||||||
#define __APP_H__
|
#define __APP_H__
|
||||||
|
|
||||||
|
|
||||||
#include "utils/dbg.h"
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <ArduinoJson.h>
|
||||||
#include <RF24.h>
|
#include <RF24.h>
|
||||||
#include <RF24_config.h>
|
#include <RF24_config.h>
|
||||||
#include <ArduinoJson.h>
|
|
||||||
|
|
||||||
#include "appInterface.h"
|
#include "appInterface.h"
|
||||||
|
|
||||||
#include "config/settings.h"
|
#include "config/settings.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "utils/crc.h"
|
|
||||||
#include "utils/scheduler.h"
|
|
||||||
|
|
||||||
#include "hm/hmSystem.h"
|
|
||||||
#include "hm/hmPayload.h"
|
#include "hm/hmPayload.h"
|
||||||
|
#include "hm/hmSystem.h"
|
||||||
#include "hm/miPayload.h"
|
#include "hm/miPayload.h"
|
||||||
#include "wifi/ahoywifi.h"
|
|
||||||
#include "web/web.h"
|
|
||||||
#include "web/RestApi.h"
|
|
||||||
|
|
||||||
#include "publisher/pubMqtt.h"
|
#include "publisher/pubMqtt.h"
|
||||||
#include "publisher/pubSerial.h"
|
#include "publisher/pubSerial.h"
|
||||||
|
#include "utils/crc.h"
|
||||||
|
#include "utils/dbg.h"
|
||||||
|
#include "utils/scheduler.h"
|
||||||
|
#include "web/RestApi.h"
|
||||||
|
#include "web/web.h"
|
||||||
|
#include "wifi/ahoywifi.h"
|
||||||
|
|
||||||
// convert degrees and radians for sun calculation
|
// convert degrees and radians for sun calculation
|
||||||
#define SIN(x) (sin(radians(x)))
|
#define SIN(x) (sin(radians(x)))
|
||||||
|
@ -46,9 +41,8 @@ typedef PubMqtt<HmSystemType> PubMqttType;
|
||||||
typedef PubSerial<HmSystemType> PubSerialType;
|
typedef PubSerial<HmSystemType> PubSerialType;
|
||||||
|
|
||||||
// PLUGINS
|
// PLUGINS
|
||||||
#include "plugins/Display/MonochromeDisplay.h"
|
#include "plugins/Display/Display.h"
|
||||||
typedef MonochromeDisplay<HmSystemType> MonoDisplayType;
|
typedef Display<HmSystemType> DisplayType;
|
||||||
|
|
||||||
|
|
||||||
class app : public IApp, public ah::Scheduler {
|
class app : public IApp, public ah::Scheduler {
|
||||||
public:
|
public:
|
||||||
|
@ -136,7 +130,7 @@ class app : public IApp, public ah::Scheduler {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ivSendHighPrio(Inverter<> *iv) {
|
void ivSendHighPrio(Inverter<> *iv) {
|
||||||
if(mIVCommunicationOn) // only send commands if communcation is enabled
|
if (mIVCommunicationOn) // only send commands if communcation is enabled
|
||||||
mPayload.ivSendHighPrio(iv);
|
mPayload.ivSendHighPrio(iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +156,7 @@ class app : public IApp, public ah::Scheduler {
|
||||||
|
|
||||||
String getTimeStr(uint32_t offset = 0) {
|
String getTimeStr(uint32_t offset = 0) {
|
||||||
char str[10];
|
char str[10];
|
||||||
if(0 == mTimestamp)
|
if (0 == mTimestamp)
|
||||||
sprintf(str, "n/a");
|
sprintf(str, "n/a");
|
||||||
else
|
else
|
||||||
sprintf(str, "%02d:%02d:%02d ", hour(mTimestamp + offset), minute(mTimestamp + offset), second(mTimestamp + offset));
|
sprintf(str, "%02d:%02d:%02d ", hour(mTimestamp + offset), minute(mTimestamp + offset), second(mTimestamp + offset));
|
||||||
|
@ -184,7 +178,7 @@ class app : public IApp, public ah::Scheduler {
|
||||||
void setTimestamp(uint32_t newTime) {
|
void setTimestamp(uint32_t newTime) {
|
||||||
DPRINT(DBG_DEBUG, F("setTimestamp: "));
|
DPRINT(DBG_DEBUG, F("setTimestamp: "));
|
||||||
DBGPRINTLN(String(newTime));
|
DBGPRINTLN(String(newTime));
|
||||||
if(0 == newTime)
|
if (0 == newTime)
|
||||||
mWifi.getNtpTime();
|
mWifi.getNtpTime();
|
||||||
else
|
else
|
||||||
Scheduler::setTimestamp(newTime);
|
Scheduler::setTimestamp(newTime);
|
||||||
|
@ -198,12 +192,12 @@ class app : public IApp, public ah::Scheduler {
|
||||||
void resetSystem(void);
|
void resetSystem(void);
|
||||||
|
|
||||||
void payloadEventListener(uint8_t cmd) {
|
void payloadEventListener(uint8_t cmd) {
|
||||||
#if !defined(AP_ONLY)
|
#if !defined(AP_ONLY)
|
||||||
if (mMqttEnabled)
|
if (mMqttEnabled)
|
||||||
mMqtt.payloadEventListener(cmd);
|
mMqtt.payloadEventListener(cmd);
|
||||||
#endif
|
#endif
|
||||||
if(mConfig->plugin.display.type != 0)
|
if (mConfig->plugin.display.type != 0)
|
||||||
mMonoDisplay.payloadEventListener(cmd);
|
mDisplay.payloadEventListener(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mqttSubRxCb(JsonObject obj);
|
void mqttSubRxCb(JsonObject obj);
|
||||||
|
@ -274,7 +268,7 @@ class app : public IApp, public ah::Scheduler {
|
||||||
uint32_t mSunrise, mSunset;
|
uint32_t mSunrise, mSunset;
|
||||||
|
|
||||||
// plugins
|
// plugins
|
||||||
MonoDisplayType mMonoDisplay;
|
DisplayType mDisplay;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*__APP_H__*/
|
#endif /*__APP_H__*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef __MONOCHROME_DISPLAY__
|
#ifndef __DISPLAY__
|
||||||
#define __MONOCHROME_DISPLAY__
|
#define __DISPLAY__
|
||||||
|
|
||||||
#include <Timezone.h>
|
#include <Timezone.h>
|
||||||
#include <U8g2lib.h>
|
#include <U8g2lib.h>
|
||||||
|
@ -13,9 +13,9 @@
|
||||||
#define DISP_DEFAULT_TIMEOUT 60 // in seconds
|
#define DISP_DEFAULT_TIMEOUT 60 // in seconds
|
||||||
|
|
||||||
template <class HMSYSTEM>
|
template <class HMSYSTEM>
|
||||||
class MonochromeDisplay {
|
class Display {
|
||||||
public:
|
public:
|
||||||
MonochromeDisplay() {}
|
Display() {}
|
||||||
|
|
||||||
void setup(display_t *cfg, HMSYSTEM *sys, uint32_t *utcTs, uint8_t disp_reset, const char *version) {
|
void setup(display_t *cfg, HMSYSTEM *sys, uint32_t *utcTs, uint8_t disp_reset, const char *version) {
|
||||||
mCfg = cfg;
|
mCfg = cfg;
|
||||||
|
@ -26,7 +26,7 @@ class MonochromeDisplay {
|
||||||
|
|
||||||
if (mCfg->type == 0) {
|
if (mCfg->type == 0) {
|
||||||
return;
|
return;
|
||||||
} else if (1 < mCfg->type < 10) {
|
} else if (1 < mCfg->type < 11) {
|
||||||
switch (mCfg->rot) {
|
switch (mCfg->rot) {
|
||||||
case 0:
|
case 0:
|
||||||
DisplayMono.disp_rotation = U8G2_R0;
|
DisplayMono.disp_rotation = U8G2_R0;
|
||||||
|
@ -97,9 +97,9 @@ class MonochromeDisplay {
|
||||||
totalYieldTotal += iv->getChannelFieldValue(CH0, FLD_YT, rec);
|
totalYieldTotal += iv->getChannelFieldValue(CH0, FLD_YT, rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (1 < mCfg->type < 4) {
|
if (1 < mCfg->type < 11) {
|
||||||
DisplayMono.loop(totalPower, totalYieldDay, totalYieldTotal, isprod);
|
DisplayMono.loop(totalPower, totalYieldDay, totalYieldTotal, isprod);
|
||||||
} else if (mCfg->type == 4) {
|
} else if (mCfg->type > 10) {
|
||||||
DisplayEPaper.loop(totalPower, totalYieldDay, totalYieldTotal, isprod);
|
DisplayEPaper.loop(totalPower, totalYieldDay, totalYieldTotal, isprod);
|
||||||
counterEPaper++;
|
counterEPaper++;
|
||||||
}
|
}
|
||||||
|
@ -123,4 +123,4 @@ class MonochromeDisplay {
|
||||||
uint32_t _lastDisplayUpdate = 0;
|
uint32_t _lastDisplayUpdate = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*__MONOCHROME_DISPLAY__*/
|
#endif /*__DISPLAY__*/
|
Loading…
Add table
Add a link
Reference in a new issue