APA102 device for use with Adalight (nominaly for ws2801)

Former-commit-id: 7fb9e8e84518be9387ea9feca11e93a8a5389e4f
This commit is contained in:
tociek 2015-10-13 19:11:01 +02:00
parent 4fe01a6613
commit 33edcddb1b
4 changed files with 51 additions and 1 deletions

View File

@ -15,6 +15,7 @@ include_directories(
SET(Leddevice_QT_HEADERS
${CURRENT_SOURCE_DIR}/LedRs232Device.h
${CURRENT_SOURCE_DIR}/LedDeviceAdalight.h
${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.h
${CURRENT_SOURCE_DIR}/LedDeviceAmbiLed.h
${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.h
)
@ -40,6 +41,7 @@ SET(Leddevice_SOURCES
${CURRENT_SOURCE_DIR}/LedRs232Device.cpp
${CURRENT_SOURCE_DIR}/LedDeviceAdalight.cpp
${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.cpp
${CURRENT_SOURCE_DIR}/LedDeviceAmbiLed.cpp
${CURRENT_SOURCE_DIR}/LedDeviceLightpack.cpp
${CURRENT_SOURCE_DIR}/LedDeviceMultiLightpack.cpp

View File

@ -40,7 +40,7 @@ private slots:
/// Write the last data to the leds again
void rewriteLeds();
private:
protected:
/// The buffer containing the packed RGB values
std::vector<uint8_t> _ledBuffer;

View File

@ -0,0 +1,36 @@
#pragma once
// STL includes
#include <string>
// Qt includes
#include <QTimer>
// hyperion incluse
#include "LedDeviceAdalight.h"
///
/// Implementation of the LedDevice interface for writing to an Adalight led device for APA102 led strips.
///
class LedDeviceAdalightApa102 : public LedDeviceAdalight
{
Q_OBJECT
public:
///
/// Constructs the LedDevice for attached Adalight device
///
/// @param outputDevice The name of the output device (eg '/dev/ttyS0')
/// @param baudrate The used baudrate for writing to the output device
///
LedDeviceAdalightApa102(const std::string& outputDevice, const unsigned baudrate, int delayAfterConnect_ms);
///
/// 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);
};

View File

@ -33,6 +33,7 @@
#include "LedDevicePhilipsHue.h"
#include "LedDeviceTpm2.h"
#include "LedDeviceAtmo.h"
#include "LedDeviceAdalightApa102.h"
#ifdef ENABLE_WS2812BPWM
#include "LedDeviceWS2812b.h"
@ -58,6 +59,17 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig)
device = deviceAdalight;
}
else if (type == "adalightapa102")
{
const std::string output = deviceConfig["output"].asString();
const unsigned rate = deviceConfig["rate"].asInt();
const int delay_ms = deviceConfig["delayAfterConnect"].asInt();
LedDeviceAdalightApa102* deviceAdalightApa102 = new LedDeviceAdalightApa102(output, rate, delay_ms);
deviceAdalightApa102->open();
device = deviceAdalightApa102;
}
else if (type == "ambiled")
{
const std::string output = deviceConfig["output"].asString();