diff --git a/.gitmodules b/.gitmodules index 7df473a..b4fd32e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "components/idf-dfplayermini"] path = components/idf-dfplayermini url = https://git.oit.cloud/morgan/idf-dfplayermini.git +[submodule "components/configulator"] + path = components/configulator + url = https://git.oit.cloud/morgan/configulator diff --git a/components/configulator b/components/configulator new file mode 160000 index 0000000..c9c691a --- /dev/null +++ b/components/configulator @@ -0,0 +1 @@ +Subproject commit c9c691ab7e7d2f6945c49a7327652df401905361 diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 55360f2..5719c80 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -6,6 +6,6 @@ set(COMPONENT_SRCS "\ user_button.c\ ") set(COMPONENT_ADD_INCLUDEDIRS ". ../include") -set(REQUIRES idf-dfplayermini) +set(REQUIRES configulator) register_component() diff --git a/main/main.c b/main/main.c index 6d0b0ab..1ed1ecf 100644 --- a/main/main.c +++ b/main/main.c @@ -10,6 +10,7 @@ #include "nvs_flash.h" #include "esp_vfs_dev.h" +#include "configulator.h" #include "main.h" #include "console.h" #include "ble.h" @@ -44,6 +45,24 @@ void app_main(void) { char *name = malloc(strlen(TAG) + 4); sprintf(name, "%s-%02X", TAG, mac[5]); + uint8_t tank_levels[] = { 100, 100, 100, 100 }; + + cfglr_handle_t cfglr_handle = { + .namespace = "configulator", + .backend = CFGLR_BACKEND_NVS(), + .elements = { + CFGLR_ELEMENT_U8("armed", 1, CFGLR_SIGNALER_IDF_EVENT()), + CFGLR_ELEMENT_U8("monitor", 0, CFGLR_SIGNALER_IDF_EVENT()), + CFGLR_ELEMENT_U8("pour_button", 21, CFGLR_SIGNALER_IDF_EVENT()), + CFGLR_ELEMENT_STR("device_name", 32, name, CFGLR_SIGNALER_IDF_EVENT()), + CFGLR_ELEMENT_BIN("tank_levels", 4, tank_levels, 4, CFGLR_SIGNALER_IDF_EVENT()), + CFGLR_ELEMENT_BIN("pump_pins", 4, pump_gpio_map, 4, CFGLR_SIGNALER_IDF_EVENT()), + { NULL }, + }, + }; + + uint8_t ret = cfglr_init(&cfglr_handle); + vTaskDelay(1000 / portTICK_PERIOD_MS); user_button_init();