mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-28 00:06:12 +02:00
MonochromeDisplay in Display umbenannt
This commit is contained in:
parent
18ea8b5925
commit
ce20d7c1b4
3 changed files with 296 additions and 303 deletions
11
src/app.cpp
11
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);
|
||||||
|
@ -78,13 +79,12 @@ void app::setup() {
|
||||||
|
|
||||||
// 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()));
|
||||||
|
@ -155,8 +155,7 @@ void app::onWifi(bool gotIp) {
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
@ -168,7 +167,7 @@ void app::regularTickers(void) {
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
30
src/app.h
30
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:
|
||||||
|
@ -203,7 +197,7 @@ class app : public IApp, public ah::Scheduler {
|
||||||
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