From b63753f5dc6954353b2ac93b5d2cc8cb249ea897 Mon Sep 17 00:00:00 2001 From: "T. van der Zwan" Date: Tue, 17 Dec 2013 18:50:15 +0000 Subject: [PATCH] Moved all devices to separate library and added 'Factory' for device creation. Former-commit-id: 26cab1b85b00406240689ad9c1018f0307028fe4 --- include/hyperion/Hyperion.h | 3 +- include/hyperion/PriorityMuxer.h | 3 - include/{hyperion => leddevice}/LedDevice.h | 0 include/leddevice/LedDeviceFactory.h | 27 ++++ libsrc/CMakeLists.txt | 1 + libsrc/hyperion/CMakeLists.txt | 40 +----- libsrc/hyperion/Hyperion.cpp | 126 +----------------- libsrc/hyperion/LinearColorSmoothing.h | 2 +- libsrc/leddevice/CMakeLists.txt | 69 ++++++++++ .../LedDeviceAdalight.cpp | 0 .../device => leddevice}/LedDeviceAdalight.h | 0 libsrc/leddevice/LedDeviceFactory.cpp | 126 ++++++++++++++++++ .../LedDeviceLightpack-hidapi.cpp | 0 .../LedDeviceLightpack-hidapi.h | 0 .../LedDeviceLightpack.cpp | 0 .../device => leddevice}/LedDeviceLightpack.h | 2 +- .../device => leddevice}/LedDeviceLpd6803.cpp | 0 .../device => leddevice}/LedDeviceLpd6803.h | 0 .../device => leddevice}/LedDeviceLpd8806.cpp | 0 .../device => leddevice}/LedDeviceLpd8806.h | 0 .../LedDeviceMultiLightpack.cpp | 0 .../LedDeviceMultiLightpack.h | 2 +- .../LedDevicePaintpack.cpp | 0 .../device => leddevice}/LedDevicePaintpack.h | 2 +- .../device => leddevice}/LedDeviceSedu.cpp | 0 .../device => leddevice}/LedDeviceSedu.h | 0 .../device => leddevice}/LedDeviceTest.cpp | 0 .../device => leddevice}/LedDeviceTest.h | 4 +- .../device => leddevice}/LedDeviceWs2801.cpp | 0 .../device => leddevice}/LedDeviceWs2801.h | 0 .../device => leddevice}/LedDeviceWs2811.cpp | 0 .../device => leddevice}/LedDeviceWs2811.h | 0 .../device => leddevice}/LedRs232Device.cpp | 0 .../device => leddevice}/LedRs232Device.h | 4 +- .../device => leddevice}/LedSpiDevice.cpp | 0 .../device => leddevice}/LedSpiDevice.h | 2 +- test/TestSpi.cpp | 2 +- 37 files changed, 240 insertions(+), 175 deletions(-) rename include/{hyperion => leddevice}/LedDevice.h (100%) create mode 100644 include/leddevice/LedDeviceFactory.h create mode 100644 libsrc/leddevice/CMakeLists.txt rename libsrc/{hyperion/device => leddevice}/LedDeviceAdalight.cpp (100%) rename libsrc/{hyperion/device => leddevice}/LedDeviceAdalight.h (100%) create mode 100644 libsrc/leddevice/LedDeviceFactory.cpp rename libsrc/{hyperion/device => leddevice}/LedDeviceLightpack-hidapi.cpp (100%) rename libsrc/{hyperion/device => leddevice}/LedDeviceLightpack-hidapi.h (100%) rename libsrc/{hyperion/device => leddevice}/LedDeviceLightpack.cpp (100%) rename libsrc/{hyperion/device => leddevice}/LedDeviceLightpack.h (98%) rename libsrc/{hyperion/device => leddevice}/LedDeviceLpd6803.cpp (100%) rename libsrc/{hyperion/device => leddevice}/LedDeviceLpd6803.h (100%) rename libsrc/{hyperion/device => leddevice}/LedDeviceLpd8806.cpp (100%) rename libsrc/{hyperion/device => leddevice}/LedDeviceLpd8806.h (100%) rename libsrc/{hyperion/device => leddevice}/LedDeviceMultiLightpack.cpp (100%) rename libsrc/{hyperion/device => leddevice}/LedDeviceMultiLightpack.h (97%) rename libsrc/{hyperion/device => leddevice}/LedDevicePaintpack.cpp (100%) rename libsrc/{hyperion/device => leddevice}/LedDevicePaintpack.h (96%) rename libsrc/{hyperion/device => leddevice}/LedDeviceSedu.cpp (100%) rename libsrc/{hyperion/device => leddevice}/LedDeviceSedu.h (100%) rename libsrc/{hyperion/device => leddevice}/LedDeviceTest.cpp (100%) rename libsrc/{hyperion/device => leddevice}/LedDeviceTest.h (93%) rename libsrc/{hyperion/device => leddevice}/LedDeviceWs2801.cpp (100%) rename libsrc/{hyperion/device => leddevice}/LedDeviceWs2801.h (100%) rename libsrc/{hyperion/device => leddevice}/LedDeviceWs2811.cpp (100%) rename libsrc/{hyperion/device => leddevice}/LedDeviceWs2811.h (100%) rename libsrc/{hyperion/device => leddevice}/LedRs232Device.cpp (100%) rename libsrc/{hyperion/device => leddevice}/LedRs232Device.h (95%) rename libsrc/{hyperion/device => leddevice}/LedSpiDevice.cpp (100%) rename libsrc/{hyperion/device => leddevice}/LedSpiDevice.h (98%) diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index cb092c2e..9689d97d 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -12,13 +12,13 @@ // Hyperion includes #include -#include #include // Effect engine includes #include // Forward class declaration +class LedDevice; class ColorTransform; class EffectEngine; class HsvTransform; @@ -158,7 +158,6 @@ public slots: int setEffect(const std::string & effectName, const Json::Value & args, int priority, int timeout = -1); public: - static LedDevice * createDevice(const Json::Value & deviceConfig); static ColorOrder createColorOrder(const Json::Value & deviceConfig); static LedString createLedString(const Json::Value & ledsConfig); diff --git a/include/hyperion/PriorityMuxer.h b/include/hyperion/PriorityMuxer.h index bc2aaaaa..79342c5f 100644 --- a/include/hyperion/PriorityMuxer.h +++ b/include/hyperion/PriorityMuxer.h @@ -12,9 +12,6 @@ // Utils includes #include -// Hyperion includes -#include - /// /// The PriorityMuxer handles the priority channels. Led values input is written to the priority map /// and the muxer keeps track of all active priorities. The current priority can be queried and per diff --git a/include/hyperion/LedDevice.h b/include/leddevice/LedDevice.h similarity index 100% rename from include/hyperion/LedDevice.h rename to include/leddevice/LedDevice.h diff --git a/include/leddevice/LedDeviceFactory.h b/include/leddevice/LedDeviceFactory.h new file mode 100644 index 00000000..898efbf1 --- /dev/null +++ b/include/leddevice/LedDeviceFactory.h @@ -0,0 +1,27 @@ + +#pragma once + +// Json includes +#include + +// Leddevice includes +#include + + +/// +/// The LedDeviceFactory is responsible for constructing 'LedDevices' +/// +class LedDeviceFactory +{ +public: + + /// + /// Constructs a LedDevice based on the given configuration + /// + /// @param deviceConfig The configuration of the led-device + /// + /// @return The constructed LedDevice or nullptr if configuration is invalid. The ownership of + /// the constructed LedDevice is tranferred to the caller + /// + static LedDevice * construct(const Json::Value & deviceConfig); +}; diff --git a/libsrc/CMakeLists.txt b/libsrc/CMakeLists.txt index ee82011c..8eab4b33 100644 --- a/libsrc/CMakeLists.txt +++ b/libsrc/CMakeLists.txt @@ -7,6 +7,7 @@ add_subdirectory(hyperion) add_subdirectory(jsonserver) add_subdirectory(protoserver) add_subdirectory(boblightserver) +add_subdirectory(leddevice) add_subdirectory(utils) add_subdirectory(xbmcvideochecker) add_subdirectory(effectengine) diff --git a/libsrc/hyperion/CMakeLists.txt b/libsrc/hyperion/CMakeLists.txt index abc5f862..3723ef35 100644 --- a/libsrc/hyperion/CMakeLists.txt +++ b/libsrc/hyperion/CMakeLists.txt @@ -3,27 +3,17 @@ SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/hyperion) SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/hyperion) -#add libusb and pthreads (required for the Lighpack usb device) -find_package(libusb-1.0 REQUIRED) -find_package(Threads REQUIRED) - -include_directories( - ../../include/hidapi - ${LIBUSB_1_INCLUDE_DIRS}) # for Lightpack device - # Group the headers that go through the MOC compiler SET(Hyperion_QT_HEADERS ${CURRENT_HEADER_DIR}/Hyperion.h ${CURRENT_SOURCE_DIR}/LinearColorSmoothing.h - ${CURRENT_SOURCE_DIR}/device/LedDeviceAdalight.h ) SET(Hyperion_HEADERS ${CURRENT_HEADER_DIR}/ImageProcessor.h ${CURRENT_HEADER_DIR}/ImageProcessorFactory.h ${CURRENT_HEADER_DIR}/ImageToLedsMap.h - ${CURRENT_HEADER_DIR}/LedDevice.h ${CURRENT_HEADER_DIR}/LedString.h ${CURRENT_HEADER_DIR}/PriorityMuxer.h @@ -31,18 +21,6 @@ SET(Hyperion_HEADERS ${CURRENT_HEADER_DIR}/BlackBorderProcessor.h ${CURRENT_SOURCE_DIR}/MultiColorTransform.h - - ${CURRENT_SOURCE_DIR}/device/LedSpiDevice.h - ${CURRENT_SOURCE_DIR}/device/LedRs232Device.h - ${CURRENT_SOURCE_DIR}/device/LedDeviceTest.h - ${CURRENT_SOURCE_DIR}/device/LedDeviceSedu.h - ${CURRENT_SOURCE_DIR}/device/LedDeviceWs2801.h - ${CURRENT_SOURCE_DIR}/device/LedDeviceWs2811.h - ${CURRENT_SOURCE_DIR}/device/LedDeviceLpd6803.h - ${CURRENT_SOURCE_DIR}/device/LedDeviceLpd8806.h - ${CURRENT_SOURCE_DIR}/device/LedDeviceLightpack.h - ${CURRENT_SOURCE_DIR}/device/LedDevicePaintpack.h - ${CURRENT_SOURCE_DIR}/device/LedDeviceMultiLightpack.h ) SET(Hyperion_SOURCES @@ -57,19 +35,6 @@ SET(Hyperion_SOURCES ${CURRENT_SOURCE_DIR}/ImageToLedsMap.cpp ${CURRENT_SOURCE_DIR}/MultiColorTransform.cpp ${CURRENT_SOURCE_DIR}/LinearColorSmoothing.cpp - - ${CURRENT_SOURCE_DIR}/device/LedSpiDevice.cpp - ${CURRENT_SOURCE_DIR}/device/LedRs232Device.cpp - ${CURRENT_SOURCE_DIR}/device/LedDeviceSedu.cpp - ${CURRENT_SOURCE_DIR}/device/LedDeviceTest.cpp - ${CURRENT_SOURCE_DIR}/device/LedDeviceWs2801.cpp - ${CURRENT_SOURCE_DIR}/device/LedDeviceWs2811.cpp - ${CURRENT_SOURCE_DIR}/device/LedDeviceLpd6803.cpp - ${CURRENT_SOURCE_DIR}/device/LedDeviceLpd8806.cpp - ${CURRENT_SOURCE_DIR}/device/LedDeviceAdalight.cpp - ${CURRENT_SOURCE_DIR}/device/LedDeviceLightpack.cpp - ${CURRENT_SOURCE_DIR}/device/LedDevicePaintpack.cpp - ${CURRENT_SOURCE_DIR}/device/LedDeviceMultiLightpack.cpp ) set(Hyperion_RESOURCES @@ -78,7 +43,7 @@ set(Hyperion_RESOURCES QT4_WRAP_CPP(Hyperion_HEADERS_MOC ${Hyperion_QT_HEADERS}) -qt4_add_resources(Hyperion_RESOURCES_RCC ${Hyperion_RESOURCES} OPTIONS "-no-compress") +QT4_ADD_RESOURCES(Hyperion_RESOURCES_RCC ${Hyperion_RESOURCES} OPTIONS "-no-compress") add_library(hyperion ${Hyperion_HEADERS} @@ -90,10 +55,9 @@ add_library(hyperion target_link_libraries(hyperion hyperion-utils + leddevice effectengine hidapi-libusb serialport - ${LIBUSB_1_LIBRARIES} #apt-get install libusb-1.0-0-dev - ${CMAKE_THREAD_LIBS_INIT} ${QT_LIBRARIES} ) diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index 518c7631..3b726ed5 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -14,19 +14,11 @@ // hyperion include #include -#include #include -#include "device/LedDeviceLpd6803.h" -#include "device/LedDeviceLpd8806.h" -#include "device/LedDeviceSedu.h" -#include "device/LedDeviceTest.h" -#include "device/LedDeviceWs2801.h" -#include "device/LedDeviceWs2811.h" -#include "device/LedDeviceAdalight.h" -#include "device/LedDevicePaintpack.h" -#include "device/LedDeviceLightpack.h" -#include "device/LedDeviceMultiLightpack.h" +// Leddevice includes +#include +#include #include "MultiColorTransform.h" #include "LinearColorSmoothing.h" @@ -34,116 +26,6 @@ // effect engine includes #include -LedDevice* Hyperion::createDevice(const Json::Value& deviceConfig) -{ - std::cout << "Device configuration: " << deviceConfig << std::endl; - - std::string type = deviceConfig.get("type", "UNSPECIFIED").asString(); - std::transform(type.begin(), type.end(), type.begin(), ::tolower); - - LedDevice* device = nullptr; - if (type == "ws2801" || type == "lightberry") - { - const std::string output = deviceConfig["output"].asString(); - const unsigned rate = deviceConfig["rate"].asInt(); - - LedDeviceWs2801* deviceWs2801 = new LedDeviceWs2801(output, rate); - deviceWs2801->open(); - - device = deviceWs2801; - } - else if (type == "ws2811") - { - const std::string output = deviceConfig["output"].asString(); - const std::string outputSpeed = deviceConfig["output"].asString(); - const std::string timingOption = deviceConfig["timingOption"].asString(); - - ws2811::SpeedMode speedMode = (outputSpeed == "high")? ws2811::highspeed : ws2811::lowspeed; - if (outputSpeed != "high" && outputSpeed != "low") - { - std::cerr << "Incorrect speed-mode selected for WS2811: " << outputSpeed << " != {'high', 'low'}" << std::endl; - } - - LedDeviceWs2811 * deviceWs2811 = new LedDeviceWs2811(output, ws2811::fromString(timingOption, ws2811::option_2855), speedMode); - deviceWs2811->open(); - - device = deviceWs2811; - } - 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; - } - 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; - } - else if (type == "adalight") - { - const std::string output = deviceConfig["output"].asString(); - const unsigned rate = deviceConfig["rate"].asInt(); - - LedDeviceAdalight* deviceAdalight = new LedDeviceAdalight(output, rate); - deviceAdalight->open(); - - device = deviceAdalight; - } - else if (type == "lightpack") - { - const std::string output = deviceConfig.get("output", "").asString(); - - LedDeviceLightpack* deviceLightpack = new LedDeviceLightpack(); - deviceLightpack->open(output); - - device = deviceLightpack; - } - else if (type == "paintpack") - { - LedDevicePaintpack * devicePainLightpack = new LedDevicePaintpack(); - devicePainLightpack->open(); - - device = devicePainLightpack; - } - else if (type == "multi-lightpack") - { - LedDeviceMultiLightpack* deviceLightpack = new LedDeviceMultiLightpack(); - deviceLightpack->open(); - - device = deviceLightpack; - } - else if (type == "test") - { - const std::string output = deviceConfig["output"].asString(); - device = new LedDeviceTest(output); - } - else - { - std::cout << "Unable to create device " << type << std::endl; - // Unknown / Unimplemented device - } - return device; -} Hyperion::ColorOrder Hyperion::createColorOrder(const Json::Value &deviceConfig) { @@ -379,7 +261,7 @@ Hyperion::Hyperion(const Json::Value &jsonConfig) : _muxer(_ledString.leds().size()), _raw2ledTransform(createLedColorsTransform(_ledString.leds().size(), jsonConfig["color"])), _colorOrder(createColorOrder(jsonConfig["device"])), - _device(createDevice(jsonConfig["device"])), + _device(LedDeviceFactory::construct(jsonConfig["device"])), _effectEngine(nullptr), _timer() { diff --git a/libsrc/hyperion/LinearColorSmoothing.h b/libsrc/hyperion/LinearColorSmoothing.h index a0b706a0..9035248b 100644 --- a/libsrc/hyperion/LinearColorSmoothing.h +++ b/libsrc/hyperion/LinearColorSmoothing.h @@ -11,7 +11,7 @@ #include // hyperion incluse -#include +#include /// Linear Smooting class /// diff --git a/libsrc/leddevice/CMakeLists.txt b/libsrc/leddevice/CMakeLists.txt new file mode 100644 index 00000000..9a224036 --- /dev/null +++ b/libsrc/leddevice/CMakeLists.txt @@ -0,0 +1,69 @@ + +# Define the current source locations +SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/leddevice) +SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/leddevice) + +#add libusb and pthreads (required for the Lighpack usb device) +find_package(libusb-1.0 REQUIRED) +find_package(Threads REQUIRED) + +include_directories( + ../../include/hidapi + ${LIBUSB_1_INCLUDE_DIRS}) # for Lightpack device + +# Group the headers that go through the MOC compiler +SET(Leddevice_QT_HEADERS + ${CURRENT_SOURCE_DIR}/LedDeviceAdalight.h +) + +SET(Leddevice_HEADERS + ${CURRENT_HEADER_DIR}/LedDevice.h + ${CURRENT_HEADER_DIR}/LedDeviceFactory.h + + ${CURRENT_SOURCE_DIR}/LedSpiDevice.h + ${CURRENT_SOURCE_DIR}/LedRs232Device.h + ${CURRENT_SOURCE_DIR}/LedDeviceTest.h + ${CURRENT_SOURCE_DIR}/LedDeviceSedu.h + ${CURRENT_SOURCE_DIR}/LedDeviceWs2801.h + ${CURRENT_SOURCE_DIR}/LedDeviceWs2811.h + ${CURRENT_SOURCE_DIR}/LedDeviceLpd6803.h + ${CURRENT_SOURCE_DIR}/LedDeviceLpd8806.h + ${CURRENT_SOURCE_DIR}/LedDeviceLightpack.h + ${CURRENT_SOURCE_DIR}/LedDevicePaintpack.h + ${CURRENT_SOURCE_DIR}/LedDeviceMultiLightpack.h +) + +SET(Leddevice_SOURCES + ${CURRENT_SOURCE_DIR}/LedDeviceFactory.cpp + + ${CURRENT_SOURCE_DIR}/LedSpiDevice.cpp + ${CURRENT_SOURCE_DIR}/LedRs232Device.cpp + ${CURRENT_SOURCE_DIR}/LedDeviceSedu.cpp + ${CURRENT_SOURCE_DIR}/LedDeviceTest.cpp + ${CURRENT_SOURCE_DIR}/LedDeviceWs2801.cpp + ${CURRENT_SOURCE_DIR}/LedDeviceWs2811.cpp + ${CURRENT_SOURCE_DIR}/LedDeviceLpd6803.cpp + ${CURRENT_SOURCE_DIR}/LedDeviceLpd8806.cpp + ${CURRENT_SOURCE_DIR}/LedDeviceAdalight.cpp + ${CURRENT_SOURCE_DIR}/LedDeviceLightpack.cpp + ${CURRENT_SOURCE_DIR}/LedDevicePaintpack.cpp + ${CURRENT_SOURCE_DIR}/LedDeviceMultiLightpack.cpp +) + +QT4_WRAP_CPP(Leddevice_HEADERS_MOC ${Leddevice_QT_HEADERS}) + +add_library(leddevice + ${Leddevice_HEADERS} + ${Leddevice_QT_HEADERS} + ${Leddevice_HEADERS_MOC} + ${Leddevice_SOURCES} +) + +target_link_libraries(leddevice + hyperion-utils + hidapi-libusb + serialport + ${LIBUSB_1_LIBRARIES} #apt-get install libusb-1.0-0-dev + ${CMAKE_THREAD_LIBS_INIT} + ${QT_LIBRARIES} +) diff --git a/libsrc/hyperion/device/LedDeviceAdalight.cpp b/libsrc/leddevice/LedDeviceAdalight.cpp similarity index 100% rename from libsrc/hyperion/device/LedDeviceAdalight.cpp rename to libsrc/leddevice/LedDeviceAdalight.cpp diff --git a/libsrc/hyperion/device/LedDeviceAdalight.h b/libsrc/leddevice/LedDeviceAdalight.h similarity index 100% rename from libsrc/hyperion/device/LedDeviceAdalight.h rename to libsrc/leddevice/LedDeviceAdalight.h diff --git a/libsrc/leddevice/LedDeviceFactory.cpp b/libsrc/leddevice/LedDeviceFactory.cpp new file mode 100644 index 00000000..e745d7e9 --- /dev/null +++ b/libsrc/leddevice/LedDeviceFactory.cpp @@ -0,0 +1,126 @@ + +// Leddevice includes +#include + +// Local Leddevice includes +#include "LedDeviceLpd6803.h" +#include "LedDeviceLpd8806.h" +#include "LedDeviceSedu.h" +#include "LedDeviceTest.h" +#include "LedDeviceWs2801.h" +#include "LedDeviceWs2811.h" +#include "LedDeviceAdalight.h" +#include "LedDevicePaintpack.h" +#include "LedDeviceLightpack.h" +#include "LedDeviceMultiLightpack.h" + +LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig) +{ + std::cout << "Device configuration: " << deviceConfig << std::endl; + + std::string type = deviceConfig.get("type", "UNSPECIFIED").asString(); + std::transform(type.begin(), type.end(), type.begin(), ::tolower); + + LedDevice* device = nullptr; + if (type == "ws2801" || type == "lightberry") + { + const std::string output = deviceConfig["output"].asString(); + const unsigned rate = deviceConfig["rate"].asInt(); + + LedDeviceWs2801* deviceWs2801 = new LedDeviceWs2801(output, rate); + deviceWs2801->open(); + + device = deviceWs2801; + } + else if (type == "ws2811") + { + const std::string output = deviceConfig["output"].asString(); + const std::string outputSpeed = deviceConfig["output"].asString(); + const std::string timingOption = deviceConfig["timingOption"].asString(); + + ws2811::SpeedMode speedMode = (outputSpeed == "high")? ws2811::highspeed : ws2811::lowspeed; + if (outputSpeed != "high" && outputSpeed != "low") + { + std::cerr << "Incorrect speed-mode selected for WS2811: " << outputSpeed << " != {'high', 'low'}" << std::endl; + } + + LedDeviceWs2811 * deviceWs2811 = new LedDeviceWs2811(output, ws2811::fromString(timingOption, ws2811::option_2855), speedMode); + deviceWs2811->open(); + + device = deviceWs2811; + } + 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; + } + 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; + } + else if (type == "adalight") + { + const std::string output = deviceConfig["output"].asString(); + const unsigned rate = deviceConfig["rate"].asInt(); + + LedDeviceAdalight* deviceAdalight = new LedDeviceAdalight(output, rate); + deviceAdalight->open(); + + device = deviceAdalight; + } + else if (type == "lightpack") + { + const std::string output = deviceConfig.get("output", "").asString(); + + LedDeviceLightpack* deviceLightpack = new LedDeviceLightpack(); + deviceLightpack->open(output); + + device = deviceLightpack; + } + else if (type == "paintpack") + { + LedDevicePaintpack * devicePainLightpack = new LedDevicePaintpack(); + devicePainLightpack->open(); + + device = devicePainLightpack; + } + else if (type == "multi-lightpack") + { + LedDeviceMultiLightpack* deviceLightpack = new LedDeviceMultiLightpack(); + deviceLightpack->open(); + + device = deviceLightpack; + } + else if (type == "test") + { + const std::string output = deviceConfig["output"].asString(); + device = new LedDeviceTest(output); + } + else + { + std::cout << "Unable to create device " << type << std::endl; + // Unknown / Unimplemented device + } + return device; +} diff --git a/libsrc/hyperion/device/LedDeviceLightpack-hidapi.cpp b/libsrc/leddevice/LedDeviceLightpack-hidapi.cpp similarity index 100% rename from libsrc/hyperion/device/LedDeviceLightpack-hidapi.cpp rename to libsrc/leddevice/LedDeviceLightpack-hidapi.cpp diff --git a/libsrc/hyperion/device/LedDeviceLightpack-hidapi.h b/libsrc/leddevice/LedDeviceLightpack-hidapi.h similarity index 100% rename from libsrc/hyperion/device/LedDeviceLightpack-hidapi.h rename to libsrc/leddevice/LedDeviceLightpack-hidapi.h diff --git a/libsrc/hyperion/device/LedDeviceLightpack.cpp b/libsrc/leddevice/LedDeviceLightpack.cpp similarity index 100% rename from libsrc/hyperion/device/LedDeviceLightpack.cpp rename to libsrc/leddevice/LedDeviceLightpack.cpp diff --git a/libsrc/hyperion/device/LedDeviceLightpack.h b/libsrc/leddevice/LedDeviceLightpack.h similarity index 98% rename from libsrc/hyperion/device/LedDeviceLightpack.h rename to libsrc/leddevice/LedDeviceLightpack.h index 6c4b2232..73b3dba5 100644 --- a/libsrc/hyperion/device/LedDeviceLightpack.h +++ b/libsrc/leddevice/LedDeviceLightpack.h @@ -9,7 +9,7 @@ #include // Hyperion includes -#include +#include /// /// LedDevice implementation for a lightpack device (http://code.google.com/p/light-pack/) diff --git a/libsrc/hyperion/device/LedDeviceLpd6803.cpp b/libsrc/leddevice/LedDeviceLpd6803.cpp similarity index 100% rename from libsrc/hyperion/device/LedDeviceLpd6803.cpp rename to libsrc/leddevice/LedDeviceLpd6803.cpp diff --git a/libsrc/hyperion/device/LedDeviceLpd6803.h b/libsrc/leddevice/LedDeviceLpd6803.h similarity index 100% rename from libsrc/hyperion/device/LedDeviceLpd6803.h rename to libsrc/leddevice/LedDeviceLpd6803.h diff --git a/libsrc/hyperion/device/LedDeviceLpd8806.cpp b/libsrc/leddevice/LedDeviceLpd8806.cpp similarity index 100% rename from libsrc/hyperion/device/LedDeviceLpd8806.cpp rename to libsrc/leddevice/LedDeviceLpd8806.cpp diff --git a/libsrc/hyperion/device/LedDeviceLpd8806.h b/libsrc/leddevice/LedDeviceLpd8806.h similarity index 100% rename from libsrc/hyperion/device/LedDeviceLpd8806.h rename to libsrc/leddevice/LedDeviceLpd8806.h diff --git a/libsrc/hyperion/device/LedDeviceMultiLightpack.cpp b/libsrc/leddevice/LedDeviceMultiLightpack.cpp similarity index 100% rename from libsrc/hyperion/device/LedDeviceMultiLightpack.cpp rename to libsrc/leddevice/LedDeviceMultiLightpack.cpp diff --git a/libsrc/hyperion/device/LedDeviceMultiLightpack.h b/libsrc/leddevice/LedDeviceMultiLightpack.h similarity index 97% rename from libsrc/hyperion/device/LedDeviceMultiLightpack.h rename to libsrc/leddevice/LedDeviceMultiLightpack.h index c7174ad3..65e0d1d6 100644 --- a/libsrc/hyperion/device/LedDeviceMultiLightpack.h +++ b/libsrc/leddevice/LedDeviceMultiLightpack.h @@ -10,7 +10,7 @@ #include // Hyperion includes -#include +#include #include "LedDeviceLightpack.h" /// diff --git a/libsrc/hyperion/device/LedDevicePaintpack.cpp b/libsrc/leddevice/LedDevicePaintpack.cpp similarity index 100% rename from libsrc/hyperion/device/LedDevicePaintpack.cpp rename to libsrc/leddevice/LedDevicePaintpack.cpp diff --git a/libsrc/hyperion/device/LedDevicePaintpack.h b/libsrc/leddevice/LedDevicePaintpack.h similarity index 96% rename from libsrc/hyperion/device/LedDevicePaintpack.h rename to libsrc/leddevice/LedDevicePaintpack.h index 8247bfb6..327dc123 100644 --- a/libsrc/hyperion/device/LedDevicePaintpack.h +++ b/libsrc/leddevice/LedDevicePaintpack.h @@ -7,7 +7,7 @@ #include // Hyperion includes -#include +#include /// /// LedDevice implementation for a paintpack device () diff --git a/libsrc/hyperion/device/LedDeviceSedu.cpp b/libsrc/leddevice/LedDeviceSedu.cpp similarity index 100% rename from libsrc/hyperion/device/LedDeviceSedu.cpp rename to libsrc/leddevice/LedDeviceSedu.cpp diff --git a/libsrc/hyperion/device/LedDeviceSedu.h b/libsrc/leddevice/LedDeviceSedu.h similarity index 100% rename from libsrc/hyperion/device/LedDeviceSedu.h rename to libsrc/leddevice/LedDeviceSedu.h diff --git a/libsrc/hyperion/device/LedDeviceTest.cpp b/libsrc/leddevice/LedDeviceTest.cpp similarity index 100% rename from libsrc/hyperion/device/LedDeviceTest.cpp rename to libsrc/leddevice/LedDeviceTest.cpp diff --git a/libsrc/hyperion/device/LedDeviceTest.h b/libsrc/leddevice/LedDeviceTest.h similarity index 93% rename from libsrc/hyperion/device/LedDeviceTest.h rename to libsrc/leddevice/LedDeviceTest.h index dbe84940..cc4a6f32 100644 --- a/libsrc/hyperion/device/LedDeviceTest.h +++ b/libsrc/leddevice/LedDeviceTest.h @@ -3,8 +3,8 @@ // STL includes0 #include -// Hyperion includes -#include +// Leddevice includes +#include /// /// Implementation of the LedDevice that write the led-colors to an diff --git a/libsrc/hyperion/device/LedDeviceWs2801.cpp b/libsrc/leddevice/LedDeviceWs2801.cpp similarity index 100% rename from libsrc/hyperion/device/LedDeviceWs2801.cpp rename to libsrc/leddevice/LedDeviceWs2801.cpp diff --git a/libsrc/hyperion/device/LedDeviceWs2801.h b/libsrc/leddevice/LedDeviceWs2801.h similarity index 100% rename from libsrc/hyperion/device/LedDeviceWs2801.h rename to libsrc/leddevice/LedDeviceWs2801.h diff --git a/libsrc/hyperion/device/LedDeviceWs2811.cpp b/libsrc/leddevice/LedDeviceWs2811.cpp similarity index 100% rename from libsrc/hyperion/device/LedDeviceWs2811.cpp rename to libsrc/leddevice/LedDeviceWs2811.cpp diff --git a/libsrc/hyperion/device/LedDeviceWs2811.h b/libsrc/leddevice/LedDeviceWs2811.h similarity index 100% rename from libsrc/hyperion/device/LedDeviceWs2811.h rename to libsrc/leddevice/LedDeviceWs2811.h diff --git a/libsrc/hyperion/device/LedRs232Device.cpp b/libsrc/leddevice/LedRs232Device.cpp similarity index 100% rename from libsrc/hyperion/device/LedRs232Device.cpp rename to libsrc/leddevice/LedRs232Device.cpp diff --git a/libsrc/hyperion/device/LedRs232Device.h b/libsrc/leddevice/LedRs232Device.h similarity index 95% rename from libsrc/hyperion/device/LedRs232Device.h rename to libsrc/leddevice/LedRs232Device.h index 5e3236f3..856a80fe 100644 --- a/libsrc/hyperion/device/LedRs232Device.h +++ b/libsrc/leddevice/LedRs232Device.h @@ -3,8 +3,8 @@ // Serial includes #include -// Hyperion includes -#include +// Leddevice includes +#include /// /// The LedRs232Device implements an abstract base-class for LedDevices using a RS232-device. diff --git a/libsrc/hyperion/device/LedSpiDevice.cpp b/libsrc/leddevice/LedSpiDevice.cpp similarity index 100% rename from libsrc/hyperion/device/LedSpiDevice.cpp rename to libsrc/leddevice/LedSpiDevice.cpp diff --git a/libsrc/hyperion/device/LedSpiDevice.h b/libsrc/leddevice/LedSpiDevice.h similarity index 98% rename from libsrc/hyperion/device/LedSpiDevice.h rename to libsrc/leddevice/LedSpiDevice.h index 4b47b7d8..299cf904 100644 --- a/libsrc/hyperion/device/LedSpiDevice.h +++ b/libsrc/leddevice/LedSpiDevice.h @@ -4,7 +4,7 @@ #include // Hyperion includes -#include +#include /// /// The LedSpiDevice implements an abstract base-class for LedDevices using the SPI-device. diff --git a/test/TestSpi.cpp b/test/TestSpi.cpp index dd139f80..1a3d5a92 100644 --- a/test/TestSpi.cpp +++ b/test/TestSpi.cpp @@ -10,7 +10,7 @@ // Local includes #include -#include "../libsrc/hyperion/device/LedDeviceWs2801.h" +#include "../libsrc/leddevice/LedDeviceWs2801.h" void setColor(char* colorStr) {