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 , SetSunriseToTime ,
  SetBleCustomColorMode , SetBleMode , GoToFavoriteIndex , SetFavoriteIndex ,
  SignalSunsetProgress , SignalSunriseProgress , SignalSuntimerCancel , BlipOutput ,
  PrintStatus , PrintFavorites , DisableSunTimer , SetMicSensitivity
}
 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_sunrise_to_time_command (component::time::RealTime &time) const
 Parse the current command for a set sunrise 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.
 
bool parse_go_to_favorite_command (uint8_t &index) const
 Parse the current command for a go to favorite.
 
bool parse_set_favorite_command (uint8_t &index) const
 Parse the current command for a set favorite.
 
bool parse_signal_sunset_progress_command (float &progress) const
 Parse the current command for a sunset update signal.
 
bool parse_signal_sunrise_progress_command (float &progress) const
 Parse the current command for a sunrise update signal.
 
bool parse_signal_suntimer_cancel_command () const
 Parse the current command for a suntimer cancel signal.
 
bool parse_disable_sun_timer_command (bool &isSunrise) const
 Parse the current command for a sun timer disable.
 
bool parse_set_mic_sensitivity_command (uint8_t &sensitivity) const
 Parse the current command for a microphone sensitivity change.
 
bool parse_blip_output_command (uint32_t &duration_ms) const
 Parse the current command for an output blip.
 
bool parse_print_status_command () const
 Parse the current command for a status print.
 
bool parse_print_favorites_command () const
 Parse the current command for a favorites print.
 

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_sunrise_to_time_command (const component::time::RealTime &time)
 Set this commant to set sunrise 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 UserCommand make_go_to_favorite_command (const uint8_t index)
 Set this commant to go to the given favorite, if possible.
 
static UserCommand make_set_favorite_command (const uint8_t index)
 Set this commant to set favorite.
 
static UserCommand make_signal_sunset_progress_command (const float progress)
 Set this commant to signal a sunset update.
 
static UserCommand make_signal_sunrise_progress_command (const float progress)
 Set this commant to signal a sunrise update.
 
static UserCommand make_signal_suntimer_cancel_command ()
 Set this commant to signal a suntimer cancel event.
 
static UserCommand make_disable_sun_timer_command (const bool isSunrise)
 Set this command to disable a sun timer. A disabled sunrise keeps the brightness it reached, as for a user brightness change.
 
static UserCommand make_set_mic_sensitivity_command (const uint8_t sensitivity)
 Set this command to set the microphone sensitivity.
 
static UserCommand make_blip_output_command (const uint32_t duration_ms)
 Set this commant to blip the output.
 
static UserCommand make_print_status_command ()
 Set this commant to print the user status line.
 
static UserCommand make_print_favorites_command ()
 Set this commant to print the favorite modes infos.
 

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

SetSunriseToTime 

set the sunrise to a target real time

SetBleCustomColorMode 

switch to BLE custom color mode

SetBleMode 

switch to a target BLE mode

GoToFavoriteIndex 

Go to the target favorite index.

SetFavoriteIndex 

Set the current mode to the target favorite index.

SignalSunsetProgress 

Signal a sunset update event.

SignalSunriseProgress 

Signal a sunrise update event.

SignalSuntimerCancel 

Signal that a suntimer was canceled.

BlipOutput 

Turn off the output for a short time.

PrintStatus 

Print the current mode, group, ramp, brightness and favorite state on one line.

PrintFavorites 

Print the favorite mode count.

DisableSunTimer 

Disable the sunset or the sunrise timer.

SetMicSensitivity 

Set the microphone sensitivity.

Member Function Documentation

◆ make_blip_output_command()

UserCommand lampda::common::UserCommand::make_blip_output_command ( const uint32_t  duration_ms)
static

Set this commant to blip the output.

Parameters
[in]duration_ms
Returns
The correct user command

◆ 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_disable_sun_timer_command()

UserCommand lampda::common::UserCommand::make_disable_sun_timer_command ( const bool  isSunrise)
static

