starting MCU development
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
@@ -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 ()
|
||||
|
@@ -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<int>::max())
|
||||
{
|
||||
throw std::overflow_error("index is too large");
|
||||
}
|
||||
copy.m_index = static_cast<int>(index);
|
||||
return copy;
|
||||
}
|
@@ -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());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user