mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-30 01:06:11 +02:00
fix blue LED lights up all the time #672
added an instant start communication (once NTP is synced)
This commit is contained in:
parent
e03464dabc
commit
a157f2b97b
7 changed files with 30 additions and 17 deletions
31
src/app.cpp
31
src/app.cpp
|
@ -164,7 +164,8 @@ void app::tickNtpUpdate(void) {
|
|||
mMqttReconnect = false;
|
||||
}
|
||||
|
||||
everyMin(std::bind(&app::tickMinute, this), "tMin");
|
||||
if(mConfig->inst.rstValsNotAvail)
|
||||
everyMin(std::bind(&app::tickMinute, this), "tMin");
|
||||
if(mConfig->inst.rstYieldMidNight) {
|
||||
uint32_t midTrig = mTimestamp - ((mTimestamp - 1) % 86400) + 86400; // next midnight
|
||||
onceAt(std::bind(&app::tickMidnight, this), midTrig, "midNi");
|
||||
|
@ -176,6 +177,12 @@ void app::tickNtpUpdate(void) {
|
|||
mCalculatedTimezoneOffset = (int8_t)((mConfig->sun.lon >= 0 ? mConfig->sun.lon + 7.5 : mConfig->sun.lon - 7.5) / 15) * 3600;
|
||||
tickCalcSunrise();
|
||||
}
|
||||
|
||||
// immediately start communicating
|
||||
if(isOK && mSendFirst) {
|
||||
mSendFirst = false;
|
||||
once(std::bind(&app::tickSend, this), 2, "senOn");
|
||||
}
|
||||
}
|
||||
once(std::bind(&app::tickNtpUpdate, this), nxtTrig, "ntp");
|
||||
}
|
||||
|
@ -246,17 +253,17 @@ void app::tickComm(void) {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
void app::tickMinute(void) {
|
||||
if(mConfig->inst.rstValsNotAvail) {
|
||||
Inverter<> *iv;
|
||||
// set values to zero, except yields
|
||||
for (uint8_t id = 0; id < mSys.getNumInverters(); id++) {
|
||||
iv = mSys.getInverterByPos(id);
|
||||
if (NULL == iv)
|
||||
continue; // skip to next inverter
|
||||
// only triggered if 'reset values on no avail is enabled'
|
||||
|
||||
if(!iv->isAvailable(mTimestamp) && !iv->isProducing(mTimestamp) && iv->config->enabled)
|
||||
mPayload.zeroInverterValues(iv);
|
||||
}
|
||||
Inverter<> *iv;
|
||||
// set values to zero, except yields
|
||||
for (uint8_t id = 0; id < mSys.getNumInverters(); id++) {
|
||||
iv = mSys.getInverterByPos(id);
|
||||
if (NULL == iv)
|
||||
continue; // skip to next inverter
|
||||
|
||||
if(!iv->isAvailable(mTimestamp) && !iv->isProducing(mTimestamp) && iv->config->enabled)
|
||||
mPayload.zeroInverterValues(iv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -325,6 +332,8 @@ void app::resetSystem(void) {
|
|||
mTimestamp = 1;
|
||||
#endif
|
||||
|
||||
mSendFirst = true;
|
||||
|
||||
mSunrise = 0;
|
||||
mSunset = 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue