AwesomeStudioPedal
A programmable, multi-profile foot controller for DAWs, score readers, and studio automation
Loading...
Searching...
No Matches
pedal_config.cpp
Go to the documentation of this file.
1#include "pedal_config.h"
2#include "action.h"
3#include "button_constants.h"
4#include "config_loader.h"
5#include "profile.h"
6#include "send_action.h"
7#include "serial_action.h"
8#include <memory>
9
17{
18 ConfigLoader configLoader;
19
20 if (configLoader.loadFromFile(profileManager, keyboard, "/profiles.json"))
21 {
22 return true;
23 }
24
25 // File missing or invalid — load the hardcoded default
26 if (! configLoader.loadFromString(profileManager, keyboard, ConfigLoader::getDefaultConfig()))
27 {
28 // DEFAULT_CONFIG failed to parse: this is a compile-time bug, not a runtime error
29 return false;
30 }
31
32 // Persist the default so future boots load from file
33 configLoader.saveToFile(profileManager, "/profiles.json");
34 return true;
35}
Loads pedal configuration from JSON files.
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.
Manages up to MAX_PROFILES profiles with LED feedback.
ProfileManager * profileManager
Definition main.cpp:72
bool configureProfiles(ProfileManager &profileManager, IBleKeyboard *keyboard)
Load profiles from file; fall back to DEFAULT_CONFIG on failure.