Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Namespaces | Enumerations | Functions | Variables
button_bindings.h File Reference

User configurable links between click counts and default behaviors. More...

Go to the source code of this file.

Namespaces

namespace  lampda
 Program scope.
 
namespace  lampda::logic
 Handle the main high level logics.
 
namespace  lampda::logic::button_bindings
 Handle the links between click counts and the configurable default behaviors.
 

Enumerations

enum class  lampda::logic::button_bindings::Behavior : uint8_t {
  lampda::logic::button_bindings::Favorite , lampda::logic::button_bindings::QuickNavigation , lampda::logic::button_bindings::Sunset , lampda::logic::button_bindings::CustomRamp ,
  lampda::logic::button_bindings::Indicator , lampda::logic::button_bindings::Scroll , lampda::logic::button_bindings::None
}
 Default behaviors that can be linked to a click count. More...
 
enum class  lampda::logic::button_bindings::SetResult : uint8_t { lampda::logic::button_bindings::Success , lampda::logic::button_bindings::UnsupportedBehavior , lampda::logic::button_bindings::ReservedClicks , lampda::logic::button_bindings::SwapNotPossible }
 Result of a binding change. More...
 

Functions

Behavior lampda::logic::button_bindings::get_click_behavior (const uint8_t clicks)
 Return the behavior whose click action is linked to this click count, or Behavior::None.
 
Behavior lampda::logic::button_bindings::get_hold_behavior (const uint8_t clicks)
 Return the behavior whose hold action is linked to this click count, or Behavior::None.
 
uint8_t lampda::logic::button_bindings::get_clicks (const Behavior behavior)
 Return the click count linked to this behavior, or 0 if this lamp type does not have this behavior.
 
uint8_t lampda::logic::button_bindings::get_min_clicks (const Behavior behavior)
 Return the lowest click count this behavior can be linked to.
 
bool lampda::logic::button_bindings::is_supported (const Behavior behavior)
 Return true if this lamp type has this behavior.
 
const char * lampda::logic::button_bindings::get_name (const Behavior behavior)
 Return the name of this behavior, as used by the command line.
 
Behavior lampda::logic::button_bindings::get_behavior_from_name (const char *name)
 Find a behavior from its command line name.
 
SetResult lampda::logic::button_bindings::set_binding (const Behavior behavior, const uint8_t clicks)
 Link a behavior to a click count.
 
void lampda::logic::button_bindings::reset_to_defaults ()
 Restore the default links.
 
void lampda::logic::button_bindings::load_from_memory ()
 Load the links from the user parameters. Missing or incoherent values give the default links.
 
void lampda::logic::button_bindings::write_to_memory ()
 Store the links in the user parameters.
 

Variables

static constexpr size_t lampda::logic::button_bindings::behaviorCount = static_cast<size_t>(Behavior::None)
 Number of configurable behaviors.
 
static constexpr uint8_t lampda::logic::button_bindings::maxClicks = 9
 Highest click count a behavior can be linked to.
 

Detailed Description

User configurable links between click counts and default behaviors.

The click action (NC) and the hold action (NH) of a behavior always move together, so that a binding change cannot split a behavior between two click counts. Two behaviors can share a click count if they do not use the same action, like the quick navigation (click only) and the scroll (hold only).

Click counts 1 and 2 (on/off, next mode, brightness) and 10 and above (shutdown, resets) cannot be configured. 3 clicks is always the group navigation, so only the behaviors without a click action can use 3 clicks.