Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
user_commands.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <array>
9#include <cstdint>
10
12
13#include "src/system/component/time_handling.h"
14
15namespace lampda {
16namespace common {
17
21{
22public:
24 enum class Type
25 {
26 Invalid,
29 SetMode,
30 OnOff,
35 };
36 static constexpr uint8_t maxDataSize = 8;
37
38 Type get_type() const { return _type; }
39
45 static UserCommand make_set_ramp_command(const uint8_t ramp);
46
52 static UserCommand make_brightness_command(const brightness_t brightness);
53
60 static UserCommand make_set_mode_command(const uint8_t groupId, const uint8_t modeId);
61
67 static UserCommand make_turn_onoff_command(const bool shouldTurnOn);
68
75
82
90 static UserCommand make_set_ble_custom_color_mode_command(const uint8_t red, const uint8_t green, const uint8_t blue);
91
97 static UserCommand make_set_ble_mode_command(const uint8_t index);
98
110 bool parse_ramp(uint8_t& ramp) const;
111
117 bool parse_brightness(brightness_t& brightness) const;
118
125 bool parse_set_mode(uint8_t& groupId, uint8_t& modeId) const;
126
132 bool parse_turn_onoff(bool& shouldTurnOn) const;
133
140
147
153 bool parse_set_ble_custom_color_mode_command(uint32_t& color) const;
154
160 bool parse_set_ble_mode_command(uint8_t& index) const;
161
162protected:
164 UserCommand();
165
166private:
167 Type _type;
168 uint8_t _dataCnt;
169 std::array<uint8_t, maxDataSize> _data;
170};
171
172} // namespace common
173} // namespace lampda
Define a command destined to the user layer. Command can only be created by the static make_* methods...
Definition: user_commands.h:21
static UserCommand make_set_mode_command(const uint8_t groupId, const uint8_t modeId)
Set this commant to handle mode switch.
Definition: user_commands.cpp:29
bool parse_set_sunset_to_time_command(component::time::RealTime &time) const
Parse the current command for a set sunset to time value.
Definition: user_commands.cpp:155
bool parse_set_mode(uint8_t &groupId, uint8_t &modeId) const
Parse the current command for a set_mode values.
Definition: user_commands.cpp:122
bool parse_ramp(uint8_t &ramp) const
Parse the current command for a ramp value.
Definition: user_commands.cpp:100
bool parse_set_ble_mode_command(uint8_t &index) const
Parse the current command for a set current mode to BLE mode.
Definition: user_commands.cpp:180
static UserCommand make_set_ramp_command(const uint8_t ramp)
Set this commant to handle user ramp change.
Definition: user_commands.cpp:10
static UserCommand make_set_sunset_to_time_command(const component::time::RealTime &time)
Set this commant to set sunset to real time.
Definition: user_commands.cpp:60
Type
Command type.
Definition: user_commands.h:25
@ SetSunsetToTime
set the sunset to a target real time
@ SetRealTime
set the system real time
@ SetBleMode
switch to a target BLE mode
@ Invalid
invalid placeholder message
@ SetBleCustomColorMode
switch to BLE custom color mode
@ SetUserRamp
set the user ramp value
static UserCommand make_set_real_time_command(const component::time::RealTime &time)
Set this commant to set system real time.
Definition: user_commands.cpp:48
bool parse_brightness(brightness_t &brightness) const
Parse the current command for a brightness value.
Definition: user_commands.cpp:108
bool parse_turn_onoff(bool &shouldTurnOn) const
Parse the current command for a on/off value.
Definition: user_commands.cpp:131
bool parse_set_ble_custom_color_mode_command(uint32_t &color) const
Parse the current command for a set current mode to BLE custom color.
Definition: user_commands.cpp:171
UserCommand()
Protected constructor to prevent unallowed uses.
Definition: user_commands.cpp:8
static UserCommand make_set_ble_mode_command(const uint8_t index)
Set this commant to set ble mode.
Definition: user_commands.cpp:85
static UserCommand make_brightness_command(const brightness_t brightness)
Set this commant to handle brightness.
Definition: user_commands.cpp:19
static UserCommand make_turn_onoff_command(const bool shouldTurnOn)
Set this commant to handle turn on/off.
Definition: user_commands.cpp:39
static UserCommand make_set_ble_custom_color_mode_command(const uint8_t red, const uint8_t green, const uint8_t blue)
Set this commant to set ble custom color.
Definition: user_commands.cpp:72
bool parse_set_real_time_command(component::time::RealTime &time) const
Parse the current command for a set real time value.
Definition: user_commands.cpp:139
Program scope.
Definition: control_fixed_modes.hpp:12
uint16_t brightness_t
Define the type of the brightness parameters.
Definition: constants.h:147
Store a real time reference.
Definition: time_handling.h:18
Define the system hardware constants.