Lamp-Da
0.1
A compact lantern project
Loading...
Searching...
No Matches
src
system
logic
button_bindings.h
Go to the documentation of this file.
1
12
#ifndef BUTTON_BINDINGS_H
13
#define BUTTON_BINDINGS_H
14
15
#include <cstddef>
16
#include <cstdint>
17
18
namespace
lampda
{
19
namespace
logic {
21
namespace
button_bindings {
22
24
enum class
Behavior
: uint8_t
25
{
26
Favorite
,
27
QuickNavigation
,
28
Sunset
,
29
CustomRamp
,
30
Indicator
,
31
Scroll
,
32
None
,
33
};
34
36
static
constexpr
size_t
behaviorCount
=
static_cast<
size_t
>
(
Behavior::None
);
37
39
static
constexpr
uint8_t
maxClicks
= 9;
40
42
enum class
SetResult
: uint8_t
43
{
44
Success
,
45
UnsupportedBehavior
,
46
ReservedClicks
,
47
SwapNotPossible
,
48
};
49
51
Behavior
get_click_behavior
(
const
uint8_t clicks);
52
54
Behavior
get_hold_behavior
(
const
uint8_t clicks);
55
57
uint8_t
get_clicks
(
const
Behavior
behavior);
58
60
uint8_t
get_min_clicks
(
const
Behavior
behavior);
61
63
bool
is_supported
(
const
Behavior
behavior);
64
66
const
char
*
get_name
(
const
Behavior
behavior);
67
73
Behavior
get_behavior_from_name
(
const
char
* name);
74
84
SetResult
set_binding
(
const
Behavior
behavior,
const
uint8_t clicks);
85
87
void
reset_to_defaults
();
88
90
void
load_from_memory
();
91
93
void
write_to_memory
();
94
95
}
// namespace button_bindings
96
}
// namespace logic
97
}
// namespace lampda
98
99
#endif
lampda::logic::button_bindings::get_behavior_from_name
Behavior get_behavior_from_name(const char *name)
Find a behavior from its command line name.
Definition:
button_bindings.cpp:132
lampda::logic::button_bindings::set_binding
SetResult set_binding(const Behavior behavior, const uint8_t clicks)
Link a behavior to a click count.
Definition:
button_bindings.cpp:142
lampda::logic::button_bindings::get_clicks
uint8_t get_clicks(const Behavior behavior)
Return the click count linked to this behavior, or 0 if this lamp type does not have this behavior.
Definition:
button_bindings.cpp:125
lampda::logic::button_bindings::SetResult
SetResult
Result of a binding change.
Definition:
button_bindings.h:43
lampda::logic::button_bindings::SetResult::Success
@ Success
the binding was changed
lampda::logic::button_bindings::SetResult::ReservedClicks
@ ReservedClicks
this click count is outside of [get_min_clicks(behavior), maxClicks]
lampda::logic::button_bindings::SetResult::UnsupportedBehavior
@ UnsupportedBehavior
this lamp type does not have this behavior
lampda::logic::button_bindings::SetResult::SwapNotPossible
@ SwapNotPossible
a behavior on this click count cannot use the click count of this behavior
lampda::logic::button_bindings::reset_to_defaults
void reset_to_defaults()
Restore the default links.
Definition:
button_bindings.cpp:168
lampda::logic::button_bindings::behaviorCount
static constexpr size_t behaviorCount
Number of configurable behaviors.
Definition:
button_bindings.h:36
lampda::logic::button_bindings::get_click_behavior
Behavior get_click_behavior(const uint8_t clicks)
Return the behavior whose click action is linked to this click count, or Behavior::None.
Definition:
button_bindings.cpp:103
lampda::logic::button_bindings::get_name
const char * get_name(const Behavior behavior)
Return the name of this behavior, as used by the command line.
Definition:
button_bindings.cpp:127
lampda::logic::button_bindings::write_to_memory
void write_to_memory()
Store the links in the user parameters.
Definition:
button_bindings.cpp:188
lampda::logic::button_bindings::load_from_memory
void load_from_memory()
Load the links from the user parameters. Missing or incoherent values give the default links.
Definition:
button_bindings.cpp:170
lampda::logic::button_bindings::Behavior
Behavior
Default behaviors that can be linked to a click count.
Definition:
button_bindings.h:25
lampda::logic::button_bindings::Behavior::Favorite
@ Favorite
click: jump to the favorites. hold: add or remove a favorite
lampda::logic::button_bindings::Behavior::Scroll
@ Scroll
hold: scroll across modes and groups
lampda::logic::button_bindings::Behavior::QuickNavigation
@ QuickNavigation
click: jump to the first mode
lampda::logic::button_bindings::Behavior::Indicator
@ Indicator
click: next indicator brightness. hold: cycle the indicator brightness
lampda::logic::button_bindings::Behavior::None
@ None
no behavior, keep this value last
lampda::logic::button_bindings::Behavior::Sunset
@ Sunset
hold: start or extend the sunset timer
lampda::logic::button_bindings::Behavior::CustomRamp
@ CustomRamp
hold: configure the custom ramp of the mode
lampda::logic::button_bindings::get_min_clicks
uint8_t get_min_clicks(const Behavior behavior)
Return the lowest click count this behavior can be linked to.
Definition:
button_bindings.cpp:69
lampda::logic::button_bindings::is_supported
bool is_supported(const Behavior behavior)
Return true if this lamp type has this behavior.
Definition:
button_bindings.cpp:80
lampda::logic::button_bindings::maxClicks
static constexpr uint8_t maxClicks
Highest click count a behavior can be linked to.
Definition:
button_bindings.h:39
lampda::logic::button_bindings::get_hold_behavior
Behavior get_hold_behavior(const uint8_t clicks)
Return the behavior whose hold action is linked to this click count, or Behavior::None.
Definition:
button_bindings.cpp:114
lampda
Program scope.
Definition:
control_fixed_modes.hpp:14
Generated by
1.9.6