Browse Source

MonochromeDisplay in Display umbenannt

pull/735/head
dAjaY85 2 years ago
parent
commit
ce20d7c1b4
  1. 11
      src/app.cpp
  2. 30
      src/app.h
  3. 16
      src/plugins/Display/Display.h

11
src/app.cpp

@ -4,13 +4,14 @@
//-----------------------------------------------------------------------------
#include "app.h"
#include <ArduinoJson.h>
#include "utils/sun.h"
//-----------------------------------------------------------------------------
app::app() : ah::Scheduler() {}
//-----------------------------------------------------------------------------
void app::setup() {
Serial.begin(115200);
@ -78,13 +79,12 @@ void app::setup() {
// Plugins
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);
regularTickers();
// DBGPRINTLN("--- end setup");
// DBGPRINTLN(String(ESP.getFreeHeap()));
// DBGPRINTLN(String(ESP.getHeapFragmentation()));
@ -155,8 +155,7 @@ void app::onWifi(bool gotIp) {
mMqttEnabled = false;
everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL");
}
}
else {
} else {
mInnerLoopCb = std::bind(&app::loopWifi, this);
everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL");
}
@ -168,7 +167,7 @@ void app::regularTickers(void) {
everySec(std::bind(&WebType::tickSecond, &mWeb), "webSc");
// Plugins
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");
}

30
src/app.h

@ -6,30 +6,25 @@
#ifndef __APP_H__
#define __APP_H__
#include "utils/dbg.h"
#include <Arduino.h>
#include <ArduinoJson.h>
#include <RF24.h>
#include <RF24_config.h>
#include <ArduinoJson.h>
#include "appInterface.h"
#include "config/settings.h"
#include "defines.h"
#include "utils/crc.h"
#include "utils/scheduler.h"
#include "hm/hmSystem.h"
#include "hm/hmPayload.h"
#include "hm/hmSystem.h"
#include "hm/miPayload.h"
#include "wifi/ahoywifi.h"
#include "web/web.h"
#include "web/RestApi.h"
#include "publisher/pubMqtt.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
#define SIN(x) (sin(radians(x)))
@ -46,9 +41,8 @@ typedef PubMqtt<HmSystemType> PubMqttType;
typedef PubSerial<HmSystemType> PubSerialType;
// PLUGINS
#include "plugins/Display/MonochromeDisplay.h"
typedef MonochromeDisplay<HmSystemType> MonoDisplayType;
#include "plugins/Display/Display.h"
typedef Display<HmSystemType> DisplayType;
class app : public IApp, public ah::Scheduler {
public:
@ -203,7 +197,7 @@ class app : public IApp, public ah::Scheduler {
mMqtt.payloadEventListener(cmd);
#endif
if (mConfig->plugin.display.type != 0)
mMonoDisplay.payloadEventListener(cmd);
mDisplay.payloadEventListener(cmd);
}
void mqttSubRxCb(JsonObject obj);
@ -274,7 +268,7 @@ class app : public IApp, public ah::Scheduler {
uint32_t mSunrise, mSunset;
// plugins
MonoDisplayType mMonoDisplay;
DisplayType mDisplay;
};
#endif /*__APP_H__*/

16
src/plugins/Display/MonochromeDisplay.h → src/plugins/Display/Display.h

@ -1,5 +1,5 @@
#ifndef __MONOCHROME_DISPLAY__
#define __MONOCHROME_DISPLAY__
#ifndef __DISPLAY__
#define __DISPLAY__
#include <Timezone.h>
#include <U8g2lib.h>
@ -13,9 +13,9 @@
#define DISP_DEFAULT_TIMEOUT 60 // in seconds
template <class HMSYSTEM>
class MonochromeDisplay {
class Display {
public:
MonochromeDisplay() {}
Display() {}
void setup(display_t *cfg, HMSYSTEM *sys, uint32_t *utcTs, uint8_t disp_reset, const char *version) {
mCfg = cfg;
@ -26,7 +26,7 @@ class MonochromeDisplay {
if (mCfg->type == 0) {
return;
} else if (1 < mCfg->type < 10) {
} else if (1 < mCfg->type < 11) {
switch (mCfg->rot) {
case 0:
DisplayMono.disp_rotation = U8G2_R0;
@ -97,9 +97,9 @@ class MonochromeDisplay {
totalYieldTotal += iv->getChannelFieldValue(CH0, FLD_YT, rec);
}
if (1 < mCfg->type < 4) {
if (1 < mCfg->type < 11) {
DisplayMono.loop(totalPower, totalYieldDay, totalYieldTotal, isprod);
} else if (mCfg->type == 4) {
} else if (mCfg->type > 10) {
DisplayEPaper.loop(totalPower, totalYieldDay, totalYieldTotal, isprod);
counterEPaper++;
}
@ -123,4 +123,4 @@ class MonochromeDisplay {
uint32_t _lastDisplayUpdate = 0;
};
#endif /*__MONOCHROME_DISPLAY__*/
#endif /*__DISPLAY__*/
Loading…
Cancel
Save