2014-02-07 14:55:54 +01:00
|
|
|
// Stl includes
|
|
|
|
#include <string>
|
|
|
|
#include <algorithm>
|
2013-12-17 19:50:15 +01:00
|
|
|
|
2014-01-04 11:35:11 +01:00
|
|
|
// Build configuration
|
2013-12-29 20:43:01 +01:00
|
|
|
#include <HyperionConfig.h>
|
|
|
|
|
2013-12-17 19:50:15 +01:00
|
|
|
// Leddevice includes
|
|
|
|
#include <leddevice/LedDeviceFactory.h>
|
|
|
|
|
|
|
|
// Local Leddevice includes
|
2013-12-17 22:53:16 +01:00
|
|
|
#ifdef ENABLE_SPIDEV
|
|
|
|
#include "LedDeviceLpd6803.h"
|
|
|
|
#include "LedDeviceLpd8806.h"
|
2014-01-18 13:43:39 +01:00
|
|
|
#include "LedDeviceP9813.h"
|
2014-01-18 23:49:32 +01:00
|
|
|
#include "LedDeviceWs2801.h"
|
2016-05-15 18:39:17 +02:00
|
|
|
#include "LedDeviceWs2812SPI.h"
|
2014-12-03 09:34:48 +01:00
|
|
|
#include "LedDeviceAPA102.h"
|
2013-12-17 22:53:16 +01:00
|
|
|
#endif
|
|
|
|
|
2014-03-04 20:38:54 +01:00
|
|
|
#ifdef ENABLE_TINKERFORGE
|
|
|
|
#include "LedDeviceTinkerforge.h"
|
|
|
|
#endif
|
|
|
|
|
2014-01-04 11:35:11 +01:00
|
|
|
#include "LedDeviceAdalight.h"
|
2015-01-05 14:28:21 +01:00
|
|
|
#include "LedDeviceAmbiLed.h"
|
2015-11-08 16:31:18 +01:00
|
|
|
#include "LedDeviceRawHID.h"
|
2014-01-04 11:35:11 +01:00
|
|
|
#include "LedDeviceLightpack.h"
|
|
|
|
#include "LedDeviceMultiLightpack.h"
|
|
|
|
#include "LedDevicePaintpack.h"
|
|
|
|
#include "LedDevicePiBlaster.h"
|
2013-12-17 19:50:15 +01:00
|
|
|
#include "LedDeviceSedu.h"
|
2016-03-23 11:12:34 +01:00
|
|
|
#include "LedDeviceFile.h"
|
2016-01-04 12:16:44 +01:00
|
|
|
#include "LedDeviceFadeCandy.h"
|
2016-01-06 10:40:48 +01:00
|
|
|
#include "LedDeviceUdp.h"
|
2016-05-30 23:58:31 +02:00
|
|
|
#include "LedDeviceUdpRaw.h"
|
2014-03-09 11:36:46 +01:00
|
|
|
#include "LedDeviceHyperionUsbasp.h"
|
2014-04-27 12:59:44 +02:00
|
|
|
#include "LedDevicePhilipsHue.h"
|
2014-06-15 02:19:09 +02:00
|
|
|
#include "LedDeviceTpm2.h"
|
2015-02-04 21:49:33 +01:00
|
|
|
#include "LedDeviceAtmo.h"
|
2015-10-13 19:11:01 +02:00
|
|
|
#include "LedDeviceAdalightApa102.h"
|
2016-03-14 20:19:19 +01:00
|
|
|
#include "LedDeviceAtmoOrb.h"
|
2013-12-17 19:50:15 +01:00
|
|
|
|
2014-09-19 16:37:58 +02:00
|
|
|
#ifdef ENABLE_WS2812BPWM
|
|
|
|
#include "LedDeviceWS2812b.h"
|
|
|
|
#endif
|
2014-09-16 00:17:23 +02:00
|
|
|
|
2016-03-04 09:07:02 +01:00
|
|
|
#ifdef ENABLE_WS281XPWM
|
|
|
|
#include "LedDeviceWS281x.h"
|
|
|
|
#endif
|
|
|
|
|
2013-12-17 19:50:15 +01:00
|
|
|
LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig)
|
|
|
|
{
|
2016-03-23 17:40:34 +01:00
|
|
|
std::cout << "LEDDEVICE INFO: configuration: " << deviceConfig << std::endl;
|
2013-12-17 19:50:15 +01:00
|
|
|
|
|
|
|
std::string type = deviceConfig.get("type", "UNSPECIFIED").asString();
|
|
|
|
std::transform(type.begin(), type.end(), type.begin(), ::tolower);
|
|
|
|
|
|
|
|
LedDevice* device = nullptr;
|
2013-12-17 22:53:16 +01:00
|
|
|
if (false) {}
|
2014-01-04 11:35:11 +01:00
|
|
|
else if (type == "adalight")
|
2013-12-17 19:50:15 +01:00
|
|
|
{
|
|
|
|
const std::string output = deviceConfig["output"].asString();
|
|
|
|
const unsigned rate = deviceConfig["rate"].asInt();
|
2014-05-04 11:31:13 +02:00
|
|
|
const int delay_ms = deviceConfig["delayAfterConnect"].asInt();
|
2013-12-17 19:50:15 +01:00
|
|
|
|
2014-05-04 11:31:13 +02:00
|
|
|
LedDeviceAdalight* deviceAdalight = new LedDeviceAdalight(output, rate, delay_ms);
|
2014-01-04 11:35:11 +01:00
|
|
|
deviceAdalight->open();
|
2013-12-17 19:50:15 +01:00
|
|
|
|
2014-01-04 11:35:11 +01:00
|
|
|
device = deviceAdalight;
|
2013-12-17 19:50:15 +01:00
|
|
|
}
|
2015-10-13 19:11:01 +02:00
|
|
|
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;
|
|
|
|
}
|
2015-01-05 14:28:21 +01:00
|
|
|
else if (type == "ambiled")
|
|
|
|
{
|
|
|
|
const std::string output = deviceConfig["output"].asString();
|
|
|
|
const unsigned rate = deviceConfig["rate"].asInt();
|
|
|
|
const int delay_ms = deviceConfig["delayAfterConnect"].asInt();
|
|
|
|
|
|
|
|
LedDeviceAmbiLed* deviceAmbiLed = new LedDeviceAmbiLed(output, rate, delay_ms);
|
|
|
|
deviceAmbiLed->open();
|
|
|
|
|
|
|
|
device = deviceAmbiLed;
|
|
|
|
}
|
2014-01-04 11:35:11 +01:00
|
|
|
#ifdef ENABLE_SPIDEV
|
2013-12-17 19:50:15 +01:00
|
|
|
else if (type == "lpd6803" || type == "ldp6803")
|
|
|
|
{
|
|
|
|
const std::string output = deviceConfig["output"].asString();
|
|
|
|
const unsigned rate = deviceConfig["rate"].asInt();
|
|
|
|
|
|
|
|
LedDeviceLpd6803* deviceLdp6803 = new LedDeviceLpd6803(output, rate);
|
|
|
|
deviceLdp6803->open();
|
|
|
|
|
|
|
|
device = deviceLdp6803;
|
|
|
|
}
|
|
|
|
else if (type == "lpd8806" || type == "ldp8806")
|
|
|
|
{
|
|
|
|
const std::string output = deviceConfig["output"].asString();
|
|
|
|
const unsigned rate = deviceConfig["rate"].asInt();
|
|
|
|
|
|
|
|
LedDeviceLpd8806* deviceLpd8806 = new LedDeviceLpd8806(output, rate);
|
|
|
|
deviceLpd8806->open();
|
|
|
|
|
|
|
|
device = deviceLpd8806;
|
|
|
|
}
|
2014-01-18 23:57:47 +01:00
|
|
|
else if (type == "p9813")
|
|
|
|
{
|
|
|
|
const std::string output = deviceConfig["output"].asString();
|
|
|
|
const unsigned rate = deviceConfig["rate"].asInt();
|
|
|
|
|
|
|
|
LedDeviceP9813* deviceP9813 = new LedDeviceP9813(output, rate);
|
|
|
|
deviceP9813->open();
|
|
|
|
|
|
|
|
device = deviceP9813;
|
2014-12-03 18:41:44 +01:00
|
|
|
}
|
2014-12-03 09:34:48 +01:00
|
|
|
else if (type == "apa102")
|
|
|
|
{
|
|
|
|
const std::string output = deviceConfig["output"].asString();
|
|
|
|
const unsigned rate = deviceConfig["rate"].asInt();
|
2016-05-10 12:16:19 +02:00
|
|
|
const unsigned ledcount = deviceConfig.get("leds",0).asInt();
|
2014-12-03 09:34:48 +01:00
|
|
|
|
2016-05-10 12:16:19 +02:00
|
|
|
LedDeviceAPA102* deviceAPA102 = new LedDeviceAPA102(output, rate, ledcount);
|
2014-12-03 09:34:48 +01:00
|
|
|
deviceAPA102->open();
|
|
|
|
|
|
|
|
device = deviceAPA102;
|
2014-01-18 23:57:47 +01:00
|
|
|
}
|
2014-01-04 11:35:11 +01:00
|
|
|
else if (type == "ws2801" || type == "lightberry")
|
|
|
|
{
|
|
|
|
const std::string output = deviceConfig["output"].asString();
|
|
|
|
const unsigned rate = deviceConfig["rate"].asInt();
|
2016-02-13 13:00:31 +01:00
|
|
|
const unsigned latchtime = deviceConfig.get("latchtime",500000).asInt();
|
2014-01-04 11:35:11 +01:00
|
|
|
|
2016-02-13 13:00:31 +01:00
|
|
|
LedDeviceWs2801* deviceWs2801 = new LedDeviceWs2801(output, rate, latchtime);
|
2014-01-04 11:35:11 +01:00
|
|
|
deviceWs2801->open();
|
|
|
|
|
|
|
|
device = deviceWs2801;
|
|
|
|
}
|
2016-05-15 18:39:17 +02:00
|
|
|
else if (type == "ws2812spi")
|
|
|
|
{
|
|
|
|
const std::string output = deviceConfig["output"].asString();
|
|
|
|
const unsigned rate = deviceConfig.get("rate",2857143).asInt();
|
|
|
|
|
|
|
|
LedDeviceWs2812SPI* deviceWs2812SPI = new LedDeviceWs2812SPI(output, rate);
|
|
|
|
deviceWs2812SPI->open();
|
|
|
|
|
|
|
|
device = deviceWs2812SPI;
|
|
|
|
}
|
2013-12-19 09:29:26 +01:00
|
|
|
#endif
|
2014-03-04 20:38:54 +01:00
|
|
|
#ifdef ENABLE_TINKERFORGE
|
2014-03-09 11:42:20 +01:00
|
|
|
else if (type=="tinkerforge")
|
2014-03-04 20:38:54 +01:00
|
|
|
{
|
|
|
|
const std::string host = deviceConfig.get("output", "127.0.0.1").asString();
|
|
|
|
const uint16_t port = deviceConfig.get("port", 4223).asInt();
|
|
|
|
const std::string uid = deviceConfig["uid"].asString();
|
|
|
|
const unsigned rate = deviceConfig["rate"].asInt();
|
|
|
|
|
|
|
|
LedDeviceTinkerforge* deviceTinkerforge = new LedDeviceTinkerforge(host, port, uid, rate);
|
|
|
|
deviceTinkerforge->open();
|
|
|
|
|
|
|
|
device = deviceTinkerforge;
|
|
|
|
}
|
2013-12-19 09:29:26 +01:00
|
|
|
#endif
|
2015-11-08 16:31:18 +01:00
|
|
|
else if (type == "rawhid")
|
|
|
|
{
|
|
|
|
const int delay_ms = deviceConfig["delayAfterConnect"].asInt();
|
|
|
|
auto VendorIdString = deviceConfig.get("VID", "0x2341").asString();
|
|
|
|
auto ProductIdString = deviceConfig.get("PID", "0x8036").asString();
|
|
|
|
|
|
|
|
// Convert HEX values to integer
|
|
|
|
auto VendorId = std::stoul(VendorIdString, nullptr, 16);
|
|
|
|
auto ProductId = std::stoul(ProductIdString, nullptr, 16);
|
|
|
|
|
|
|
|
LedDeviceRawHID* deviceHID = new LedDeviceRawHID(VendorId, ProductId, delay_ms);
|
|
|
|
deviceHID->open();
|
|
|
|
|
|
|
|
device = deviceHID;
|
|
|
|
}
|
2013-12-17 19:50:15 +01:00
|
|
|
else if (type == "lightpack")
|
|
|
|
{
|
|
|
|
const std::string output = deviceConfig.get("output", "").asString();
|
|
|
|
|
|
|
|
LedDeviceLightpack* deviceLightpack = new LedDeviceLightpack();
|
|
|
|
deviceLightpack->open(output);
|
|
|
|
|
|
|
|
device = deviceLightpack;
|
|
|
|
}
|
2016-03-22 01:01:54 +01:00
|
|
|
else if (type == "multi-lightpack")
|
2014-01-04 11:35:11 +01:00
|
|
|
{
|
|
|
|
LedDeviceMultiLightpack* deviceLightpack = new LedDeviceMultiLightpack();
|
|
|
|
deviceLightpack->open();
|
|
|
|
|
|
|
|
device = deviceLightpack;
|
|
|
|
}
|
2013-12-17 19:50:15 +01:00
|
|
|
else if (type == "paintpack")
|
|
|
|
{
|
2015-11-08 16:32:53 +01:00
|
|
|
const int delay_ms = deviceConfig["delayAfterConnect"].asInt();
|
|
|
|
auto VendorIdString = deviceConfig.get("VID", "0x0EBF").asString();
|
|
|
|
auto ProductIdString = deviceConfig.get("PID", "0x0025").asString();
|
|
|
|
|
|
|
|
// Convert HEX values to integer
|
|
|
|
auto VendorId = std::stoul(VendorIdString, nullptr, 16);
|
|
|
|
auto ProductId = std::stoul(ProductIdString, nullptr, 16);
|
|
|
|
|
|
|
|
LedDevicePaintpack * devicePainLightpack = new LedDevicePaintpack(VendorId, ProductId, delay_ms);
|
2013-12-17 19:50:15 +01:00
|
|
|
devicePainLightpack->open();
|
|
|
|
|
|
|
|
device = devicePainLightpack;
|
|
|
|
}
|
2014-01-04 11:35:11 +01:00
|
|
|
else if (type == "piblaster")
|
2013-12-17 19:50:15 +01:00
|
|
|
{
|
2014-01-04 11:35:11 +01:00
|
|
|
const std::string output = deviceConfig.get("output", "").asString();
|
|
|
|
const std::string assignment = deviceConfig.get("assignment", "").asString();
|
2016-04-29 16:00:33 +02:00
|
|
|
const Json::Value gpioMapping = deviceConfig.get("gpiomap", Json::nullValue);
|
|
|
|
|
|
|
|
if (assignment.length() > 0) {
|
|
|
|
std::cout << "ERROR: Sorry, the configuration syntax has changed in this version." << std::endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
if (! gpioMapping.isNull() ) {
|
|
|
|
LedDevicePiBlaster * devicePiBlaster = new LedDevicePiBlaster(output, gpioMapping);
|
|
|
|
devicePiBlaster->open();
|
|
|
|
|
|
|
|
device = devicePiBlaster;
|
|
|
|
} else {
|
|
|
|
std::cout << "ERROR: no gpiomap defined." << std::endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2014-01-04 11:35:11 +01:00
|
|
|
}
|
|
|
|
else if (type == "sedu")
|
|
|
|
{
|
|
|
|
const std::string output = deviceConfig["output"].asString();
|
|
|
|
const unsigned rate = deviceConfig["rate"].asInt();
|
|
|
|
|
|
|
|
LedDeviceSedu* deviceSedu = new LedDeviceSedu(output, rate);
|
|
|
|
deviceSedu->open();
|
|
|
|
|
|
|
|
device = deviceSedu;
|
2013-12-17 19:50:15 +01:00
|
|
|
}
|
2014-03-09 11:36:46 +01:00
|
|
|
else if (type == "hyperion-usbasp-ws2801")
|
|
|
|
{
|
|
|
|
LedDeviceHyperionUsbasp * deviceHyperionUsbasp = new LedDeviceHyperionUsbasp(LedDeviceHyperionUsbasp::CMD_WRITE_WS2801);
|
|
|
|
deviceHyperionUsbasp->open();
|
|
|
|
device = deviceHyperionUsbasp;
|
|
|
|
}
|
|
|
|
else if (type == "hyperion-usbasp-ws2812")
|
|
|
|
{
|
|
|
|
LedDeviceHyperionUsbasp * deviceHyperionUsbasp = new LedDeviceHyperionUsbasp(LedDeviceHyperionUsbasp::CMD_WRITE_WS2812);
|
|
|
|
deviceHyperionUsbasp->open();
|
|
|
|
device = deviceHyperionUsbasp;
|
|
|
|
}
|
2014-04-27 12:59:44 +02:00
|
|
|
else if (type == "philipshue")
|
|
|
|
{
|
|
|
|
const std::string output = deviceConfig["output"].asString();
|
2015-02-01 15:29:40 +01:00
|
|
|
const std::string username = deviceConfig.get("username", "newdeveloper").asString();
|
2014-07-16 20:22:37 +02:00
|
|
|
const bool switchOffOnBlack = deviceConfig.get("switchOffOnBlack", true).asBool();
|
2015-02-01 15:56:51 +01:00
|
|
|
const int transitiontime = deviceConfig.get("transitiontime", 1).asInt();
|
2015-03-03 15:45:09 +01:00
|
|
|
std::vector<unsigned int> lightIds;
|
2015-03-07 09:58:48 +01:00
|
|
|
for (Json::Value::ArrayIndex i = 0; i < deviceConfig["lightIds"].size(); i++) {
|
2015-03-03 15:45:09 +01:00
|
|
|
lightIds.push_back(deviceConfig["lightIds"][i].asInt());
|
|
|
|
}
|
|
|
|
device = new LedDevicePhilipsHue(output, username, switchOffOnBlack, transitiontime, lightIds);
|
2014-04-27 12:59:44 +02:00
|
|
|
}
|
2016-04-02 00:07:28 +02:00
|
|
|
else if (type == "atmoorb")
|
|
|
|
{
|
2016-03-15 12:06:24 +01:00
|
|
|
const std::string output = deviceConfig["output"].asString();
|
2016-04-02 00:07:28 +02:00
|
|
|
const bool useOrbSmoothing = deviceConfig.get("useOrbSmoothing", false).asBool();
|
2016-03-15 12:06:24 +01:00
|
|
|
const int transitiontime = deviceConfig.get("transitiontime", 1).asInt();
|
2016-04-02 00:07:28 +02:00
|
|
|
const int skipSmoothingDiff = deviceConfig.get("skipSmoothingDiff", 0).asInt();
|
2016-03-15 12:06:24 +01:00
|
|
|
const int port = deviceConfig.get("port", 1).asInt();
|
|
|
|
const int numLeds = deviceConfig.get("numLeds", 1).asInt();
|
2016-04-02 00:07:28 +02:00
|
|
|
const std::string orbId = deviceConfig["orbIds"].asString();
|
2016-03-15 12:06:24 +01:00
|
|
|
std::vector<unsigned int> orbIds;
|
2016-03-14 20:19:19 +01:00
|
|
|
|
2016-03-15 18:37:55 +01:00
|
|
|
// If we find multiple Orb ids separate them and add to list
|
|
|
|
const std::string separator (",");
|
|
|
|
if (orbId.find(separator) != std::string::npos) {
|
2016-04-02 00:07:28 +02:00
|
|
|
std::stringstream ss(orbId);
|
|
|
|
std::vector<int> output;
|
|
|
|
unsigned int i;
|
|
|
|
while (ss >> i) {
|
|
|
|
orbIds.push_back(i);
|
|
|
|
if (ss.peek() == ',' || ss.peek() == ' ')
|
|
|
|
ss.ignore();
|
|
|
|
}
|
2016-03-15 18:37:55 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-02 00:07:28 +02:00
|
|
|
orbIds.push_back(atoi(orbId.c_str()));
|
2016-03-15 18:37:55 +01:00
|
|
|
}
|
|
|
|
|
2016-04-02 00:07:28 +02:00
|
|
|
device = new LedDeviceAtmoOrb(output, useOrbSmoothing, transitiontime, skipSmoothingDiff, port, numLeds, orbIds);
|
|
|
|
}
|
2016-03-23 11:12:34 +01:00
|
|
|
else if (type == "file")
|
2013-12-17 19:50:15 +01:00
|
|
|
{
|
2016-03-23 11:28:31 +01:00
|
|
|
const std::string output = deviceConfig.get("output", "/dev/null").asString();
|
2016-03-23 11:12:34 +01:00
|
|
|
device = new LedDeviceFile(output);
|
2013-12-17 19:50:15 +01:00
|
|
|
}
|
2016-01-04 12:16:44 +01:00
|
|
|
else if (type == "fadecandy")
|
|
|
|
{
|
2016-01-27 10:44:51 +01:00
|
|
|
const std::string host = deviceConfig.get("output", "127.0.0.1").asString();
|
|
|
|
const uint16_t port = deviceConfig.get("port", 7890).asInt();
|
|
|
|
const uint16_t channel = deviceConfig.get("channel", 0).asInt();
|
|
|
|
device = new LedDeviceFadeCandy(host, port, channel);
|
2016-01-04 12:16:44 +01:00
|
|
|
}
|
2016-01-06 10:40:48 +01:00
|
|
|
else if (type == "udp")
|
|
|
|
{
|
|
|
|
const std::string output = deviceConfig["output"].asString();
|
|
|
|
const unsigned rate = deviceConfig["rate"].asInt();
|
|
|
|
const unsigned protocol = deviceConfig["protocol"].asInt();
|
|
|
|
const unsigned maxPacket = deviceConfig["maxpacket"].asInt();
|
|
|
|
device = new LedDeviceUdp(output, rate, protocol, maxPacket);
|
|
|
|
}
|
2016-05-30 23:58:31 +02:00
|
|
|
else if (type == "udpraw")
|
|
|
|
{
|
|
|
|
const std::string output = deviceConfig["output"].asString();
|
|
|
|
const unsigned rate = deviceConfig["rate"].asInt();
|
|
|
|
const unsigned latchtime = deviceConfig.get("latchtime",500000).asInt();
|
|
|
|
|
|
|
|
LedDeviceUdpRaw* deviceUdpRaw = new LedDeviceUdpRaw(output, rate, latchtime);
|
|
|
|
deviceUdpRaw->open();
|
|
|
|
device = deviceUdpRaw;
|
|
|
|
}
|
2014-06-15 02:19:09 +02:00
|
|
|
else if (type == "tpm2")
|
|
|
|
{
|
|
|
|
const std::string output = deviceConfig["output"].asString();
|
|
|
|
const unsigned rate = deviceConfig["rate"].asInt();
|
|
|
|
|
2014-09-19 16:37:58 +02:00
|
|
|
LedDeviceTpm2 * deviceTpm2 = new LedDeviceTpm2(output, rate);
|
2014-06-15 02:19:09 +02:00
|
|
|
deviceTpm2->open();
|
|
|
|
device = deviceTpm2;
|
2014-09-19 16:37:58 +02:00
|
|
|
}
|
2015-02-04 21:49:33 +01:00
|
|
|
else if (type == "atmo")
|
|
|
|
{
|
|
|
|
const std::string output = deviceConfig["output"].asString();
|
|
|
|
const unsigned rate = 38400;
|
|
|
|
|
|
|
|
LedDeviceAtmo * deviceAtmo = new LedDeviceAtmo(output, rate);
|
|
|
|
deviceAtmo->open();
|
|
|
|
device = deviceAtmo;
|
|
|
|
}
|
2014-09-19 16:37:58 +02:00
|
|
|
#ifdef ENABLE_WS2812BPWM
|
|
|
|
else if (type == "ws2812b")
|
2014-09-16 00:17:23 +02:00
|
|
|
{
|
2014-09-17 21:20:36 +02:00
|
|
|
LedDeviceWS2812b * ledDeviceWS2812b = new LedDeviceWS2812b();
|
|
|
|
device = ledDeviceWS2812b;
|
2014-06-15 02:19:09 +02:00
|
|
|
}
|
2016-03-04 09:07:02 +01:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_WS281XPWM
|
|
|
|
else if (type == "ws281x")
|
|
|
|
{
|
|
|
|
const int gpio = deviceConfig.get("gpio", 18).asInt();
|
2016-03-22 13:50:14 +01:00
|
|
|
const int leds = deviceConfig.get("leds", 256).asInt();
|
2016-03-04 09:07:02 +01:00
|
|
|
const uint32_t freq = deviceConfig.get("freq", (Json::UInt)800000ul).asInt();
|
|
|
|
const int dmanum = deviceConfig.get("dmanum", 5).asInt();
|
2016-03-21 05:22:19 +01:00
|
|
|
const int pwmchannel = deviceConfig.get("pwmchannel", 0).asInt();
|
2016-03-22 13:50:14 +01:00
|
|
|
const int invert = deviceConfig.get("invert", 0).asInt();
|
2016-03-04 09:07:02 +01:00
|
|
|
|
2016-03-22 13:50:14 +01:00
|
|
|
LedDeviceWS281x * ledDeviceWS281x = new LedDeviceWS281x(gpio, leds, freq, dmanum, pwmchannel, invert);
|
2016-03-04 09:07:02 +01:00
|
|
|
device = ledDeviceWS281x;
|
|
|
|
}
|
2014-09-19 16:37:58 +02:00
|
|
|
#endif
|
2013-12-17 19:50:15 +01:00
|
|
|
else
|
|
|
|
{
|
2016-03-23 17:40:34 +01:00
|
|
|
std::cout << "LEDDEVICE ERROR: Unknown/Unimplemented device " << type << std::endl;
|
2013-12-17 19:50:15 +01:00
|
|
|
// Unknown / Unimplemented device
|
2016-05-10 12:16:19 +02:00
|
|
|
exit(1);
|
2013-12-17 19:50:15 +01:00
|
|
|
}
|
|
|
|
return device;
|
|
|
|
}
|