AwesomeStudioPedal
A programmable, multi-profile foot controller for DAWs, score readers, and studio automation
Loading...
Searching...
No Matches
ProfileManager Class Reference

Manages up to MAX_PROFILES profiles with LED feedback. More...

#include <profile_manager.h>

Public Member Functions

 ProfileManager (std::vector< ILEDController * > leds)
 
void addProfile (uint8_t profileIndex, std::unique_ptr< Profile > profile)
 
ActiongetAction (uint8_t profileIndex, uint8_t button) const
 
const ProfilegetProfile (uint8_t profileIndex) const
 
uint8_t switchProfile ()
 Advance to the next populated profile slot and trigger blink feedback.
 
uint8_t getCurrentProfile () const
 
void setCurrentProfile (uint8_t profileIndex)
 Directly set the current profile without triggering blink feedback.
 
const std::string & getProfileName (uint8_t profileIndex) const
 
void resetToFirstProfile ()
 Reset to the first populated slot (or slot 0 if all empty)
 
bool hasActiveDelayedAction () const
 Returns true if any DelayedAction across all profiles is currently running.
 
void update (uint32_t now)
 Drive timed LED behaviour — call every loop iteration.
 

Static Public Member Functions

static const char * getActionTypeString (Action::Type actionType)
 

Static Public Attributes

static constexpr uint8_t MAX_PROFILES = 63
 2^6 − 1 (6 select LEDs max)
 
static constexpr uint8_t MAX_SELECT_LEDS = 6
 

Detailed Description

Manages up to MAX_PROFILES profiles with LED feedback.

LED encoding (chosen at runtime based on numProfiles vs numSelectLeds):

  • One-hot mode (numProfiles <= numSelectLeds): Profile N lights LED N exclusively. Intuitive and direct.
  • Binary mode (numProfiles > numSelectLeds): The 1-based profile number is binary-encoded across all select LEDs. LED 1 = bit 0 (LSB), LED 2 = bit 1, etc.

Maximum profiles for a given wiring: 2^numSelectLeds − 1.

After a profile switch all select LEDs blink 3 times, then return to the encoding for the new profile. Drive this by calling update() every loop.

Definition at line 25 of file profile_manager.h.

Constructor & Destructor Documentation

◆ ProfileManager()

ProfileManager::ProfileManager ( std::vector< ILEDController * >  leds)
explicit
Parameters
ledsPointers to LED controllers for profile-select LEDs. Size must match hardwareConfig.numSelectLeds.

Definition at line 6 of file profile_manager.cpp.

Member Function Documentation

◆ addProfile()

void ProfileManager::addProfile ( uint8_t  profileIndex,
std::unique_ptr< Profile profile 
)

Definition at line 11 of file profile_manager.cpp.

◆ getAction()

Action * ProfileManager::getAction ( uint8_t  profileIndex,
uint8_t  button 
) const

Definition at line 19 of file profile_manager.cpp.

◆ getActionTypeString()

const char * ProfileManager::getActionTypeString ( Action::Type  actionType)
static

Definition at line 193 of file profile_manager.cpp.

◆ getCurrentProfile()

uint8_t ProfileManager::getCurrentProfile ( ) const
inline

Definition at line 51 of file profile_manager.h.

◆ getProfile()

const Profile * ProfileManager::getProfile ( uint8_t  profileIndex) const

Definition at line 28 of file profile_manager.cpp.

◆ getProfileName()

const std::string & ProfileManager::getProfileName ( uint8_t  profileIndex) const

Definition at line 163 of file profile_manager.cpp.

◆ hasActiveDelayedAction()

bool ProfileManager::hasActiveDelayedAction ( ) const

Returns true if any DelayedAction across all profiles is currently running.

Definition at line 173 of file profile_manager.cpp.

◆ resetToFirstProfile()

void ProfileManager::resetToFirstProfile ( )

Reset to the first populated slot (or slot 0 if all empty)

Called after loadFromString clears and repopulates all slots so that currentProfile is never left pointing at an empty slot.

Definition at line 147 of file profile_manager.cpp.

◆ setCurrentProfile()

void ProfileManager::setCurrentProfile ( uint8_t  profileIndex)

Directly set the current profile without triggering blink feedback.

Used to restore a saved profile on boot. Caller must ensure the profile slot is populated before calling.

Definition at line 138 of file profile_manager.cpp.

◆ switchProfile()

uint8_t ProfileManager::switchProfile ( )

Advance to the next populated profile slot and trigger blink feedback.

Skips empty slots and wraps around. Triggers a 3-blink sequence on all select LEDs; the LEDs return to the profile encoding after the sequence completes.

Returns
New current profile index

Definition at line 37 of file profile_manager.cpp.

◆ update()

void ProfileManager::update ( uint32_t  now)

Drive timed LED behaviour — call every loop iteration.

Parameters
nowCurrent time in milliseconds (millis())

Definition at line 96 of file profile_manager.cpp.

Member Data Documentation

◆ MAX_PROFILES

constexpr uint8_t ProfileManager::MAX_PROFILES = 63
staticconstexpr

2^6 − 1 (6 select LEDs max)

Definition at line 28 of file profile_manager.h.

◆ MAX_SELECT_LEDS

constexpr uint8_t ProfileManager::MAX_SELECT_LEDS = 6
staticconstexpr

Definition at line 29 of file profile_manager.h.


The documentation for this class was generated from the following files: