mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-21 20:51:00 +00:00

* chore: todo.txt * chore: comments * fix: no fast refresh on VME290 Reverts a line of code which was accidentally committed * refactor: god class Divide the behavior from the old WindowManager class into several subclasses which each have a clear role. * refactor: cppcheck medium warnings Enough to pass github CI for now * refactor: updateType selection * refactor: don't use a setter for the shared AppletFonts * fix: update prioritization forceUpdate calls weren't being prioritized * refactor: remove unhelpful logging getTimeString is used for parsing our own time, but also the timestamps of messages. The "one time only" log printing will likely fire in unhelpful situations. * fix: " " * refactor: get rid of types.h file for enums * Keep that sneaky todo file out of commits
83 lines
3.4 KiB
C++
83 lines
3.4 KiB
C++
#ifdef MESHTASTIC_INCLUDE_INKHUD
|
|
|
|
#include "./Persistence.h"
|
|
|
|
using namespace NicheGraphics;
|
|
|
|
// Load settings and latestMessage data
|
|
void InkHUD::Persistence::loadSettings()
|
|
{
|
|
// Load the InkHUD settings from flash, and check version number
|
|
// We should only consider the version number if the InkHUD flashdata component reports that we *did* actually load flash data
|
|
Settings loadedSettings;
|
|
bool loadSucceeded = FlashData<Settings>::load(&loadedSettings, "settings");
|
|
if (loadSucceeded && loadedSettings.meta.version == SETTINGS_VERSION && loadedSettings.meta.version != 0)
|
|
settings = loadedSettings; // Version matched, replace the defaults with the loaded values
|
|
else
|
|
LOG_WARN("Settings version changed. Using defaults");
|
|
}
|
|
|
|
// Load settings and latestMessage data
|
|
void InkHUD::Persistence::loadLatestMessage()
|
|
{
|
|
// Load previous "latestMessages" data from flash
|
|
MessageStore store("latest");
|
|
store.loadFromFlash();
|
|
|
|
// Place into latestMessage struct, for convenient access
|
|
// Number of strings loaded determines whether last message was broadcast or dm
|
|
if (store.messages.size() == 1) {
|
|
latestMessage.dm = store.messages.at(0);
|
|
latestMessage.wasBroadcast = false;
|
|
} else if (store.messages.size() == 2) {
|
|
latestMessage.dm = store.messages.at(0);
|
|
latestMessage.broadcast = store.messages.at(1);
|
|
latestMessage.wasBroadcast = true;
|
|
}
|
|
}
|
|
|
|
// Save the InkHUD settings to flash
|
|
void InkHUD::Persistence::saveSettings()
|
|
{
|
|
FlashData<Settings>::save(&settings, "settings");
|
|
}
|
|
|
|
// Save latestMessage data to flash
|
|
void InkHUD::Persistence::saveLatestMessage()
|
|
{
|
|
// Number of strings saved determines whether last message was broadcast or dm
|
|
MessageStore store("latest");
|
|
store.messages.push_back(latestMessage.dm);
|
|
if (latestMessage.wasBroadcast)
|
|
store.messages.push_back(latestMessage.broadcast);
|
|
store.saveToFlash();
|
|
}
|
|
|
|
/*
|
|
void InkHUD::Persistence::printSettings(Settings *settings)
|
|
{
|
|
if (SETTINGS_VERSION != 2)
|
|
LOG_WARN("Persistence::printSettings was written for SETTINGS_VERSION=2, current is %d", SETTINGS_VERSION);
|
|
|
|
LOG_DEBUG("meta.version=%d", settings->meta.version);
|
|
LOG_DEBUG("userTiles.count=%d", settings->userTiles.count);
|
|
LOG_DEBUG("userTiles.maxCount=%d", settings->userTiles.maxCount);
|
|
LOG_DEBUG("userTiles.focused=%d", settings->userTiles.focused);
|
|
for (uint8_t i = 0; i < MAX_TILES_GLOBAL; i++)
|
|
LOG_DEBUG("userTiles.displayedUserApplet[%d]=%d", i, settings->userTiles.displayedUserApplet[i]);
|
|
for (uint8_t i = 0; i < MAX_USERAPPLETS_GLOBAL; i++)
|
|
LOG_DEBUG("userApplets.active[%d]=%d", i, settings->userApplets.active[i]);
|
|
for (uint8_t i = 0; i < MAX_USERAPPLETS_GLOBAL; i++)
|
|
LOG_DEBUG("userApplets.autoshow[%d]=%d", i, settings->userApplets.autoshow[i]);
|
|
LOG_DEBUG("optionalFeatures.notifications=%d", settings->optionalFeatures.notifications);
|
|
LOG_DEBUG("optionalFeatures.batteryIcon=%d", settings->optionalFeatures.batteryIcon);
|
|
LOG_DEBUG("optionalMenuItems.nextTile=%d", settings->optionalMenuItems.nextTile);
|
|
LOG_DEBUG("optionalMenuItems.backlight=%d", settings->optionalMenuItems.backlight);
|
|
LOG_DEBUG("tips.firstBoot=%d", settings->tips.firstBoot);
|
|
LOG_DEBUG("tips.safeShutdownSeen=%d", settings->tips.safeShutdownSeen);
|
|
LOG_DEBUG("rotation=%d", settings->rotation);
|
|
LOG_DEBUG("recentlyActiveSeconds=%d", settings->recentlyActiveSeconds);
|
|
}
|
|
*/
|
|
|
|
#endif |