Added battery module, cal factor refresh bug

This commit is contained in:
2026-03-27 17:14:16 +01:00
parent f000924c05
commit eab70f9bf9
12 changed files with 224 additions and 36 deletions

View File

@@ -5,22 +5,34 @@
#include "router.h"
namespace router {
int send(const Task& task) {
if (task.target >= MOD_COUNT) {
return 1;
}
int send(const Task &task) {
if (task.target == MOD_ALL) {
for (size_t i = 0; i < MOD_COUNT; i++) {
module_base* mod = modules[task.target];
module_base *mod = modules[i];
if (mod == nullptr) {
return 1;
}
if (mod == nullptr) {
continue;
}
return mod->push(task);
return mod->push(task);
}
}
if (task.target >= MOD_COUNT) {
return 1;
}
int send(module_id target, task_type type, uint32_t data) {
Task t{target, type, data};
return send(t);
}
}
module_base *mod = modules[task.target];
if (mod == nullptr) {
return 1;
}
return mod->push(task);
}
int send(module_id target, task_type type, uint32_t data) {
Task t{target, type, data};
return send(t);
}
} // namespace router

View File

@@ -10,8 +10,10 @@ enum module_id : uint8_t {
MOD_CFG,
MOD_GPS,
MOD_LCD,
MOD_BAT,
MOD_COUNT,
MOD_NULL
MOD_NULL,
MOD_ALL,
};
enum task_type : uint8_t {
@@ -25,6 +27,9 @@ enum task_type : uint8_t {
TASK_CONFIG_WRITE_TEMP_TRACK,
TASK_CONFIG_TRACK_DELETE,
TASK_CONFIG_CFG_RESET,
TASK_CONFIG_VBAT_CAL_SET,
TASK_BATTERY_CAL,
TASK_ALL_CONFIG_UPDATED,
};
struct Task {