EduArt Sensor Ring Library 3.0.0
Loading...
Searching...
No Matches
WS2812b_Device.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 EduArt Robotik GmbH
2
9
10#pragma once
11
12#include <memory>
13
16#include "sensorring/device/hardware/ws2812b/WS2812b_Params.hpp"
18#include "sensorring/platform/SensorringExport.hpp"
19
20namespace eduart {
21
22namespace device {
23
24class WS2812b_DeviceImpl;
25
30class SENSORRING_EXPORT WS2812b_Device : public BaseDevice {
31public:
38 WS2812b_Device(WS2812b_Params params, com::ComInterfaceID interface, unsigned int idx);
39
42
47 const WS2812b_Params& getParams() const;
48
49 // Simple static helpers to control all WS2812b devices on the bus.
58 static bool setLight(LightMode mode, std::uint8_t red, std::uint8_t green, std::uint8_t blue);
63 static bool syncLight();
64
65private:
71 void comCallback(const com::ComEndpoint source, const std::vector<uint8_t>& data) override;
72
73 void onResetSensorState() override;
74 void onClearDataFlag() override;
75
76 friend class WS2812b_DeviceImpl;
77 std::unique_ptr<WS2812b_DeviceImpl> _impl;
78};
79
80} // namespace device
81
82} // namespace eduart
Base device combining IDevice and BaseSensor with device ID and state.
Interface type definition.
Light mode definition.
LightMode
Light mode enumeration.
Definition LightMode.hpp:22
Uniquely identifies a communication endpoint by its string ID.
Definition ComEndpoint.hpp:25
BaseDevice(DeviceID id, com::ComInterface *interface, com::ComEndpoint target, bool enable)
Constructs the device with the given ID, communication interface, endpoint, and enable flag.
static bool setLight(LightMode mode, std::uint8_t red, std::uint8_t green, std::uint8_t blue)
Set light mode and color for all WS2812b devices on the bus.
WS2812b_Device(WS2812b_Params params, com::ComInterfaceID interface, unsigned int idx)
Construct a new WS2812b device instance.
const WS2812b_Params & getParams() const
Get the parameters used to configure this device.
static bool syncLight()
Synchronize pending light updates on all WS2812b devices.
Definition ComInterfaceID.hpp:32
Parameter structure of the sensor lights of a sensor board. Not all sensor boards have lights.
Definition WS2812b_Params.hpp:19