AwesomeStudioPedal
A programmable, multi-profile foot controller for DAWs, score readers, and studio automation
Loading...
Searching...
No Matches
config_loader.h
Go to the documentation of this file.
1#pragma once
2#include "action.h"
3#include "button_constants.h"
4#include "file_system.h"
5#include "i_ble_keyboard.h"
6#include "i_logger.h"
7#include "profile_manager.h"
8#include <ArduinoJson.h>
9#include <string>
10
19{
20public:
23
25 ConfigLoader(IFileSystem* fs, ILogger* logger);
26
28 IBleKeyboard* keyboard,
29 const std::string& configPath);
31 IBleKeyboard* keyboard,
32 const std::string& jsonConfig);
33 bool saveToFile(const ProfileManager& profileManager, const std::string& configPath);
35 IBleKeyboard* keyboard,
36 const std::string& jsonConfig);
38 IBleKeyboard* keyboard,
39 uint8_t profileIndex,
40 const std::string& jsonConfig);
41
42 static const char* getDefaultConfig() { return DEFAULT_CONFIG; }
43
44 static uint8_t getButtonIndex(const char* buttonName);
45
46private:
47 static const char* DEFAULT_CONFIG;
48
49 IFileSystem* fileSystem_;
50 ILogger* logger_;
51
52 std::unique_ptr<Action> createActionFromJson(const ArduinoJson::JsonObject& actionJson,
53 IBleKeyboard* keyboard);
54 std::unique_ptr<Action> createSendCharActionFromJson(const ArduinoJson::JsonObject& actionJson,
55 IBleKeyboard* keyboard);
56 static void actionToJson(const Action* action, ArduinoJson::JsonObject& out);
57 void populateProfileFromJson(Profile& profile,
58 ArduinoJson::JsonObject buttons,
59 IBleKeyboard* keyboard);
60 void logLoadedConfig(const ProfileManager& profileManager) const;
61 bool profileExistsByName(const ProfileManager& profileManager, const char* name) const;
62 static uint8_t findEmptyProfileSlot(const ProfileManager& profileManager);
63};
Base class for all pedal actions.
Definition action.h:12
Loads pedal configuration from JSON files.
bool replaceProfile(ProfileManager &profileManager, IBleKeyboard *keyboard, uint8_t profileIndex, const std::string &jsonConfig)
Replaces a specific profile with configuration from JSON.
bool mergeConfig(ProfileManager &profileManager, IBleKeyboard *keyboard, const std::string &jsonConfig)
Merges configuration from JSON into existing profiles.
static uint8_t getButtonIndex(const char *buttonName)
Converts button name to button index.
ConfigLoader()
Default constructor: uses production singletons (firmware path)
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.
static const char * getDefaultConfig()
Interface for Bluetooth LE keyboard functionality.
Abstract interface for file system operations.
Definition file_system.h:12
Interface for logging functionality.
Definition i_logger.h:11
Manages up to MAX_PROFILES profiles with LED feedback.
Represents a single button configuration profile.
Definition profile.h:15
ProfileManager * profileManager
Definition main.cpp:72