Set this command to disable a sun timer. A disabled sunrise keeps the brightness it reached, as for a user brightness change.

Parameters
[in]isSunriseTrue to disable the sunrise timer, false for the sunset timer
Returns
The correct user command

◆ make_go_to_favorite_command()

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

Set this commant to go to the given favorite, if possible.

Parameters
[in]index
Returns
The correct user command

◆ make_print_favorites_command()

UserCommand lampda::common::UserCommand::make_print_favorites_command ( )
static

Set this commant to print the favorite modes infos.

Returns
The correct user command

◆ make_print_status_command()

UserCommand lampda::common::UserCommand::make_print_status_command ( )
static

Set this commant to print the user status line.

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_favorite_command()

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

Set this commant to set favorite.

Parameters
[in]index
Returns
The correct user command

◆ make_set_mic_sensitivity_command()

UserCommand lampda::common::UserCommand::make_set_mic_sensitivity_command ( const uint8_t  sensitivity)
static

Set this command to set the microphone sensitivity.

Parameters
[in]sensitivitySensitivity, see component::microphone::set_sensitivity
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_sunrise_to_time_command()

UserCommand lampda::common::UserCommand::make_set_sunrise_to_time_command ( const component::time::RealTime &  time)
static

Set this commant to set sunrise to 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_signal_sunrise_progress_command()

UserCommand lampda::common::UserCommand::make_signal_sunrise_progress_command ( const float  progress)
static

Set this commant to signal a sunrise update.

Parameters
[in]progress
Returns
The correct user command

◆ make_signal_sunset_progress_command()

UserCommand lampda::common::UserCommand::make_signal_sunset_progress_command ( const float  progress)
static

Set this commant to signal a sunset update.

Parameters
[in]progress
Returns
The correct user command

◆ make_signal_suntimer_cancel_command()

UserCommand lampda::common::UserCommand::make_signal_suntimer_cancel_command ( )
static

Set this commant to signal a suntimer cancel event.

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_blip_output_command()

bool lampda::common::UserCommand::parse_blip_output_command ( uint32_t &  duration_ms) const

Parse the current command for an output blip.

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

◆ 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_disable_sun_timer_command()

bool lampda::common::UserCommand::parse_disable_sun_timer_command ( bool &  isSunrise) const

Parse the current command for a sun timer disable.

Parameters
[out]isSunriseTrue if the sunrise timer must be disabled, false for the sunset timer
Returns
True if the current message is valid, and parameter is set

◆ parse_go_to_favorite_command()

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

Parse the current command for a go to favorite.

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

◆ parse_print_favorites_command()

bool lampda::common::UserCommand::parse_print_favorites_command ( ) const

Parse the current command for a favorites print.

Returns
True if the current message is valid

◆ parse_print_status_command()

bool lampda::common::UserCommand::parse_print_status_command ( ) const

Parse the current command for a status print.

Returns
True if the current message is valid

◆ 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_favorite_command()

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

Parse the current command for a set favorite.

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

◆ parse_set_mic_sensitivity_command()

bool lampda::common::UserCommand::parse_set_mic_sensitivity_command ( uint8_t &  sensitivity) const

Parse the current command for a microphone sensitivity change.

Parameters
[out]sensitivityThe requested sensitivity
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_sunrise_to_time_command()

bool lampda::common::UserCommand::parse_set_sunrise_to_time_command ( component::time::RealTime &  time) const

Parse the current command for a set sunrise to 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_signal_sunrise_progress_command()

bool lampda::common::UserCommand::parse_signal_sunrise_progress_command ( float &  progress) const

Parse the current command for a sunrise update signal.

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

◆ parse_signal_sunset_progress_command()

bool lampda::common::UserCommand::parse_signal_sunset_progress_command ( float &  progress) const

Parse the current command for a sunset update signal.

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

◆ parse_signal_suntimer_cancel_command()

bool lampda::common::UserCommand::parse_signal_suntimer_cancel_command ( ) const

Parse the current command for a suntimer cancel signal.

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: