Merge pull request #533 from markwal/rpi_ws281x

Add new WS281x driver

Former-commit-id: 1264edf7f5e0bc29f091e72989ab7116b78056bf
This commit is contained in:
brindosch
2016-03-11 19:10:13 +01:00
9 changed files with 176 additions and 6 deletions

View File

@@ -42,6 +42,10 @@
#include "LedDeviceWS2812b.h"
#endif
#ifdef ENABLE_WS281XPWM
#include "LedDeviceWS281x.h"
#endif
LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig)
{
std::cout << "Device configuration: " << deviceConfig << std::endl;
@@ -285,6 +289,18 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig)
LedDeviceWS2812b * ledDeviceWS2812b = new LedDeviceWS2812b();
device = ledDeviceWS2812b;
}
#endif
#ifdef ENABLE_WS281XPWM
else if (type == "ws281x")
{
const int gpio = deviceConfig.get("gpio", 18).asInt();
const int leds = deviceConfig.get("leds", 12).asInt();
const uint32_t freq = deviceConfig.get("freq", (Json::UInt)800000ul).asInt();
const int dmanum = deviceConfig.get("dmanum", 5).asInt();
LedDeviceWS281x * ledDeviceWS281x = new LedDeviceWS281x(gpio, leds, freq, dmanum);
device = ledDeviceWS281x;
}
#endif
else
{