Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
lampda::common::UserCommand Class Reference

Define a command destined to the user layer. Command can only be created by the static make_* methods. More...

#include <user_commands.h>

Public Types

enum class  Type {
  Invalid , SetUserRamp , Brightness , SetMode ,
  OnOff , SetRealTime , SetSunsetToTime , SetBleCustomColorMode ,
  SetBleMode
}
 Command type. More...
 

Public Member Functions

Type get_type () const
 
bool parse_ramp (uint8_t &ramp) const
 Parse the current command for a ramp value.
 
bool parse_brightness (brightness_t &brightness) const
 Parse the current command for a brightness value.
 
bool parse_set_mode (uint8_t &groupId, uint8_t &modeId) const
 Parse the current command for a set_mode values.
 
bool parse_turn_onoff (bool &shouldTurnOn) const
 Parse the current command for a on/off value.
 
bool parse_set_real_time_command (component::time::RealTime &time) const
 Parse the current command for a set real time value.
 
bool parse_set_sunset_to_time_command (component::time::RealTime &time) const
 Parse the current command for a set sunset to time value.
 
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.
 
bool parse_set_ble_mode_command (uint8_t &index) const
 Parse the current command for a set current mode to BLE mode.
 

Static Public Member Functions

static UserCommand make_set_ramp_command (const uint8_t ramp)
 Set this commant to handle user ramp change.
 
static UserCommand make_brightness_command (const brightness_t brightness)
 Set this commant to handle brightness.
 
static UserCommand make_set_mode_command (const uint8_t groupId, const uint8_t modeId)
 Set this commant to handle mode switch.
 
static UserCommand make_turn_onoff_command (const bool shouldTurnOn)
 Set this commant to handle turn on/off.
 
static UserCommand make_set_real_time_command (const component::time::RealTime &time)
 Set this commant to set system real time.
 
static UserCommand make_set_sunset_to_time_command (const component::time::RealTime &time)
 Set this commant to set sunset to real time.
 
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.
 
static UserCommand make_set_ble_mode_command (const uint8_t index)
 Set this commant to set ble mode.
 

Static Public Attributes

static constexpr uint8_t maxDataSize = 8
 

Protected Member Functions

 UserCommand ()
 Protected constructor to prevent unallowed uses.
 

Detailed Description

Define a command destined to the user layer. Command can only be created by the static make_* methods.

Member Enumeration Documentation

◆ Type

Command type.

Enumerator
Invalid 

invalid placeholder message

SetUserRamp 

set the user ramp value

Brightness 

set brightness

SetMode 

set mode index

OnOff 

turn on or off

SetRealTime 

set the system real time

SetSunsetToTime 

set the sunset to a target real time

SetBleCustomColorMode 

switch to BLE custom color mode

SetBleMode 

switch to a target BLE mode

Member Function Documentation

◆ make_brightness_command()

UserCommand lampda::common::UserCommand::make_brightness_command ( const brightness_t  brightness)
static

Set this commant to handle brightness.

Parameters
[in]brightness
Returns
The correct user command

◆ make_set_ble_custom_color_mode_command()

UserCommand lampda::common::UserCommand::make_set_ble_custom_color_mode_command ( const uint8_t  red,
const uint8_t  green,
const uint8_t  blue 
)
static

Set this commant to set ble custom color.

Parameters
[in]red
[in]green
[in]blue
Returns
The correct user command

◆ make_set_ble_mode_command()

UserCommand lampda::common::UserCommand::make_set_ble_mode_command ( const uint8_t  index)
static

Set this commant to set ble mode.

Parameters
[in]index
Returns
The correct user command

◆ make_set_mode_command()

UserCommand lampda::common::UserCommand::make_set_mode_command ( const uint8_t  groupId,
const uint8_t  modeId 
)
static

Set this commant to handle mode switch.

Parameters
[in]groupId
[in]modeId
Returns
The correct user command

◆ make_set_ramp_command()

UserCommand lampda::common::UserCommand::make_set_ramp_command ( const uint8_t  ramp)
static

Set this commant to handle user ramp change.

Parameters
[in]ramp
Returns
The correct user command

◆ make_set_real_time_command()

UserCommand lampda::common::UserCommand::make_set_real_time_command ( const component::time::RealTime time)
static

Set this commant to set system real time.

Parameters
[in]time
Returns
The correct user command

◆ make_set_sunset_to_time_command()

UserCommand lampda::common::UserCommand::make_set_sunset_to_time_command ( const component::time::RealTime time)
static

Set this commant to set sunset to real time.

Parameters
[in]time
Returns
The correct user command

◆ make_turn_onoff_command()

UserCommand lampda::common::UserCommand::make_turn_onoff_command ( const bool  shouldTurnOn)
static

Set this commant to handle turn on/off.

Parameters
[in]shouldTurnOn
Returns
The correct user command

◆ parse_brightness()

bool lampda::common::UserCommand::parse_brightness ( brightness_t brightness) const

Parse the current command for a brightness value.

Parameters
[out]brightness
Returns
True if the current message is valid, and parameter is set

◆ parse_ramp()

bool lampda::common::UserCommand::parse_ramp ( uint8_t &  ramp) const

Parse the current command for a ramp value.

Parsing functions

Parameters
[out]ramp
Returns
True if the current message is valid, and parameter is set

◆ parse_set_ble_custom_color_mode_command()

bool lampda::common::UserCommand::parse_set_ble_custom_color_mode_command ( uint32_t &  color) const

Parse the current command for a set current mode to BLE custom color.

Parameters
[out]color
Returns
True if the current message is valid, and parameter is set

◆ parse_set_ble_mode_command()

bool lampda::common::UserCommand::parse_set_ble_mode_command ( uint8_t &  index) const

Parse the current command for a set current mode to BLE mode.

Parameters
[out]index
Returns
True if the current message is valid, and parameter is set

◆ parse_set_mode()

bool lampda::common::UserCommand::parse_set_mode ( uint8_t &  groupId,
uint8_t &  modeId 
) const

Parse the current command for a set_mode values.

Parameters
[out]groupId
[out]modeId
Returns
True if the current message is valid, and parameters are set

◆ parse_set_real_time_command()

bool lampda::common::UserCommand::parse_set_real_time_command ( component::time::RealTime time) const

Parse the current command for a set real time value.

Parameters
[out]time
Returns
True if the current message is valid, and parameter is set

◆ parse_set_sunset_to_time_command()

bool lampda::common::UserCommand::parse_set_sunset_to_time_command ( component::time::RealTime time) const

Parse the current command for a set sunset to time value.

Parameters
[out]time
Returns
True if the current message is valid, and parameter is set

◆ parse_turn_onoff()

bool lampda::common::UserCommand::parse_turn_onoff ( bool &  shouldTurnOn) const

Parse the current command for a on/off value.

Parameters
[out]shouldTurnOn
Returns
True if the current message is valid, and parameter is set

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