Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
lampda::modes Namespace Reference

Contains basic interface types to implement custom user modes. More...

Namespaces

namespace  audio
 User modes audio utilities.
 
namespace  automaton
 Modes implementing cellular automaton using "grid" tools.
 
namespace  bluetooth
 Define bluetooth special modes.
 
namespace  colors
 Tools to manipulate colors and their representation.
 
namespace  default_modes
 Basic "default" modes included with the hardware.
 
namespace  hardware
 Provide interface to the physical hardware and other facilities.
 
namespace  imu
 User modes imu utilities.
 
namespace  store
 Mode key store interface, see ContextTy::KeyProxy.
 

Classes

struct  BasicMode
 Parent object for all custom user modes. More...
 
struct  ContextTy
 Local context exposing system features to active BasicMode. More...
 
struct  DefaultManagerConfig
 Default manager configuration, enables you to customize defaults. More...
 
struct  HelixXYZTy
 
struct  Particle
 Define a particle in 3D space. it has a position and speed. More...
 
class  ParticleSystem
 Define a particle system ALL PARTICLE SYSTEM SHARE THE SAME PĂ„RTICLE SUBSET. More...
 
struct  XYTy
 

Typedefs

using FixedModes = modes::GroupFor< fixed::PaletteBlackBodyMode, fixed::PaletteRainbowMode, fixed::PalettePapiMode >
 Fixed modes groups.
 
using MiscFixedModes = modes::GroupFor< fixed::PalettePartyMode, fixed::PaletteForestMode, fixed::PaletteOceanMode >
 Fixed palette colors modes.
 
template<typename... Modes>
using GroupFor = GroupTy< std::tuple< Modes... > >
 Group together many different modes::BasicMode.
 
template<typename ManagerConfig , typename... Groups>
using ManagerForConfig = ModeManagerTy< ManagerConfig, std::tuple< Groups... >, 0 >
 Same as modes::ManagerFor but with custom defaults.
 
template<typename... Groups>
using ManagerFor = ModeManagerTy< DefaultManagerConfig, std::tuple< Groups... >, 0 >
 Group together several mode groups defined through modes::GroupFor.
 
template<uint8_t hiddenGroupCnt, typename... Groups>
using ManagerForHiddenGroups = ModeManagerTy< DefaultManagerConfig, std::tuple< Groups... >, hiddenGroupCnt >
 Group together several mode groups defined through modes::GroupFor. Will use the last hiddenGroupCnt as hidden groups, only accessible through certain action.
 
template<uint8_t hiddenGroupCnt, typename ManagerConfig , typename... Groups>
using ManagerFoHiddenConfig = ModeManagerTy< ManagerConfig, std::tuple< Groups... >, hiddenGroupCnt >
 Same as modes::ManagerFor but with custom defaults, and additional hidden groups.
 
using LampTy = hardware::LampTy
 Define a particle in cylindrical space, and movement equations on the cylinder surface.
 

Enumerations

enum class  ConfigKeys : uint8_t {
  rampSaturates , clearStripOnModeChange , customRampStepSpeedMs , customRampAnimEffect ,
  customRampAnimChoice
}
 Keys to enable modes to change configuration at runtime. More...
 

Functions

template<typename NewLocalMode >
static auto context_as (auto &ctx)
 Bind provided context to another modes::BasicMode.
 
static constexpr uint16_t to_strip (uint16_t, uint16_t)
 convert grid coordinates to strip index
 
static constexpr XYTy strip_to_XY (uint16_t n)
 convert strip index to grid coordinates
 
static constexpr HelixXYZTy strip_to_helix (int16_t n)
 convert strip index to 3D coordinates
 
static constexpr HelixXYZTy strip_to_helix_unconstraint (const int16_t n)
 convert strip index to 3D coordinates, without checks on led index. This allows to use 3D coordinates out of the lamp body
 
static constexpr bool is_led_index_valid (const int16_t ledIndex)
 True if the given strip index is a valid one.
 
static constexpr bool is_lamp_coordinate_out_of_bounds (const float angle_rad, const float z)
 True if the given led index is out of bounds.
 
static constexpr uint16_t to_led_index (const float angle_rad, const float z)
 convert a lamp coordinate to a led index
 
