refactor persistence manager from cpp to c
Some checks failed
ESP-IDF Build / build (esp32c6, release-v5.4) (push) Failing after 4m12s
ESP-IDF Build / build (esp32c6, release-v5.5) (push) Failing after 4m17s
ESP-IDF Build / build (esp32s3, release-v5.4) (push) Failing after 3m49s
ESP-IDF Build / build (esp32s3, release-v5.5) (push) Failing after 4m0s
Some checks failed
ESP-IDF Build / build (esp32c6, release-v5.4) (push) Failing after 4m12s
ESP-IDF Build / build (esp32c6, release-v5.5) (push) Failing after 4m17s
ESP-IDF Build / build (esp32s3, release-v5.4) (push) Failing after 3m49s
ESP-IDF Build / build (esp32s3, release-v5.5) (push) Failing after 4m0s
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
// Project-specific headers
|
||||
#include "common/Widget.h"
|
||||
#include "IPersistenceManager.h"
|
||||
#include "persistence_manager.h"
|
||||
#include "u8g2.h"
|
||||
|
||||
class MenuItem;
|
||||
@@ -28,7 +28,7 @@ class MenuItem;
|
||||
* @details This structure serves as a configuration container that provides menu widgets
|
||||
* with access to the display system, screen management functions, input
|
||||
* handling callbacks, and persistent storage.
|
||||
*
|
||||
*
|
||||
* @see Widget
|
||||
* @see ButtonType
|
||||
* @see IPersistenceManager
|
||||
@@ -61,14 +61,8 @@ typedef struct
|
||||
std::function<void(ButtonType button)> onButtonClicked;
|
||||
|
||||
/**
|
||||
* @brief Shared pointer to platform-independent persistence manager
|
||||
* @details This provides access to persistent key-value storage across different
|
||||
* platforms. The actual implementation (SDL3 or ESP32/NVS) is determined
|
||||
* at compile time based on the target platform.
|
||||
*
|
||||
* @note The persistence manager is shared across all menu widgets and maintains
|
||||
* its state throughout the application lifecycle.
|
||||
* @brief Zeiger auf C-Persistence-Manager-Instanz
|
||||
*/
|
||||
std::shared_ptr<IPersistenceManager> persistenceManager;
|
||||
persistence_manager_t *persistenceManager;
|
||||
|
||||
} menu_options_t;
|
||||
@@ -64,7 +64,7 @@ void Menu::setItemSize(const size_t size, int8_t startIndex)
|
||||
constexpr int key_length = 20;
|
||||
char key[key_length] = "";
|
||||
snprintf(key, key_length, "section_%zu", i + 1 - startIndex);
|
||||
index = m_options->persistenceManager->GetValue(key, index);
|
||||
index = persistence_manager_get_int(m_options->persistenceManager, key, index);
|
||||
}
|
||||
addSelection(i + 1, caption, m_items.at(0).getValues(), index);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "ui/ClockScreenSaver.h"
|
||||
#include "hal_esp32/PersistenceManager.h"
|
||||
#include "persistence_manager.h"
|
||||
#include "simulator.h"
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
@@ -38,8 +38,9 @@ void ClockScreenSaver::updateTextDimensions()
|
||||
|
||||
void ClockScreenSaver::getCurrentTimeString(char *buffer, size_t bufferSize) const
|
||||
{
|
||||
if (m_options && m_options->persistenceManager->GetValue("light_active", false) &&
|
||||
m_options->persistenceManager->GetValue("light_mode", 0) == 0)
|
||||
if (m_options && m_options->persistenceManager &&
|
||||
persistence_manager_get_bool(m_options->persistenceManager, "light_active", false) &&
|
||||
persistence_manager_get_int(m_options->persistenceManager, "light_mode", 0) == 0)
|
||||
{
|
||||
char *simulated_time = get_time();
|
||||
if (simulated_time != nullptr)
|
||||
|
||||
@@ -27,7 +27,7 @@ LightMenu::LightMenu(menu_options_t *options) : Menu(options), m_options(options
|
||||
bool active = false;
|
||||
if (m_options && m_options->persistenceManager)
|
||||
{
|
||||
active = m_options->persistenceManager->GetValue(LightMenuOptions::LIGHT_ACTIVE, active);
|
||||
active = persistence_manager_get_bool(m_options->persistenceManager, LightMenuOptions::LIGHT_ACTIVE, active);
|
||||
}
|
||||
addToggle(LightMenuItem::ACTIVATE, "Einschalten", active);
|
||||
|
||||
@@ -39,7 +39,8 @@ LightMenu::LightMenu(menu_options_t *options) : Menu(options), m_options(options
|
||||
int mode_value = 0;
|
||||
if (m_options && m_options->persistenceManager)
|
||||
{
|
||||
mode_value = m_options->persistenceManager->GetValue(LightMenuOptions::LIGHT_MODE, mode_value);
|
||||
mode_value =
|
||||
persistence_manager_get_int(m_options->persistenceManager, LightMenuOptions::LIGHT_MODE, mode_value);
|
||||
}
|
||||
addSelection(LightMenuItem::MODE, "Modus", items, mode_value);
|
||||
|
||||
@@ -50,7 +51,9 @@ LightMenu::LightMenu(menu_options_t *options) : Menu(options), m_options(options
|
||||
int variant_value = 3;
|
||||
if (m_options && m_options->persistenceManager)
|
||||
{
|
||||
variant_value = m_options->persistenceManager->GetValue(LightMenuOptions::LIGHT_VARIANT, variant_value) - 1;
|
||||
variant_value =
|
||||
persistence_manager_get_int(m_options->persistenceManager, LightMenuOptions::LIGHT_VARIANT, variant_value) -
|
||||
1;
|
||||
}
|
||||
addSelection(LightMenuItem::VARIANT, "Variante", variants, variant_value);
|
||||
}
|
||||
@@ -70,7 +73,7 @@ void LightMenu::onButtonPressed(const MenuItem &menuItem, const ButtonType butto
|
||||
const auto value = getItem(menuItem.getId()).getValue() == "1";
|
||||
if (m_options && m_options->persistenceManager)
|
||||
{
|
||||
m_options->persistenceManager->SetValue(LightMenuOptions::LIGHT_ACTIVE, value);
|
||||
persistence_manager_set_bool(m_options->persistenceManager, LightMenuOptions::LIGHT_ACTIVE, value);
|
||||
}
|
||||
|
||||
start_simulation();
|
||||
@@ -86,8 +89,8 @@ void LightMenu::onButtonPressed(const MenuItem &menuItem, const ButtonType butto
|
||||
const auto value = getItem(item.getId()).getIndex();
|
||||
if (m_options && m_options->persistenceManager)
|
||||
{
|
||||
m_options->persistenceManager->SetValue(LightMenuOptions::LIGHT_MODE, value);
|
||||
m_options->persistenceManager->Save();
|
||||
persistence_manager_set_int(m_options->persistenceManager, LightMenuOptions::LIGHT_MODE, value);
|
||||
persistence_manager_save(m_options->persistenceManager);
|
||||
}
|
||||
|
||||
start_simulation();
|
||||
@@ -103,8 +106,8 @@ void LightMenu::onButtonPressed(const MenuItem &menuItem, const ButtonType butto
|
||||
const auto value = getItem(item.getId()).getIndex() + 1;
|
||||
if (m_options && m_options->persistenceManager)
|
||||
{
|
||||
m_options->persistenceManager->SetValue(LightMenuOptions::LIGHT_VARIANT, value);
|
||||
m_options->persistenceManager->Save();
|
||||
persistence_manager_set_int(m_options->persistenceManager, LightMenuOptions::LIGHT_VARIANT, value);
|
||||
persistence_manager_save(m_options->persistenceManager);
|
||||
}
|
||||
|
||||
start_simulation();
|
||||
|
||||
Reference in New Issue
Block a user