Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit 7fb9e8e

Browse files
author
tociek
committed
APA102 device for use with Adalight (nominaly for ws2801)
1 parent f594935 commit 7fb9e8e

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

libsrc/leddevice/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ include_directories(
1515
SET(Leddevice_QT_HEADERS
1616
${CURRENT_SOURCE_DIR}/LedRs232Device.h
1717
${CURRENT_SOURCE_DIR}/LedDeviceAdalight.h
18+
${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.h
1819
${CURRENT_SOURCE_DIR}/LedDeviceAmbiLed.h
1920
${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.h
2021
)
@@ -40,6 +41,7 @@ SET(Leddevice_SOURCES
4041
${CURRENT_SOURCE_DIR}/LedRs232Device.cpp
4142

4243
${CURRENT_SOURCE_DIR}/LedDeviceAdalight.cpp
44+
${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.cpp
4345
${CURRENT_SOURCE_DIR}/LedDeviceAmbiLed.cpp
4446
${CURRENT_SOURCE_DIR}/LedDeviceLightpack.cpp
4547
${CURRENT_SOURCE_DIR}/LedDeviceMultiLightpack.cpp

libsrc/leddevice/LedDeviceAdalight.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private slots:
4040
/// Write the last data to the leds again
4141
void rewriteLeds();
4242

43-
private:
43+
protected:
4444
/// The buffer containing the packed RGB values
4545
std::vector<uint8_t> _ledBuffer;
4646

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#pragma once
2+
3+
// STL includes
4+
#include <string>
5+
6+
// Qt includes
7+
#include <QTimer>
8+
9+
// hyperion incluse
10+
#include "LedDeviceAdalight.h"
11+
12+
///
13+
/// Implementation of the LedDevice interface for writing to an Adalight led device for APA102 led strips.
14+
///
15+
class LedDeviceAdalightApa102 : public LedDeviceAdalight
16+
{
17+
Q_OBJECT
18+
19+
public:
20+
///
21+
/// Constructs the LedDevice for attached Adalight device
22+
///
23+
/// @param outputDevice The name of the output device (eg '/dev/ttyS0')
24+
/// @param baudrate The used baudrate for writing to the output device
25+
///
26+
LedDeviceAdalightApa102(const std::string& outputDevice, const unsigned baudrate, int delayAfterConnect_ms);
27+
28+
///
29+
/// Writes the led color values to the led-device
30+
///
31+
/// @param ledValues The color-value per led
32+
/// @return Zero on succes else negative
33+
///
34+
virtual int write(const std::vector<ColorRgb> & ledValues);
35+
36+
};

libsrc/leddevice/LedDeviceFactory.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "LedDevicePhilipsHue.h"
3434
#include "LedDeviceTpm2.h"
3535
#include "LedDeviceAtmo.h"
36+
#include "LedDeviceAdalightApa102.h"
3637

3738
#ifdef ENABLE_WS2812BPWM
3839
#include "LedDeviceWS2812b.h"
@@ -58,6 +59,17 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig)
5859

5960
device = deviceAdalight;
6061
}
62+
else if (type == "adalightapa102")
63+
{
64+
const std::string output = deviceConfig["output"].asString();
65+
const unsigned rate = deviceConfig["rate"].asInt();
66+
const int delay_ms = deviceConfig["delayAfterConnect"].asInt();
67+
68+
LedDeviceAdalightApa102* deviceAdalightApa102 = new LedDeviceAdalightApa102(output, rate, delay_ms);
69+
deviceAdalightApa102->open();
70+
71+
device = deviceAdalightApa102;
72+
}
6173
else if (type == "ambiled")
6274
{
6375
const std::string output = deviceConfig["output"].asString();

0 commit comments

Comments
 (0)