EduArt Sensor Ring Library 4.0.0
Loading...
Searching...
No Matches
eduart::sensorring::device::WS2812b_Device Class Reference

Device wrapper for WS2812b LED strips controlled via the sensorring bus. More...

#include <WS2812b_Device.hpp>

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

Public Member Functions

 WS2812b_Device (WS2812b_Params params, com::ComInterfaceID interface, unsigned int idx)
 Construct a new WS2812b device instance.
bool configure () override
 Re-apply runtime configuration after board reset.
bool setDistanceMapRange (double lower_m, double upper_m)
 Set the distance map range in meters and verify it by reading it back.
bool getDistanceMapRange (double &lower_m, double &upper_m)
 Read the current distance map range from the board in meters.
bool setDistanceMapMaxBrightness (std::int64_t brightness)
 Set distance map peak channel brightness and verify it by reading it back.
bool getDistanceMapMaxBrightness (std::int64_t &brightness)
 Read the current distance map peak channel brightness from the board.
const WS2812b_Params & getParams () const override
 Get the parameters used to configure this device.
void setLight (LightMode mode, std::uint8_t r, std::uint8_t g, std::uint8_t b) override
 Set the light mode and color. Enqueues a per-device CAN command into the action queue.
Public Member Functions inherited from eduart::sensorring::device::Light
 Light (DeviceID id, com::ComInterface *interface, com::ComEndpoint target)
 Construct a Light with Device params.
 ~Light () override=default
 Virtual destructor.
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.
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 syncLight ()
 Synchronize pending light updates on all WS2812b devices.
Static Public Member Functions inherited from eduart::sensorring::device::Light
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)

Protected Member Functions

 WS2812b_Device (WS2812b_Params params, com::ComInterface *interface, unsigned int idx)
 Construct with a non-owning communication interface supplied by a subclass.
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

Additional Inherited Members

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

Device wrapper for WS2812b LED strips controlled via the sensorring bus.

Constructor & Destructor Documentation

◆ WS2812b_Device()

eduart::sensorring::device::WS2812b_Device::WS2812b_Device ( WS2812b_Params params,
com::ComInterfaceID interface,
unsigned int idx )

Construct a new WS2812b device instance.

Parameters
[in]paramsLED strip configuration parameters.
[in]interfaceCommunication interface used to talk to the device.
[in]idxIndex of the device on the bus.

Member Function Documentation

◆ configure()

bool eduart::sensorring::device::WS2812b_Device::configure ( )
overridevirtual

Re-apply runtime configuration after board reset.

Returns
true on success.

Reimplemented from eduart::sensorring::device::Device.

◆ getDistanceMapMaxBrightness()

bool eduart::sensorring::device::WS2812b_Device::getDistanceMapMaxBrightness ( std::int64_t & brightness)

Read the current distance map peak channel brightness from the board.

Parameters
[out]brightnessCurrent brightness, unchanged on failure.
Returns
true if a valid response was received.

◆ getDistanceMapRange()

bool eduart::sensorring::device::WS2812b_Device::getDistanceMapRange ( double & lower_m,
double & upper_m )

Read the current distance map range from the board in meters.

Parameters
[out]lower_mLower distance threshold, unchanged on failure.
[out]upper_mUpper distance threshold, unchanged on failure.
Returns
true if a valid response was received.

◆ getParams()

const WS2812b_Params & eduart::sensorring::device::WS2812b_Device::getParams ( ) const
inlineoverridevirtual

Get the parameters used to configure this device.

Returns
Reference to the internal WS2812b parameter struct.

Implements eduart::sensorring::device::Light.

◆ setDistanceMapMaxBrightness()

bool eduart::sensorring::device::WS2812b_Device::setDistanceMapMaxBrightness ( std::int64_t brightness)

Set distance map peak channel brightness and verify it by reading it back.

Parameters
[in]brightnessInteger brightness in [0, 255].
Returns
true if the returned brightness matches exactly.

◆ setDistanceMapRange()

bool eduart::sensorring::device::WS2812b_Device::setDistanceMapRange ( double lower_m,
double upper_m )

Set the distance map range in meters and verify it by reading it back.

Returns
true if both values match within float32 rounding tolerance.

◆ setLight()

void eduart::sensorring::device::WS2812b_Device::setLight ( LightMode mode,
std::uint8_t r,
std::uint8_t g,
std::uint8_t b )
overridevirtual

Set the light mode and color. Enqueues a per-device CAN command into the action queue.

Parameters
[in]modeLight mode to apply.
[in]rRed channel (0-255).
[in]gGreen channel (0-255).
[in]bBlue channel (0-255).

Implements eduart::sensorring::device::Light.


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