Refactored settingsutils
This commit is contained in:
@ -0,0 +1,45 @@
|
|||||||
|
#include "settingsutils.h"
|
||||||
|
|
||||||
|
// esp-idf includes
|
||||||
|
#include <esp_log.h>
|
||||||
|
|
||||||
|
// local includes
|
||||||
|
#include "globals.h"
|
||||||
|
#include "presets.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
void switchProfile(uint8_t index)
|
||||||
|
{
|
||||||
|
#ifdef SIMPLIFIED_TRIGGER_TRIGGERONPRESET
|
||||||
|
if (index == SIMPLIFIED_TRIGGER_TRIGGERONPRESET)
|
||||||
|
{
|
||||||
|
simplified = true;
|
||||||
|
#ifdef SETTINGSUTILS_PLUGIN
|
||||||
|
#include SETTINGSUTILS_PLUGIN
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
settings = presets::defaultSettings;
|
||||||
|
stringSettings = presets::makeDefaultStringSettings();
|
||||||
|
|
||||||
|
if (!settingsPersister.openProfile(index))
|
||||||
|
{
|
||||||
|
ESP_LOGE("BOBBY", "openProfile() failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!settingsPersister.load(settings))
|
||||||
|
{
|
||||||
|
ESP_LOGE("BOBBY", "load() for settings failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!settingsPersister.load(stringSettings))
|
||||||
|
{
|
||||||
|
ESP_LOGE("BOBBY", "load() for stringSettings failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
@ -1,45 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// esp-idf includes
|
#include <cstdint>
|
||||||
#include <esp_log.h>
|
|
||||||
|
|
||||||
// local includes
|
|
||||||
#include "globals.h"
|
|
||||||
#include "presets.h"
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void switchProfile(uint8_t index)
|
void switchProfile(uint8_t index);
|
||||||
{
|
|
||||||
#ifdef SIMPLIFIED_TRIGGER_TRIGGERONPRESET
|
|
||||||
if (index == SIMPLIFIED_TRIGGER_TRIGGERONPRESET)
|
|
||||||
{
|
|
||||||
simplified = true;
|
|
||||||
#ifdef SETTINGSUTILS_PLUGIN
|
|
||||||
#include SETTINGSUTILS_PLUGIN
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
settings = presets::defaultSettings;
|
|
||||||
stringSettings = presets::makeDefaultStringSettings();
|
|
||||||
|
|
||||||
if (!settingsPersister.openProfile(index))
|
|
||||||
{
|
|
||||||
ESP_LOGE("BOBBY", "openProfile() failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!settingsPersister.load(settings))
|
|
||||||
{
|
|
||||||
ESP_LOGE("BOBBY", "load() for settings failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!settingsPersister.load(stringSettings))
|
|
||||||
{
|
|
||||||
ESP_LOGE("BOBBY", "load() for stringSettings failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user