diff --git a/components/insa/CMakeLists.txt b/components/insa/CMakeLists.txt index 41b8508..660d3ec 100644 --- a/components/insa/CMakeLists.txt +++ b/components/insa/CMakeLists.txt @@ -10,6 +10,9 @@ if (DEFINED ENV{IDF_PATH}) src/ui/SettingsMenu.cpp src/ui/SplashScreen.cpp INCLUDE_DIRS "include" + PRIV_REQUIRES + ruth + u8g2 ) return() endif () diff --git a/components/insa/src/data/MenuItem.cpp b/components/insa/src/data/MenuItem.cpp index 0e1e411..c64fb5c 100644 --- a/components/insa/src/data/MenuItem.cpp +++ b/components/insa/src/data/MenuItem.cpp @@ -7,8 +7,7 @@ MenuItem::MenuItem(const uint8_t id, const uint8_t type, std::string text, Butto } // Constructor for menu items with a single value (toggles) -MenuItem::MenuItem(const uint8_t id, const uint8_t type, std::string text, std::string value, - ButtonCallback callback) +MenuItem::MenuItem(const uint8_t id, const uint8_t type, std::string text, std::string value, ButtonCallback callback) : m_id(id), m_type(type), m_text(std::move(text)), m_value(std::move(value)), m_callback(std::move(callback)) { } @@ -93,12 +92,8 @@ MenuItem MenuItem::copyWith(const size_t index) const { // Create a copy of this menu item with a new selected index MenuItem copy = *this; - + // Check for potential overflow when converting size_t to int - if (index > std::numeric_limits::max()) - { - throw std::overflow_error("index is too large"); - } copy.m_index = static_cast(index); return copy; } \ No newline at end of file diff --git a/components/insa/src/ui/LightSettingsMenu.cpp b/components/insa/src/ui/LightSettingsMenu.cpp index fa07dae..2065d9a 100644 --- a/components/insa/src/ui/LightSettingsMenu.cpp +++ b/components/insa/src/ui/LightSettingsMenu.cpp @@ -17,7 +17,7 @@ LightSettingsMenu::LightSettingsMenu(menu_options_t *options) : Menu(options), m { values.emplace_back(std::to_string(i)); } - + // Add section counter selection (allows choosing number of sections) addSelection(LightSettingsMenuItem::SECTION_COUNTER, "Sektionen", values, 7); @@ -36,7 +36,7 @@ void LightSettingsMenu::onButtonPressed(const MenuItem &menuItem, const ButtonTy if (m_options && m_options->persistence && m_options->persistence->save) { const auto key = "section_" + std::to_string(menuItem.getId()); - const auto &value = getItem(menuItem.getId()).getValue(); + const auto value = getItem(menuItem.getId()).getValue(); m_options->persistence->save(key.c_str(), value.c_str()); } } \ No newline at end of file diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 6a9bebc..76d489c 100755 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -1,7 +1,6 @@ idf_component_register(SRCS - "main.c" - "setup.c" - "button_handling.c" + "main.cpp" + "app_task.cpp" INCLUDE_DIRS "." REQUIRES insa diff --git a/main/app_task.cpp b/main/app_task.cpp new file mode 100644 index 0000000..e17314f --- /dev/null +++ b/main/app_task.cpp @@ -0,0 +1,7 @@ +#include "app_task.h" +#include "ui/SplashScreen.h" + +void app_task(void *args) +{ + /// +} \ No newline at end of file diff --git a/main/app_task.h b/main/app_task.h new file mode 100644 index 0000000..fb200be --- /dev/null +++ b/main/app_task.h @@ -0,0 +1,3 @@ +#pragma once + +void app_task(void *args); \ No newline at end of file diff --git a/main/main.c b/main/main.cpp similarity index 58% rename from main/main.c rename to main/main.cpp index a4ef2ee..d57ebb7 100644 --- a/main/main.c +++ b/main/main.cpp @@ -1,14 +1,5 @@ -#include "freertos/idf_additions.h" -#include "setup.h" - -void app_task(void *param) -{ - setup(); - while (1) - { - loop(); - } -} +#include "app_task.h" +#include "freertos/FreeRTOS.h" #ifdef __cplusplus extern "C"