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

Commit 579f442

Browse files
committed
Minor reformat of code to match hyperion-style. Added ws2812b as option to disable for devices without dma-pwm
1 parent 1cf2f19 commit 579f442

File tree

6 files changed

+144
-155
lines changed

6 files changed

+144
-155
lines changed

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ message(STATUS "ENABLE_DISPMANX = " ${ENABLE_DISPMANX})
1313
option(ENABLE_SPIDEV "Enable the SPIDEV device" ON)
1414
message(STATUS "ENABLE_SPIDEV = " ${ENABLE_SPIDEV})
1515

16+
option(ENABLE_WS2812BPWM "Enable the WS2812b-PWM device" ON)
17+
message(STATUS "ENABLE_WS2812BPWM = " ${ENABLE_WS2812BPWM})
18+
1619
option(ENABLE_V4L2 "Enable the V4L2 grabber" ON)
1720
message(STATUS "ENABLE_V4L2 = " ${ENABLE_V4L2})
1821

@@ -22,9 +25,9 @@ message(STATUS "ENABLE_TINKERFORGE = " ${ENABLE_TINKERFORGE})
2225
option(ENABLE_PROTOBUF "Enable PROTOBUF server" ON)
2326
message(STATUS "ENABLE_PROTOBUF = " ${ENABLE_PROTOBUF})
2427

25-
if (ENABLE_V4L2 AND NOT ENABLE_PROTOBUF)
28+
if(ENABLE_V4L2 AND NOT ENABLE_PROTOBUF)
2629
message(FATAL_ERROR "V4L2 grabber requires PROTOBUF. Disable V4L2 or enable PROTOBUF")
27-
endif (ENABLE_V4L2 AND NOT ENABLE_PROTOBUF)
30+
endif(ENABLE_V4L2 AND NOT ENABLE_PROTOBUF)
2831

2932
# Createt the configuration file
3033
# configure a header file to pass some of the CMake settings

HyperionConfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
// Define to enable the spi-device
1010
#cmakedefine ENABLE_SPIDEV
1111

12+
// Define to enable the ws2812b-pwm-device
13+
#cmakedefine ENABLE_WS2812BPWM
14+
1215
// Define to enable the spi-device
1316
#cmakedefine ENABLE_TINKERFORGE
1417

libsrc/leddevice/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ if(ENABLE_SPIDEV)
6868
)
6969
endif(ENABLE_SPIDEV)
7070

71+
if(ENABLE_WS2812BPWM)
7172
SET(Leddevice_HEADERS
7273
${Leddevice_HEADERS}
7374
${CURRENT_SOURCE_DIR}/LedDeviceWS2812b.h
@@ -76,6 +77,7 @@ SET(Leddevice_SOURCES
7677
${Leddevice_SOURCES}
7778
${CURRENT_SOURCE_DIR}/LedDeviceWS2812b.cpp
7879
)
80+
endif(ENABLE_WS2812BPWM)
7981

8082
if(ENABLE_TINKERFORGE)
8183
SET(Leddevice_HEADERS

libsrc/leddevice/LedDeviceFactory.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
#include "LedDevicePhilipsHue.h"
3232
#include "LedDeviceTpm2.h"
3333

34-
#include "LedDeviceWS2812b.h"
34+
#ifdef ENABLE_WS2812BPWM
35+
#include "LedDeviceWS2812b.h"
36+
#endif
3537

3638
LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig)
3739
{
@@ -180,14 +182,17 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig)
180182
const std::string output = deviceConfig["output"].asString();
181183
const unsigned rate = deviceConfig["rate"].asInt();
182184

183-
LedDeviceTpm2* deviceTpm2 = new LedDeviceTpm2(output, rate);
185+
LedDeviceTpm2 * deviceTpm2 = new LedDeviceTpm2(output, rate);
184186
deviceTpm2->open();
185187
device = deviceTpm2;
186-
}else if (type == "ws2812b")
188+
}
189+
#ifdef ENABLE_WS2812BPWM
190+
else if (type == "ws2812b")
187191
{
188192
LedDeviceWS2812b * ledDeviceWS2812b = new LedDeviceWS2812b();
189193
device = ledDeviceWS2812b;
190194
}
195+
#endif
191196
else
192197
{
193198
std::cout << "Unable to create device " << type << std::endl;

0 commit comments

Comments
 (0)