static constexpr int16_t to_led_index_no_bounds (const float angle_rad, const float z)
 convert a lamp coordinate to a led index, the result can be an index out of the lamp body
 
static constexpr float to_helix_z (const int16_t n)
 Convert a led index to an helix height coordinate.
 

Variables

static constexpr float cylinderRadius_m = LampTy::lampBodyRadius_mm / 1000.0
 radius of the cylinder, in meters
 
static constexpr float angularSpeedGain = 50000
 this gain compensate the angular acceleration for better display
 
static constexpr float linearSpeedGain = 1.0
 gain for the linear speeds
 
static constexpr float reboundCoeff = 0.1
 low rebound [0 - 1] on walls
 
static constexpr float speedDampening = 0.92
 low speed dampening [0-0.99] at every steps (viscosity)
 
static constexpr float maxAngularSpeed_radS = 4 * c_TWO_PI
 max angular speed in radians/s
 
static constexpr float maxVerticalSpeed_mmS = 50
 max vertical speed in mm/S
 

Detailed Description

Contains basic interface types to implement custom user modes.

Typedef Documentation

◆ GroupFor

template<typename... Modes>
using lampda::modes::GroupFor = typedef GroupTy<std::tuple<Modes...> >

Group together many different modes::BasicMode.

Binds all methods of the provided list of Modes and works together with modes::ModeManagerTy to dispatch events and switch modes

◆ ManagerFoHiddenConfig

template<uint8_t hiddenGroupCnt, typename ManagerConfig , typename... Groups>
using lampda::modes::ManagerFoHiddenConfig = typedef ModeManagerTy<ManagerConfig, std::tuple<Groups...>, hiddenGroupCnt>

Same as modes::ManagerFor but with custom defaults, and additional hidden groups.

See modes::DefaultManagerConfig for guide on how to override configuration.

◆ ManagerFor

template<typename... Groups>
using lampda::modes::ManagerFor = typedef ModeManagerTy<DefaultManagerConfig, std::tuple<Groups...>, 0>

Group together several mode groups defined through modes::GroupFor.

Binds all methods of the provided list of Groups and dispatch events while managing all the modes::BasicMode::StateTy states & other behaviors

Remarks
All enabled modes shall be enumerated in modes::GroupFor listed as inside the modes::ManagerFor modes::ModeManagerTy singleton

◆ ManagerForConfig

template<typename ManagerConfig , typename... Groups>
using lampda::modes::ManagerForConfig = typedef ModeManagerTy<ManagerConfig, std::tuple<Groups...>, 0>

Same as modes::ManagerFor but with custom defaults.

See modes::DefaultManagerConfig for guide on how to override configuration.

◆ ManagerForHiddenGroups

template<uint8_t hiddenGroupCnt, typename... Groups>
using lampda::modes::ManagerForHiddenGroups = typedef ModeManagerTy<DefaultManagerConfig, std::tuple<Groups...>, hiddenGroupCnt>

Group together several mode groups defined through modes::GroupFor. Will use the last hiddenGroupCnt as hidden groups, only accessible through certain action.

Binds all methods of the provided list of Groups and dispatch events while managing all the modes::BasicMode::StateTy states & other behaviors

Remarks
All enabled modes shall be enumerated in modes::GroupFor listed as inside the modes::ManagerFor modes::ModeManagerTy singleton

Enumeration Type Documentation

◆ ConfigKeys

enum class lampda::modes::ConfigKeys : uint8_t
strong

Keys to enable modes to change configuration at runtime.

During modes::BasicMode::on_enter_mode() callback, modes can change configuration temporarily, for example to change how the ramp behaves, or how fast it goes.

To change a boolean value, use the following:

// set value for "rampSaturates" to "True" for active mode
static void on_enter_mode(auto& ctx) {
ctx.template set_config_bool<ConfigKeys::rampSaturates>(true);
}

To change an integer value, 32-bit unsigned, use the following:

// set value for "customRampStepSpeedMs" to "32" for active mode
static void on_enter_mode(auto& ctx) {
ctx.template set_config_u32<ConfigKeys::customRampStepSpeedMs>(32);
}

