mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
78e606a1c4
Add a new WS281x driver which is a wrapper around jgarff's ws281x library which works on Pi B+, Pi 2, Pi Zero and probably Pi 3 as well. jgarff's ws281x library is included as a submodule Former-commit-id: e473dfd36d31b14598da5e56e4b8bf9f2aa7bb24
44 lines
1.0 KiB
C++
44 lines
1.0 KiB
C++
#ifndef LEDDEVICEWS281X_H_
|
|
#define LEDDEVICEWS281X_H_
|
|
|
|
#pragma once
|
|
|
|
#include <leddevice/LedDevice.h>
|
|
#include <ws2811.h>
|
|
|
|
class LedDeviceWS281x : public LedDevice
|
|
{
|
|
public:
|
|
///
|
|
/// Constructs the LedDevice for WS281x (one wire 800kHz)
|
|
///
|
|
/// @param gpio The gpio pin to use (BCM chip counting, default is 18)
|
|
/// @param leds The number of leds attached to the gpio pin
|
|
/// @param freq The target frequency for the data line, default is 800000
|
|
/// @param dmanum The DMA channel to use, default is 5
|
|
///
|
|
LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, int dmanum);
|
|
|
|
///
|
|
/// Destructor of the LedDevice, waits for DMA to complete and then cleans up
|
|
///
|
|
~LedDeviceWS281x();
|
|
|
|
///
|
|
/// Writes the led color values to the led-device
|
|
///
|
|
/// @param ledValues The color-value per led
|
|
/// @return Zero on succes else negative
|
|
///
|
|
virtual int write(const std::vector<ColorRgb> &ledValues);
|
|
|
|
/// Switch the leds off
|
|
virtual int switchOff();
|
|
|
|
private:
|
|
ws2811_t led_string;
|
|
bool initialized;
|
|
};
|
|
|
|
#endif /* LEDDEVICEWS281X_H_ */
|