starting MCU development

Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
2025-06-15 17:25:53 +02:00
parent 9806d4c9ae
commit 1c7942384b
7 changed files with 21 additions and 23 deletions

View File

@@ -10,6 +10,9 @@ if (DEFINED ENV{IDF_PATH})
src/ui/SettingsMenu.cpp src/ui/SettingsMenu.cpp
src/ui/SplashScreen.cpp src/ui/SplashScreen.cpp
INCLUDE_DIRS "include" INCLUDE_DIRS "include"
PRIV_REQUIRES
ruth
u8g2
) )
return() return()
endif () endif ()

View File

@@ -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) // 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, MenuItem::MenuItem(const uint8_t id, const uint8_t type, std::string text, std::string value, ButtonCallback callback)
ButtonCallback callback)
: m_id(id), m_type(type), m_text(std::move(text)), m_value(std::move(value)), m_callback(std::move(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 // Create a copy of this menu item with a new selected index
MenuItem copy = *this; MenuItem copy = *this;
// Check for potential overflow when converting size_t to int // Check for potential overflow when converting size_t to int
if (index > std::numeric_limits<int>::max())
{
throw std::overflow_error("index is too large");
}
copy.m_index = static_cast<int>(index); copy.m_index = static_cast<int>(index);
return copy; return copy;
} }

View File

@@ -17,7 +17,7 @@ LightSettingsMenu::LightSettingsMenu(menu_options_t *options) : Menu(options), m
{ {
values.emplace_back(std::to_string(i)); values.emplace_back(std::to_string(i));
} }
// Add section counter selection (allows choosing number of sections) // Add section counter selection (allows choosing number of sections)
addSelection(LightSettingsMenuItem::SECTION_COUNTER, "Sektionen", values, 7); 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) if (m_options && m_options->persistence && m_options->persistence->save)
{ {
const auto key = "section_" + std::to_string(menuItem.getId()); 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()); m_options->persistence->save(key.c_str(), value.c_str());
} }
} }

View File

@@ -1,7 +1,6 @@
idf_component_register(SRCS idf_component_register(SRCS
"main.c" "main.cpp"
"setup.c" "app_task.cpp"
"button_handling.c"
INCLUDE_DIRS "." INCLUDE_DIRS "."
REQUIRES REQUIRES
insa insa

7
main/app_task.cpp Normal file
View File

@@ -0,0 +1,7 @@
#include "app_task.h"
#include "ui/SplashScreen.h"
void app_task(void *args)
{
///
}

3
main/app_task.h Normal file
View File

@@ -0,0 +1,3 @@
#pragma once
void app_task(void *args);

View File

@@ -1,14 +1,5 @@
#include "freertos/idf_additions.h" #include "app_task.h"
#include "setup.h" #include "freertos/FreeRTOS.h"
void app_task(void *param)
{
setup();
while (1)
{
loop();
}
}
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"