EduArt Sensor Ring Library 4.0.0
Loading...
Searching...
No Matches
eduart::sensorring::device::Light Class Referenceabstract

Base class for light/LED actuator devices. More...

#include <Light.hpp>

Inheritance diagram for eduart::sensorring::device::Light:
[legend]
Collaboration diagram for eduart::sensorring::device::Light:
[legend]

Public Member Functions

 Light (DeviceID id, com::ComInterface *interface, com::ComEndpoint target)
 Construct a Light with Device params.
 ~Light () override=default
 Virtual destructor.
virtual const LightParams & getParams () const =0
 Get the current light parameters.
virtual void setLight (LightMode mode, std::uint8_t r=0, std::uint8_t g=0, std::uint8_t b=0)=0
 Set the light mode and color.
Public Member Functions inherited from eduart::sensorring::device::Device
 Device (DeviceID id, com::ComInterface *interface, com::ComEndpoint target)
 Construct the device with identity and communication link.
DeviceID getDeviceID () const
 Return the full device identifier (type + index).
unsigned int getHwIdx () const
 Return the zero-based hardware board index on its bus (used for CAN addressing and protocol bitmasks).
void setDeviceIndex (unsigned int index)
 Reassign the logical device index (DeviceID.index) without changing the hardware index.
virtual bool configure ()
 Apply post-reset runtime configuration for this device.
void setBoardContext (const board::SensorBoardParams *board_params)
 Initialize board-level context pointer (non-owning).
const board::SensorBoardParams * getBoardContext () const
 Return the board-level context pointer (non-owning).
void setPoseOffset (const math::Pose &offset)
 Store a pose offset relative to the board centre.
math::Pose getPoseOffset () const
 Return the stored pose offset relative to the board centre.
math::Pose getGlobalPose () const
 Compute and return the global pose in the ring coordinate frame.
Public Member Functions inherited from eduart::sensorring::ActionDispatcher
void setQueue (ActionQueue *queue)
void clearQueue ()
bool isManaged () const
void execute (Action action)
void execute (std::string_view key, Action action)

Static Public Member Functions

static void setAllLights (const std::vector< Light * > &devices, LightMode mode, std::uint8_t red, std::uint8_t green, std::uint8_t blue)
 Broadcast a mode+color command to ALL WS2812b devices on ALL interfaces.
Static Public Member Functions inherited from eduart::sensorring::ActionDispatcher
static void globalExecute (Action action)

Additional Inherited Members

Protected Member Functions inherited from eduart::sensorring::device::Device
virtual void comCallback (const com::ComEndpoint source, std::uint8_t command, const std::vector< std::uint8_t > &data)=0
Protected Attributes inherited from eduart::sensorring::device::Device
DeviceID _id
unsigned int _hw_idx
com::ComInterface * _interface
const board::SensorBoardParams * _board_params = nullptr
math::Pose _offset
subscription::Subscription _com_subscription

Detailed Description

Base class for light/LED actuator devices.

Inherits from Device (identity, pose, action queue). Users call setLight() to update the desired state. The concrete implementation enqueues a self-contained CAN command into the action queue, which the state machine drains and executes during the device_actions cycle.

Constructor & Destructor Documentation

◆ Light()

eduart::sensorring::device::Light::Light ( DeviceID id,
com::ComInterface * interface,
com::ComEndpoint target )

Construct a Light with Device params.

Parameters
[in]idDevice identifier.
[in]interfaceCommunication interface.
[in]targetCommunication endpoint this device listens to.

Member Function Documentation

◆ getParams()

virtual const LightParams & eduart::sensorring::device::Light::getParams ( ) const
pure virtual

Get the current light parameters.

Returns
Current Light parameters.

Implemented in eduart::sensorring::device::WS2812b_Device.

◆ setAllLights()

void eduart::sensorring::device::Light::setAllLights ( const std::vector< Light * > & devices,
LightMode mode,
std::uint8_t red,
std::uint8_t green,
std::uint8_t blue )
static

Broadcast a mode+color command to ALL WS2812b devices on ALL interfaces.

Useful for turning off all lights (including unconfigured boards).

Parameters
[in]devicesVector of WS2812b devices to apply the command to.
[in]modeLight mode to apply.
[in]redRed channel value.
[in]greenGreen channel value.
[in]blueBlue channel value.
Returns
true on success.

◆ setLight()

virtual void eduart::sensorring::device::Light::setLight ( LightMode mode,
std::uint8_t r = 0,
std::uint8_t g = 0,
std::uint8_t b = 0 )
pure virtual

Set the light mode and color.

Parameters
[in]modeLight mode to apply. Not all modes require a color to be specified.
[in]rRed channel (0-255).
[in]gGreen channel (0-255).
[in]bBlue channel (0-255).

Implemented in eduart::sensorring::device::WS2812b_Device.


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