mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-06 03:50:13 +02:00
Remove loop, simplify events section
This commit is contained in:
parent
f6b036052c
commit
873c5e249e
5 changed files with 10 additions and 30 deletions
|
@ -146,17 +146,8 @@ void setup() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform main program functions
|
// Loop empty, all functionality runs in tasks
|
||||||
void loop() {
|
void loop() {}
|
||||||
START_TIME_MEASUREMENT(loop_func);
|
|
||||||
run_event_handling();
|
|
||||||
END_TIME_MEASUREMENT_MAX(loop_func, datalayer.system.status.loop_task_10s_max_us);
|
|
||||||
#ifdef FUNCTION_TIME_MEASUREMENT
|
|
||||||
if (loop_task_timer_10s.elapsed()) {
|
|
||||||
datalayer.system.status.loop_task_10s_max_us = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(LOG_CAN_TO_SD) || defined(LOG_TO_SD)
|
#if defined(LOG_CAN_TO_SD) || defined(LOG_TO_SD)
|
||||||
void logging_loop(void* task_time_us) {
|
void logging_loop(void* task_time_us) {
|
||||||
|
|
|
@ -247,8 +247,6 @@ typedef struct {
|
||||||
int64_t mqtt_task_10s_max_us = 0;
|
int64_t mqtt_task_10s_max_us = 0;
|
||||||
/** Wifi sub-task measurement variable, reset each 10 seconds */
|
/** Wifi sub-task measurement variable, reset each 10 seconds */
|
||||||
int64_t wifi_task_10s_max_us = 0;
|
int64_t wifi_task_10s_max_us = 0;
|
||||||
/** loop() task measurement variable, reset each 10 seconds */
|
|
||||||
int64_t loop_task_10s_max_us = 0;
|
|
||||||
|
|
||||||
/** OTA handling function measurement variable */
|
/** OTA handling function measurement variable */
|
||||||
int64_t time_ota_us = 0;
|
int64_t time_ota_us = 0;
|
||||||
|
|
|
@ -59,6 +59,7 @@ static const char* EVENTS_ENUM_TYPE_STRING[] = {EVENTS_ENUM_TYPE(GENERATE_STRING
|
||||||
static const char* EVENTS_LEVEL_TYPE_STRING[] = {EVENTS_LEVEL_TYPE(GENERATE_STRING)};
|
static const char* EVENTS_LEVEL_TYPE_STRING[] = {EVENTS_LEVEL_TYPE(GENERATE_STRING)};
|
||||||
|
|
||||||
static uint32_t lastMillis = millis();
|
static uint32_t lastMillis = millis();
|
||||||
|
static uint32_t currentMillis = 0;
|
||||||
|
|
||||||
/* Local function prototypes */
|
/* Local function prototypes */
|
||||||
static void set_event(EVENTS_ENUM_TYPE event, uint8_t data, bool latched);
|
static void set_event(EVENTS_ENUM_TYPE event, uint8_t data, bool latched);
|
||||||
|
@ -69,19 +70,6 @@ static void print_event_log(void);
|
||||||
|
|
||||||
uint8_t millisrolloverCount = 0;
|
uint8_t millisrolloverCount = 0;
|
||||||
|
|
||||||
/* Exported functions */
|
|
||||||
|
|
||||||
/* Main execution function, should handle various continuous functionality */
|
|
||||||
void run_event_handling(void) {
|
|
||||||
uint32_t currentMillis = millis();
|
|
||||||
if (currentMillis < lastMillis) { // Overflow detected
|
|
||||||
millisrolloverCount++;
|
|
||||||
}
|
|
||||||
lastMillis = currentMillis;
|
|
||||||
|
|
||||||
update_event_level();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialization function */
|
/* Initialization function */
|
||||||
void init_events(void) {
|
void init_events(void) {
|
||||||
|
|
||||||
|
@ -239,6 +227,13 @@ void set_event_latched(EVENTS_ENUM_TYPE event, uint8_t data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_event(EVENTS_ENUM_TYPE event) {
|
void clear_event(EVENTS_ENUM_TYPE event) {
|
||||||
|
//Not related to clearing, but good time to check if we have rollover on millis
|
||||||
|
currentMillis = millis();
|
||||||
|
if (currentMillis < lastMillis) { // Overflow detected
|
||||||
|
millisrolloverCount++;
|
||||||
|
}
|
||||||
|
lastMillis = currentMillis;
|
||||||
|
|
||||||
if (events.entries[event].state == EVENT_STATE_ACTIVE) {
|
if (events.entries[event].state == EVENT_STATE_ACTIVE) {
|
||||||
events.entries[event].state = EVENT_STATE_INACTIVE;
|
events.entries[event].state = EVENT_STATE_INACTIVE;
|
||||||
update_event_level();
|
update_event_level();
|
||||||
|
|
|
@ -177,8 +177,6 @@ void set_event_MQTTpublished(EVENTS_ENUM_TYPE event);
|
||||||
|
|
||||||
const EVENTS_STRUCT_TYPE* get_event_pointer(EVENTS_ENUM_TYPE event);
|
const EVENTS_STRUCT_TYPE* get_event_pointer(EVENTS_ENUM_TYPE event);
|
||||||
|
|
||||||
void run_event_handling(void);
|
|
||||||
|
|
||||||
void run_sequence_on_target(void);
|
void run_sequence_on_target(void);
|
||||||
|
|
||||||
bool compareEventsByTimestampAsc(const EventData& a, const EventData& b);
|
bool compareEventsByTimestampAsc(const EventData& a, const EventData& b);
|
||||||
|
|
|
@ -940,8 +940,6 @@ String processor(const String& var) {
|
||||||
content +=
|
content +=
|
||||||
"<h4>WIFI function (MQTT task) max load last 10 s: " + String(datalayer.system.status.wifi_task_10s_max_us) +
|
"<h4>WIFI function (MQTT task) max load last 10 s: " + String(datalayer.system.status.wifi_task_10s_max_us) +
|
||||||
" us</h4>";
|
" us</h4>";
|
||||||
content +=
|
|
||||||
"<h4>loop() task max load last 10 s: " + String(datalayer.system.status.loop_task_10s_max_us) + " us</h4>";
|
|
||||||
content += "<h4>Max load @ worst case execution of core task:</h4>";
|
content += "<h4>Max load @ worst case execution of core task:</h4>";
|
||||||
content += "<h4>10ms function timing: " + String(datalayer.system.status.time_snap_10ms_us) + " us</h4>";
|
content += "<h4>10ms function timing: " + String(datalayer.system.status.time_snap_10ms_us) + " us</h4>";
|
||||||
content += "<h4>Values function timing: " + String(datalayer.system.status.time_snap_values_us) + " us</h4>";
|
content += "<h4>Values function timing: " + String(datalayer.system.status.time_snap_values_us) + " us</h4>";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue