Implemented Bobbytasks
This commit is contained in:
@@ -43,6 +43,7 @@ set(headers
|
|||||||
bobbyerrorhandler.h
|
bobbyerrorhandler.h
|
||||||
bobbyquickactions.h
|
bobbyquickactions.h
|
||||||
bobbytypesafeenum.h
|
bobbytypesafeenum.h
|
||||||
|
bobbyschedulertask.h
|
||||||
buildserver.h
|
buildserver.h
|
||||||
can.h
|
can.h
|
||||||
changevaluedisplay_bluetoothmode.h
|
changevaluedisplay_bluetoothmode.h
|
||||||
|
13
main/bobbyschedulertask.h
Normal file
13
main/bobbyschedulertask.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// 3rdparty lib includes
|
||||||
|
#include <schedulertask.h>
|
||||||
|
|
||||||
|
class BobbySchedulerTask : public espcpputils::SchedulerTask {
|
||||||
|
public:
|
||||||
|
using SchedulerTask::SchedulerTask;
|
||||||
|
void setup() const { SchedulerTask::setup(); m_wasInitialized = true; }
|
||||||
|
bool isInitialized() { return m_wasInitialized; }
|
||||||
|
private:
|
||||||
|
mutable bool m_wasInitialized{false};
|
||||||
|
};
|
@@ -107,7 +107,8 @@ extern "C" void app_main()
|
|||||||
|
|
||||||
for (auto &schedulerTask : schedulerTasks)
|
for (auto &schedulerTask : schedulerTasks)
|
||||||
{
|
{
|
||||||
schedulerTask.loop();
|
if (schedulerTask.isInitialized())
|
||||||
|
schedulerTask.loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lastStatsUpdate || now - *lastStatsUpdate >= 1000ms/configs.boardcomputerHardware.timersSettings.statsUpdateRate.value)
|
if (!lastStatsUpdate || now - *lastStatsUpdate >= 1000ms/configs.boardcomputerHardware.timersSettings.statsUpdateRate.value)
|
||||||
|
@@ -9,9 +9,6 @@
|
|||||||
// esp-idf includes
|
// esp-idf includes
|
||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
|
|
||||||
// 3rdparty lib includes
|
|
||||||
#include <schedulertask.h>
|
|
||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#include "wifi_bobbycar.h"
|
#include "wifi_bobbycar.h"
|
||||||
#include "dpad.h"
|
#include "dpad.h"
|
||||||
@@ -59,9 +56,7 @@
|
|||||||
#ifdef FEATURE_WEBSERVER
|
#ifdef FEATURE_WEBSERVER
|
||||||
#include "webserver.h"
|
#include "webserver.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_LEDSTRIP
|
|
||||||
#include "ledstrip.h"
|
#include "ledstrip.h"
|
||||||
#endif
|
|
||||||
#ifdef FEATURE_ESPNOW
|
#ifdef FEATURE_ESPNOW
|
||||||
#include "espnowfunctions.h"
|
#include "espnowfunctions.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -85,81 +80,79 @@ constexpr const char * const TAG = "TASKS";
|
|||||||
|
|
||||||
void not_needed() {}
|
void not_needed() {}
|
||||||
|
|
||||||
espcpputils::SchedulerTask schedulerTasksArr[] {
|
BobbySchedulerTask schedulerTasksArr[] {
|
||||||
espcpputils::SchedulerTask { "wifi", wifi_begin, wifi_update, 100ms },
|
BobbySchedulerTask { "wifi", wifi_begin, wifi_update, 100ms },
|
||||||
#ifdef FEATURE_DPAD
|
#ifdef FEATURE_DPAD
|
||||||
espcpputils::SchedulerTask { "dpad", dpad::init, dpad::update, 20ms },
|
BobbySchedulerTask { "dpad", dpad::init, dpad::update, 20ms },
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_DPAD_3WIRESW
|
#ifdef FEATURE_DPAD_3WIRESW
|
||||||
espcpputils::SchedulerTask { "dpad3wire", dpad3wire::init, dpad3wire::update, 20ms },
|
BobbySchedulerTask { "dpad3wire", dpad3wire::init, dpad3wire::update, 20ms },
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_DPAD_5WIRESW
|
#ifdef FEATURE_DPAD_5WIRESW
|
||||||
espcpputils::SchedulerTask { "dpad5wire", dpad5wire::init, dpad5wire::update, 20ms },
|
BobbySchedulerTask { "dpad5wire", dpad5wire::init, dpad5wire::update, 20ms },
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_DPAD_5WIRESW_2OUT
|
#ifdef FEATURE_DPAD_5WIRESW_2OUT
|
||||||
espcpputils::SchedulerTask { "dpad5wire_2out", dpad5wire_2out::init, dpad5wire_2out::update, 20ms },
|
BobbySchedulerTask { "dpad5wire_2out", dpad5wire_2out::init, dpad5wire_2out::update, 20ms },
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_DPAD_6WIRESW
|
#ifdef FEATURE_DPAD_6WIRESW
|
||||||
espcpputils::SchedulerTask { "dpad6wire", dpad6wire::init, dpad6wire::update, 20ms },
|
BobbySchedulerTask { "dpad6wire", dpad6wire::init, dpad6wire::update, 20ms },
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_ROTARY
|
#ifdef FEATURE_ROTARY
|
||||||
espcpputils::SchedulerTask { "rotary", initRotary, updateRotary, 20ms },
|
BobbySchedulerTask { "rotary", initRotary, updateRotary, 20ms },
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_MOSFETS
|
#ifdef FEATURE_MOSFETS
|
||||||
espcpputils::SchedulerTask { "mosfets", init_mosfets, update_mosfets, 100ms },
|
BobbySchedulerTask { "mosfets", init_mosfets, update_mosfets, 100ms },
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_NTP
|
#ifdef FEATURE_NTP
|
||||||
espcpputils::SchedulerTask { "time", initTime, updateTime, 100ms },
|
BobbySchedulerTask { "time", initTime, updateTime, 100ms },
|
||||||
#endif
|
#endif
|
||||||
espcpputils::SchedulerTask { "potis", initPotis, readPotis, 20ms },
|
BobbySchedulerTask { "potis", initPotis, readPotis, 20ms },
|
||||||
#ifdef FEATURE_BLUETOOTH
|
#ifdef FEATURE_BLUETOOTH
|
||||||
espcpputils::SchedulerTask { "bluetooth", bluetooth_init, bluetooth_update, 100ms },
|
BobbySchedulerTask { "bluetooth", bluetooth_init, bluetooth_update, 100ms },
|
||||||
#ifdef FEATURE_BMS
|
#ifdef FEATURE_BMS
|
||||||
espcpputils::SchedulerTask { "bms", bms::init, bms::update, 100ms },
|
BobbySchedulerTask { "bms", bms::init, bms::update, 100ms },
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_CAN
|
#ifdef FEATURE_CAN
|
||||||
espcpputils::SchedulerTask { "can", can::initCan, can::updateCan, 10ms },
|
BobbySchedulerTask { "can", can::initCan, can::updateCan, 10ms },
|
||||||
#endif
|
#endif
|
||||||
espcpputils::SchedulerTask { "debuginput", initDebugInput, handleDebugInput, 50ms },
|
BobbySchedulerTask { "debuginput", initDebugInput, handleDebugInput, 50ms },
|
||||||
#ifdef FEATURE_SERIAL
|
#ifdef FEATURE_SERIAL
|
||||||
espcpputils::SchedulerTask { "serial", initSerial, updateSerial, 50ms },
|
BobbySchedulerTask { "serial", initSerial, updateSerial, 50ms },
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_OTA
|
#ifdef FEATURE_OTA
|
||||||
espcpputils::SchedulerTask { "ota", initOta, handleOta, 50ms },
|
BobbySchedulerTask { "ota", initOta, handleOta, 50ms },
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_BLE
|
#ifdef FEATURE_BLE
|
||||||
espcpputils::SchedulerTask { "ble", initBle, handleBle, 100ms },
|
BobbySchedulerTask { "ble", initBle, handleBle, 100ms },
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_WEBSERVER
|
#ifdef FEATURE_WEBSERVER
|
||||||
espcpputils::SchedulerTask { "webserver", initWebserver, handleWebserver, 100ms },
|
BobbySchedulerTask { "webserver", initWebserver, handleWebserver, 100ms },
|
||||||
#endif
|
|
||||||
#ifdef FEATURE_LEDSTRIP
|
|
||||||
espcpputils::SchedulerTask { "ledstrip", initLedStrip, updateLedStrip, 30ms },
|
|
||||||
#endif
|
#endif
|
||||||
|
BobbySchedulerTask { "ledstrip", initLedStrip, updateLedStrip, 30ms },
|
||||||
#ifdef FEATURE_ESPNOW
|
#ifdef FEATURE_ESPNOW
|
||||||
espcpputils::SchedulerTask { "espnow", espnow::initESPNow, espnow::handle, 100ms },
|
BobbySchedulerTask { "espnow", espnow::initESPNow, espnow::handle, 100ms },
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_CLOUD
|
#ifdef FEATURE_CLOUD
|
||||||
espcpputils::SchedulerTask { "cloud", initCloud, updateCloud, 50ms },
|
BobbySchedulerTask { "cloud", initCloud, updateCloud, 50ms },
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_UDPCLOUD
|
#ifdef FEATURE_UDPCLOUD
|
||||||
espcpputils::SchedulerTask { "udpcloud", udpCloudInit, udpCloudUpdate, 50ms },
|
BobbySchedulerTask { "udpcloud", udpCloudInit, udpCloudUpdate, 50ms },
|
||||||
#endif
|
#endif
|
||||||
espcpputils::SchedulerTask { "drivingmode", initDrivingMode, updateDrivingMode, 20ms },
|
BobbySchedulerTask { "drivingmode", initDrivingMode, updateDrivingMode, 20ms },
|
||||||
espcpputils::SchedulerTask { "drivingstatistics", initStatistics, calculateStatistics, 100ms },
|
BobbySchedulerTask { "drivingstatistics", initStatistics, calculateStatistics, 100ms },
|
||||||
#ifdef FEATURE_DNS_NS
|
#ifdef FEATURE_DNS_NS
|
||||||
espcpputils::SchedulerTask { "dnsannounce", init_dns_announce, handle_dns_announce, 100ms },
|
BobbySchedulerTask { "dnsannounce", init_dns_announce, handle_dns_announce, 100ms },
|
||||||
#endif
|
#endif
|
||||||
espcpputils::SchedulerTask { "updateDisp", not_needed, updateDisplay, 20ms },
|
BobbySchedulerTask { "updateDisp", not_needed, updateDisplay, 20ms },
|
||||||
espcpputils::SchedulerTask { "redrawDisp", not_needed, redrawDisplay, 20ms },
|
BobbySchedulerTask { "redrawDisp", not_needed, redrawDisplay, 20ms },
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
cpputils::ArrayView<espcpputils::SchedulerTask> schedulerTasks{std::begin(schedulerTasksArr), std::end(schedulerTasksArr)};
|
cpputils::ArrayView<BobbySchedulerTask> schedulerTasks{std::begin(schedulerTasksArr), std::end(schedulerTasksArr)};
|
||||||
|
|
||||||
const espcpputils::SchedulerTask &drivingModeTask = []() -> const espcpputils::SchedulerTask & {
|
const BobbySchedulerTask &drivingModeTask = []() -> const BobbySchedulerTask & {
|
||||||
auto iter = std::find_if(std::begin(schedulerTasksArr), std::end(schedulerTasksArr), [](const espcpputils::SchedulerTask &task){
|
auto iter = std::find_if(std::begin(schedulerTasksArr), std::end(schedulerTasksArr), [](const BobbySchedulerTask &task){
|
||||||
return std::string_view{task.name()} == "drivingmode";
|
return std::string_view{task.name()} == "drivingmode";
|
||||||
});
|
});
|
||||||
return *iter;
|
return *iter;
|
||||||
|
@@ -3,11 +3,11 @@
|
|||||||
// 3rdparty lib includes
|
// 3rdparty lib includes
|
||||||
#include <arrayview.h>
|
#include <arrayview.h>
|
||||||
|
|
||||||
// forward declares
|
// local includes
|
||||||
namespace espcpputils { class SchedulerTask; }
|
#include "bobbyschedulertask.h"
|
||||||
|
|
||||||
extern cpputils::ArrayView<espcpputils::SchedulerTask> schedulerTasks;
|
extern cpputils::ArrayView<BobbySchedulerTask> schedulerTasks;
|
||||||
|
|
||||||
extern const espcpputils::SchedulerTask &drivingModeTask;
|
extern const BobbySchedulerTask &drivingModeTask;
|
||||||
|
|
||||||
void sched_pushStats(bool printTasks);
|
void sched_pushStats(bool printTasks);
|
||||||
|
Reference in New Issue
Block a user