|
AwesomeStudioPedal
A programmable, multi-profile foot controller for DAWs, score readers, and studio automation
|
Loads pedal configuration from JSON files. More...
#include <config_loader.h>
Public Member Functions | |
| ConfigLoader () | |
| Default constructor: uses production singletons (firmware path) | |
| ConfigLoader (IFileSystem *fs, ILogger *logger) | |
| Injection constructor: use in tests or wherever DI is needed. | |
| bool | loadFromFile (ProfileManager &profileManager, IBleKeyboard *keyboard, const std::string &configPath) |
| Loads configuration from a file. | |
| bool | loadFromString (ProfileManager &profileManager, IBleKeyboard *keyboard, const std::string &jsonConfig) |
| Loads configuration from a JSON string. | |
| bool | saveToFile (const ProfileManager &profileManager, const std::string &configPath) |
| Saves configuration to a file. | |
| bool | mergeConfig (ProfileManager &profileManager, IBleKeyboard *keyboard, const std::string &jsonConfig) |
| Merges configuration from JSON into existing profiles. | |
| bool | replaceProfile (ProfileManager &profileManager, IBleKeyboard *keyboard, uint8_t profileIndex, const std::string &jsonConfig) |
| Replaces a specific profile with configuration from JSON. | |
Static Public Member Functions | |
| static const char * | getDefaultConfig () |
| static uint8_t | getButtonIndex (const char *buttonName) |
| Converts button name to button index. | |
Loads pedal configuration from JSON files.
Responsible for parsing JSON configuration files and creating the appropriate Action objects to populate the ProfileManager.
Definition at line 18 of file config_loader.h.
| ConfigLoader::ConfigLoader | ( | ) |
Default constructor: uses production singletons (firmware path)
Default constructor.
Creates a ConfigLoader using production singletons for file system and logging. Used in firmware builds.
Definition at line 60 of file config_loader.cpp.
| ConfigLoader::ConfigLoader | ( | IFileSystem * | fs, |
| ILogger * | logger | ||
| ) |
Injection constructor: use in tests or wherever DI is needed.
Dependency injection constructor.
Creates a ConfigLoader with injected dependencies for testing or custom implementations.
| fs | File system implementation |
| logger | Logger implementation |
Definition at line 70 of file config_loader.cpp.
|
static |
Converts button name to button index.
| buttonName | The button name ("A", "B", "C", or "D") |
Definition at line 152 of file config_loader.cpp.
|
inlinestatic |
Definition at line 42 of file config_loader.h.
| bool ConfigLoader::loadFromFile | ( | ProfileManager & | profileManager, |
| IBleKeyboard * | keyboard, | ||
| const std::string & | configPath | ||
| ) |
Loads configuration from a file.
Reads the configuration file from the specified path and parses it using loadFromString().
| profileManager | The profile manager to populate with loaded profiles |
| keyboard | The BLE keyboard interface for creating keyboard actions |
| configPath | Path to the configuration file |
Definition at line 84 of file config_loader.cpp.
| bool ConfigLoader::loadFromString | ( | ProfileManager & | profileManager, |
| IBleKeyboard * | keyboard, | ||
| const std::string & | jsonConfig | ||
| ) |
Loads configuration from a JSON string.
Parses the JSON configuration and populates the profile manager with the defined profiles. Clears existing profiles before loading new ones.
| profileManager | The profile manager to populate |
| keyboard | The BLE keyboard interface for creating keyboard actions |
| jsonConfig | JSON string containing the configuration |
Definition at line 108 of file config_loader.cpp.
| bool ConfigLoader::mergeConfig | ( | ProfileManager & | profileManager, |
| IBleKeyboard * | keyboard, | ||
| const std::string & | jsonConfig | ||
| ) |
Merges configuration from JSON into existing profiles.
Adds new profiles from the JSON configuration to the profile manager, skipping any profiles that already exist by name. Only adds profiles to empty slots in the profile manager.
| profileManager | The profile manager to merge profiles into |
| keyboard | The BLE keyboard interface for creating keyboard actions |
| jsonConfig | JSON string containing profiles to merge |
Definition at line 49 of file config_loader_merge.cpp.
| bool ConfigLoader::replaceProfile | ( | ProfileManager & | profileManager, |
| IBleKeyboard * | keyboard, | ||
| uint8_t | profileIndex, | ||
| const std::string & | jsonConfig | ||
| ) |
Replaces a specific profile with configuration from JSON.
Parses the JSON configuration and replaces the profile at the specified index with the first profile found in the JSON. Validates the profile index before attempting replacement.
| profileManager | The profile manager containing the profile to replace |
| keyboard | The BLE keyboard interface for creating keyboard actions |
| profileIndex | Index of the profile to replace (0-3) |
| jsonConfig | JSON string containing the replacement profile |
Definition at line 108 of file config_loader_merge.cpp.
| bool ConfigLoader::saveToFile | ( | const ProfileManager & | profileManager, |
| const std::string & | configPath | ||
| ) |
Saves configuration to a file.
Serializes the current profile manager state to JSON and writes it to the specified file. Includes all profiles with their names, descriptions, and button action configurations.
| profileManager | The profile manager containing profiles to save |
| configPath | Path to the configuration file to write |
Definition at line 19 of file config_loader_io.cpp.