All these values are reset to their default counterpart before each mode change, see modes::DefaultManagerConfig on how to override these defaults.

Enumerator
rampSaturates 

(bool) Mode saturates on custom ramp, or else wrap?

clearStripOnModeChange 

(bool) Mode clear strip after reset, or else do nothing?

customRampStepSpeedMs 

(u32) Mode time step for incrementing custom ramp (ms)

customRampAnimEffect 

(bool) Mode uses custom ramp anim. or not?

customRampAnimChoice 

(u32) Which custom ramp anim. to use (rainbow, etc)

Function Documentation

◆ context_as()

template<typename NewLocalMode >
static auto lampda::modes::context_as ( auto &  ctx)
static

Bind provided context to another modes::BasicMode.

Parameters
[in]ctxLocal context to bind to NewLocalMode
Returns
A new context instance bound to the provided modes::BasicMode

◆ is_lamp_coordinate_out_of_bounds()

static constexpr bool lampda::modes::is_lamp_coordinate_out_of_bounds ( const float  angle_rad,
const float  z_mm 
)
staticconstexpr

True if the given led index is out of bounds.

Return true id the given coordinates exists on the strip. This function also checks the bounds using the observation angle, as the strip is an helix.

Parameters
[in]angle_radAngle in radians of the pixel.
[in]z_mmheight, in mm. Height in this coordinate system is negative.

◆ is_led_index_valid()

static constexpr bool lampda::modes::is_led_index_valid ( const int16_t  n)
staticconstexpr

True if the given strip index is a valid one.

Return true id the given led index exists on the strip.

Parameters
[in]nIndex of the led in the strip.

◆ strip_to_helix()

static constexpr HelixXYZTy lampda::modes::strip_to_helix ( int16_t  n)
staticconstexpr

convert strip index to 3D coordinates

Convert a strip led index to a 3D helix coordinate.

Parameters
[in]nIndex of the led in the strip. If will be constraint to the lamp body
Returns
Coordinates of the led in the 3D world (mm)

◆ strip_to_helix_unconstraint()

static constexpr HelixXYZTy lampda::modes::strip_to_helix_unconstraint ( const int16_t  n)
staticconstexpr

convert strip index to 3D coordinates, without checks on led index. This allows to use 3D coordinates out of the lamp body

Convert a strip led index to a 3D helix coordinate.

Parameters
[in]nIndex of the led in the strip, unconstraint to the lamp body.
Returns
Coordinates of the led in the 3D world (mm)

◆ strip_to_XY()

static constexpr XYTy lampda::modes::strip_to_XY ( uint16_t  n)
staticconstexpr

convert strip index to grid coordinates

Convert a n index on the LED strip to a matching XY coordinate.

◆ to_helix_z()

static constexpr float lampda::modes::to_helix_z ( const int16_t  n)
staticconstexpr

Convert a led index to an helix height coordinate.

Parameters
[in]nIndex of the led in the strip, unconstraint to the lamp body.
Returns
The height if the pixel, in mm.

◆ to_led_index()

static constexpr uint16_t lampda::modes::to_led_index ( const float  angle_rad,
const float  z_mm 
)
staticconstexpr

convert a lamp coordinate to a led index

Convert a cylindrical world coordinate to a led index.

Parameters
[in]angle_radAngle in radians of the pixel.
[in]z_mmheight, in mm. Height in this coordinate system is negative.
Returns
The index of the led, constrained to a valid index in the strip.

◆ to_led_index_no_bounds()

static constexpr int16_t lampda::modes::to_led_index_no_bounds ( const float  angle_rad,
const float  z_mm 
)
staticconstexpr

convert a lamp coordinate to a led index, the result can be an index out of the lamp body

Convert a cylindrical world coordinate to a led index.

Parameters
[in]angle_radAngle in radians of the pixel.
[in]z_mmheight, in mm. Height in this coordinate system is negative.
Returns
The index of the led. It is not necessarly a valid index.

◆ to_strip()

static constexpr uint16_t lampda::modes::to_strip ( uint16_t  x,
uint16_t  y 
)
staticconstexpr

convert grid coordinates to strip index

Convert x and y coordinates to a linear position on strip.