hyperion.ng/libsrc/leddevice/LedDeviceWS281x.h
penfold42 d5ce395e8e Add sk6812rgbw support (#666)
* Removed -HUP so the default -TERM signal is sent instead.
- hyperiond only listens for TERM and INT. HUP is often used to get an exe to reread its config

Changed pgrep to add '-x' so it wont partial match on the exe name.
- I have multiple instances with multiple hyperiond-instance1 names
- this ensures the service script only kills the right process

* reversing errant change to hyperion.systemd.sh

* adding support for SK6812 - not working yet

* Changed rpi_ws281x submodule to be penfold42's fork

* Set White to zero for now

* starting on the code to make the White led do stuff

* Added some basic whie led calculation
white = min(r,g,b)
r-=w, g-=w, b-=w

* cleaned up a couple of compiler warnings

* updated strip type to use corrected RGBW strip type
(the SK6812RGBW datasheet is wrong)

* moved bitpair_to_byte initialiser to (hopefully) work with older GCC

* compiler warning in udp driver
removed some tabs in ws2812b.cpp

* formatting - spaces to tabs

* moved rpi_281x to tag sk6812-v1.0

* attempt #3 at migrating the rpi_281x submodule to my fork/branch

* moving to my fork of rpi_281x

* Started implementing multiple RGB to RGBW conversion options

a quick hack has been implemented inside WS281x.cpp but ive started
moving this to RgbToRgbw.cpp for reuse by other led device types

* migrated RGB to RGBW conversion to RgbToRgbw.cpp


Former-commit-id: ff8e9038c4bb8203b71b42d12bf23be4abcc0b3b
2016-05-31 22:55:56 +02:00

52 lines
1.4 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
/// @param pwmchannel The pwm channel to use
/// @param invert Invert the output line to support an inverting level shifter
/// @param rgbw Send 32 bit rgbw colour data for sk6812
///
LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, int dmanum, int pwmchannel, int invert,
int rgbw, const std::string& whiteAlgorithm);
///
/// 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;
int chan;
bool initialized;
std::string _whiteAlgorithm;
ColorRgbw _temp_rgbw;
};
#endif /* LEDDEVICEWS281X_H_ */