1
0
mirror of https://github.com/whowechina/aic_pico.git synced 2025-01-21 03:48:43 +01:00
aic_pico/firmware/src/config.c

45 lines
840 B
C
Raw Normal View History

2023-11-01 20:41:25 +08:00
/*
* Controller Config and Runtime Data
* WHowe <github.com/whowechina>
*
* Config is a global data structure that stores all the configuration
* Runtime is something to share between files.
*/
#include "config.h"
#include "save.h"
aic_cfg_t *aic_cfg;
2023-11-04 20:30:53 +08:00
static aic_cfg_t default_cfg = {
2024-03-23 11:40:37 +08:00
.light = { .min = 24, .max = 128, .rgb = true, .led = true },
.virtual_aic = true,
2024-04-14 16:17:26 +08:00
.mode = 0,
2023-11-04 20:30:53 +08:00
};
2023-11-01 20:41:25 +08:00
aic_runtime_t *aic_runtime;
static void config_loaded()
{
2023-11-18 10:45:47 +08:00
if (aic_cfg->light.min > aic_cfg->light.max) {
aic_cfg->light = default_cfg.light;
config_changed();
}
2023-11-01 20:41:25 +08:00
}
void config_changed()
{
save_request(false);
}
void config_factory_reset()
{
*aic_cfg = default_cfg;
save_request(true);
}
void config_init()
{
aic_cfg = (aic_cfg_t *)save_alloc(sizeof(*aic_cfg), &default_cfg, config_loaded);
}