NanoLux (Device) 3.0
Codebase for the open-source AudioLux device.
Loading...
Searching...
No Matches
storage.cpp File Reference
#include <string>
#include <Preferences.h>
#include "storage.h"
#include "nanolux_util.h"

Macros

#define PATTERN_NAMESPACE   "p"
 
#define PATTERN_KEY   "k"
 
#define CONFIG_NAMESPACE   "c"
 
#define CONFIG_KEY   "f"
 

Functions

void clear_nvs ()
 Clears the NVS namespace associated with saved patterns.
 
void bound_user_data ()
 Ensures all saved pattern data is properly constrained.
 
void bound_system_settings ()
 Ensures all saved user data is properly constrained.
 
void load_slot (int slot)
 Move patterns in a slot to the main buffer.
 
void set_slot (int slot)
 Saves the currently-loaded pattern to a save slot.
 
void save_to_nvs ()
 Saves all currently-loaded patterns to NVS.
 
void clear_all ()
 Clears all patterns stored in NVS.
 
void save_config_to_nvs ()
 Saves configuration data to the NVS.
 
void verify_saves ()
 Ensures that saved settings have reasonable data.
 
void load_from_nvs ()
 Load all patterns from the NVS.
 

Variables

Strip_Data loaded_patterns
 The currently strip configuration, externed from main.ino.
 
Strip_Data saved_patterns [NUM_SAVES]
 The array for storing saved strip configurations, externed from main.ino.
 
int NUM_PATTERNS
 The number of patterns that can be shown, externed from globals.h.
 
Preferences storage
 The object used to access Non-Volatile Storage. Reused between accesses.
 
Config_Data config
 The currently-loaded device config.
 

Detailed Description

The functions and objects in this file manage patterns saved to the device.

The AudioLux uses the ESP32's Prefrences library to interface with Non-Volatile Storage, or NVS.

Function Documentation

◆ bound_system_settings()

void bound_system_settings ( )

Ensures all saved user data is properly constrained.

This function should not be called by itself.

◆ bound_user_data()

void bound_user_data ( )

Ensures all saved pattern data is properly constrained.

Constrains both pattern and strip level settings. This function should not be called by itself.

◆ clear_all()

void clear_all ( )

Clears all patterns stored in NVS.

This function also clears all patterns saved in volatile storage as well.

◆ clear_nvs()

void clear_nvs ( )

Clears the NVS namespace associated with saved patterns.

This function should not be called by itself.

◆ load_from_nvs()

void load_from_nvs ( )

Load all patterns from the NVS.

Ensures all loaded data is properly bounded.

◆ load_slot()

void load_slot ( int slot)

Move patterns in a slot to the main buffer.

Parameters
slotThe save slot number to load from.

◆ save_config_to_nvs()

void save_config_to_nvs ( )

Saves configuration data to the NVS.

Bounds currently-loaded settings before saving to NVS.

◆ save_to_nvs()

void save_to_nvs ( )

Saves all currently-loaded patterns to NVS.

This does not save the currently-loaded pattern.

◆ set_slot()

void set_slot ( int slot)

Saves the currently-loaded pattern to a save slot.

Parameters
slotThe save slot to overwrite.

◆ verify_saves()

void verify_saves ( )

Ensures that saved settings have reasonable data.

TODO: Is this function even needed anymore?

Variable Documentation

◆ config

Config_Data config
extern

The currently-loaded device config.

The current config of the device, defined in main.ino. Used to check if serial printing is allowed.

◆ loaded_patterns

Strip_Data loaded_patterns
extern

The currently strip configuration, externed from main.ino.

The currently strip configuration, externed from main.ino.

◆ saved_patterns

Strip_Data saved_patterns[NUM_SAVES]
extern

The array for storing saved strip configurations, externed from main.ino.

The array for storing saved strip configurations, externed from main.ino.