Class APA102
Defined in File apa102.hpp
Inheritance Relationships
Base Type
public husarion_ugv_lights::APA102Interface(Class APA102Interface)
Class Documentation
-
class APA102 : public husarion_ugv_lights::APA102Interface
Class representing an APA102 LED panel.
This class provides methods to control the APA102 LED panel, including setting the global brightness, setting the LED panel based on a given frame.
- Param spi_device:
SPI Device object
- Param device_name:
name of the device
- Param speed:
Speed of the SPI communication
- Param cs_high:
Chip select high flag
Public Functions
-
~APA102()
-
virtual void SetGlobalBrightness(const std::uint8_t brightness) override
Set APA102 LED global brightness.
- Parameters:
brightness – value in range from 0 to 31
- Throws:
std::out_of_range – if brightness value is out of defined range
-
virtual void SetGlobalBrightness(const float brightness) override
Set APA102 LED global brightness.
- Parameters:
brightness – value in range from 0.0 to 1.0
- Throws:
std::out_of_range – if brightness value is out of defined range
-
virtual void SetPanel(const std::vector<std::uint8_t> &frame) const override
Set APA102 LED panel based on given frame.
- Parameters:
frame – vector in the RGBA format where alpha represents brightness of a given LED
- Throws:
std::ios_base::failure – if failed to send data over SPI or std::runtime_error if frame is invalid
Protected Functions
-
std::vector<std::uint8_t> RGBAFrameToBGRBuffer(const std::vector<std::uint8_t> &frame) const
Creates buffer with BGR format with structure appropriate for the SPI transfer based on a given RGBA frame.
- Throws:
std::runtime_error – if frame has incorrect number of bytes
- Returns:
buffer vector.
-
void SPISendBuffer(const std::vector<std::uint8_t> &buffer) const
Create transfer object based on buffer and send data over SPI.
- Throws:
std::ios_base::failure – if failed to send data over SPI
Protected Attributes
-
std::uint16_t global_brightness_