Migrate InverterSettings to TaskScheduler
This commit is contained in:
parent
1501411037
commit
77779a1ed9
@ -1,16 +1,20 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <TaskSchedulerDeclarations.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#define INVERTER_UPDATE_SETTINGS_INTERVAL 60000l
|
#define INVERTER_UPDATE_SETTINGS_INTERVAL 60000l
|
||||||
|
|
||||||
class InverterSettingsClass {
|
class InverterSettingsClass {
|
||||||
public:
|
public:
|
||||||
void init();
|
void init(Scheduler* scheduler);
|
||||||
void loop();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void loop();
|
||||||
|
|
||||||
|
Task _loopTask;
|
||||||
|
|
||||||
uint32_t _lastUpdate = 0;
|
uint32_t _lastUpdate = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
InverterSettingsClass InverterSettings;
|
InverterSettingsClass InverterSettings;
|
||||||
|
|
||||||
void InverterSettingsClass::init()
|
void InverterSettingsClass::init(Scheduler* scheduler)
|
||||||
{
|
{
|
||||||
const CONFIG_T& config = Configuration.get();
|
const CONFIG_T& config = Configuration.get();
|
||||||
const PinMapping_t& pin = PinMapping.get();
|
const PinMapping_t& pin = PinMapping.get();
|
||||||
@ -87,6 +87,11 @@ void InverterSettingsClass::init()
|
|||||||
} else {
|
} else {
|
||||||
MessageOutput.println("Invalid pin config");
|
MessageOutput.println("Invalid pin config");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scheduler->addTask(_loopTask);
|
||||||
|
_loopTask.setCallback(std::bind(&InverterSettingsClass::loop, this));
|
||||||
|
_loopTask.setIterations(TASK_FOREVER);
|
||||||
|
_loopTask.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InverterSettingsClass::loop()
|
void InverterSettingsClass::loop()
|
||||||
|
|||||||
@ -144,7 +144,7 @@ void setup()
|
|||||||
}
|
}
|
||||||
MessageOutput.println("done");
|
MessageOutput.println("done");
|
||||||
|
|
||||||
InverterSettings.init();
|
InverterSettings.init(&scheduler);
|
||||||
|
|
||||||
Datastore.init(&scheduler);
|
Datastore.init(&scheduler);
|
||||||
}
|
}
|
||||||
@ -153,8 +153,6 @@ void loop()
|
|||||||
{
|
{
|
||||||
scheduler.execute();
|
scheduler.execute();
|
||||||
|
|
||||||
InverterSettings.loop();
|
|
||||||
yield();
|
|
||||||
WebApi.loop();
|
WebApi.loop();
|
||||||
yield();
|
yield();
|
||||||
Display.loop();
|
Display.loop();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user