mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Moved all devices to separate library and added 'Factory' for device creation.
Former-commit-id: 26cab1b85b00406240689ad9c1018f0307028fe4
This commit is contained in:
parent
9bfaffe93b
commit
b63753f5dc
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
// Hyperion includes
|
// Hyperion includes
|
||||||
#include <hyperion/LedString.h>
|
#include <hyperion/LedString.h>
|
||||||
#include <hyperion/LedDevice.h>
|
|
||||||
#include <hyperion/PriorityMuxer.h>
|
#include <hyperion/PriorityMuxer.h>
|
||||||
|
|
||||||
// Effect engine includes
|
// Effect engine includes
|
||||||
#include <effectengine/EffectDefinition.h>
|
#include <effectengine/EffectDefinition.h>
|
||||||
|
|
||||||
// Forward class declaration
|
// Forward class declaration
|
||||||
|
class LedDevice;
|
||||||
class ColorTransform;
|
class ColorTransform;
|
||||||
class EffectEngine;
|
class EffectEngine;
|
||||||
class HsvTransform;
|
class HsvTransform;
|
||||||
@ -158,7 +158,6 @@ public slots:
|
|||||||
int setEffect(const std::string & effectName, const Json::Value & args, int priority, int timeout = -1);
|
int setEffect(const std::string & effectName, const Json::Value & args, int priority, int timeout = -1);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static LedDevice * createDevice(const Json::Value & deviceConfig);
|
|
||||||
static ColorOrder createColorOrder(const Json::Value & deviceConfig);
|
static ColorOrder createColorOrder(const Json::Value & deviceConfig);
|
||||||
static LedString createLedString(const Json::Value & ledsConfig);
|
static LedString createLedString(const Json::Value & ledsConfig);
|
||||||
|
|
||||||
|
@ -12,9 +12,6 @@
|
|||||||
// Utils includes
|
// Utils includes
|
||||||
#include <utils/ColorRgb.h>
|
#include <utils/ColorRgb.h>
|
||||||
|
|
||||||
// Hyperion includes
|
|
||||||
#include <hyperion/LedDevice.h>
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// The PriorityMuxer handles the priority channels. Led values input is written to the priority map
|
/// 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
|
/// and the muxer keeps track of all active priorities. The current priority can be queried and per
|
||||||
|
27
include/leddevice/LedDeviceFactory.h
Normal file
27
include/leddevice/LedDeviceFactory.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Json includes
|
||||||
|
#include <json/json.h>
|
||||||
|
|
||||||
|
// Leddevice includes
|
||||||
|
#include <leddevice/LedDevice.h>
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// 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);
|
||||||
|
};
|
@ -7,6 +7,7 @@ add_subdirectory(hyperion)
|
|||||||
add_subdirectory(jsonserver)
|
add_subdirectory(jsonserver)
|
||||||
add_subdirectory(protoserver)
|
add_subdirectory(protoserver)
|
||||||
add_subdirectory(boblightserver)
|
add_subdirectory(boblightserver)
|
||||||
|
add_subdirectory(leddevice)
|
||||||
add_subdirectory(utils)
|
add_subdirectory(utils)
|
||||||
add_subdirectory(xbmcvideochecker)
|
add_subdirectory(xbmcvideochecker)
|
||||||
add_subdirectory(effectengine)
|
add_subdirectory(effectengine)
|
||||||
|
@ -3,27 +3,17 @@
|
|||||||
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/hyperion)
|
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/hyperion)
|
||||||
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/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
|
# Group the headers that go through the MOC compiler
|
||||||
SET(Hyperion_QT_HEADERS
|
SET(Hyperion_QT_HEADERS
|
||||||
${CURRENT_HEADER_DIR}/Hyperion.h
|
${CURRENT_HEADER_DIR}/Hyperion.h
|
||||||
|
|
||||||
${CURRENT_SOURCE_DIR}/LinearColorSmoothing.h
|
${CURRENT_SOURCE_DIR}/LinearColorSmoothing.h
|
||||||
${CURRENT_SOURCE_DIR}/device/LedDeviceAdalight.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(Hyperion_HEADERS
|
SET(Hyperion_HEADERS
|
||||||
${CURRENT_HEADER_DIR}/ImageProcessor.h
|
${CURRENT_HEADER_DIR}/ImageProcessor.h
|
||||||
${CURRENT_HEADER_DIR}/ImageProcessorFactory.h
|
${CURRENT_HEADER_DIR}/ImageProcessorFactory.h
|
||||||
${CURRENT_HEADER_DIR}/ImageToLedsMap.h
|
${CURRENT_HEADER_DIR}/ImageToLedsMap.h
|
||||||
${CURRENT_HEADER_DIR}/LedDevice.h
|
|
||||||
${CURRENT_HEADER_DIR}/LedString.h
|
${CURRENT_HEADER_DIR}/LedString.h
|
||||||
${CURRENT_HEADER_DIR}/PriorityMuxer.h
|
${CURRENT_HEADER_DIR}/PriorityMuxer.h
|
||||||
|
|
||||||
@ -31,18 +21,6 @@ SET(Hyperion_HEADERS
|
|||||||
${CURRENT_HEADER_DIR}/BlackBorderProcessor.h
|
${CURRENT_HEADER_DIR}/BlackBorderProcessor.h
|
||||||
|
|
||||||
${CURRENT_SOURCE_DIR}/MultiColorTransform.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
|
SET(Hyperion_SOURCES
|
||||||
@ -57,19 +35,6 @@ SET(Hyperion_SOURCES
|
|||||||
${CURRENT_SOURCE_DIR}/ImageToLedsMap.cpp
|
${CURRENT_SOURCE_DIR}/ImageToLedsMap.cpp
|
||||||
${CURRENT_SOURCE_DIR}/MultiColorTransform.cpp
|
${CURRENT_SOURCE_DIR}/MultiColorTransform.cpp
|
||||||
${CURRENT_SOURCE_DIR}/LinearColorSmoothing.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
|
set(Hyperion_RESOURCES
|
||||||
@ -78,7 +43,7 @@ set(Hyperion_RESOURCES
|
|||||||
|
|
||||||
QT4_WRAP_CPP(Hyperion_HEADERS_MOC ${Hyperion_QT_HEADERS})
|
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
|
add_library(hyperion
|
||||||
${Hyperion_HEADERS}
|
${Hyperion_HEADERS}
|
||||||
@ -90,10 +55,9 @@ add_library(hyperion
|
|||||||
|
|
||||||
target_link_libraries(hyperion
|
target_link_libraries(hyperion
|
||||||
hyperion-utils
|
hyperion-utils
|
||||||
|
leddevice
|
||||||
effectengine
|
effectengine
|
||||||
hidapi-libusb
|
hidapi-libusb
|
||||||
serialport
|
serialport
|
||||||
${LIBUSB_1_LIBRARIES} #apt-get install libusb-1.0-0-dev
|
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
|
||||||
${QT_LIBRARIES}
|
${QT_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
@ -14,19 +14,11 @@
|
|||||||
|
|
||||||
// hyperion include
|
// hyperion include
|
||||||
#include <hyperion/Hyperion.h>
|
#include <hyperion/Hyperion.h>
|
||||||
#include <hyperion/LedDevice.h>
|
|
||||||
#include <hyperion/ImageProcessorFactory.h>
|
#include <hyperion/ImageProcessorFactory.h>
|
||||||
|
|
||||||
#include "device/LedDeviceLpd6803.h"
|
// Leddevice includes
|
||||||
#include "device/LedDeviceLpd8806.h"
|
#include <leddevice/LedDevice.h>
|
||||||
#include "device/LedDeviceSedu.h"
|
#include <leddevice/LedDeviceFactory.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"
|
|
||||||
|
|
||||||
#include "MultiColorTransform.h"
|
#include "MultiColorTransform.h"
|
||||||
#include "LinearColorSmoothing.h"
|
#include "LinearColorSmoothing.h"
|
||||||
@ -34,116 +26,6 @@
|
|||||||
// effect engine includes
|
// effect engine includes
|
||||||
#include <effectengine/EffectEngine.h>
|
#include <effectengine/EffectEngine.h>
|
||||||
|
|
||||||
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)
|
Hyperion::ColorOrder Hyperion::createColorOrder(const Json::Value &deviceConfig)
|
||||||
{
|
{
|
||||||
@ -379,7 +261,7 @@ Hyperion::Hyperion(const Json::Value &jsonConfig) :
|
|||||||
_muxer(_ledString.leds().size()),
|
_muxer(_ledString.leds().size()),
|
||||||
_raw2ledTransform(createLedColorsTransform(_ledString.leds().size(), jsonConfig["color"])),
|
_raw2ledTransform(createLedColorsTransform(_ledString.leds().size(), jsonConfig["color"])),
|
||||||
_colorOrder(createColorOrder(jsonConfig["device"])),
|
_colorOrder(createColorOrder(jsonConfig["device"])),
|
||||||
_device(createDevice(jsonConfig["device"])),
|
_device(LedDeviceFactory::construct(jsonConfig["device"])),
|
||||||
_effectEngine(nullptr),
|
_effectEngine(nullptr),
|
||||||
_timer()
|
_timer()
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <linux/spi/spidev.h>
|
#include <linux/spi/spidev.h>
|
||||||
|
|
||||||
// hyperion incluse
|
// hyperion incluse
|
||||||
#include <hyperion/LedDevice.h>
|
#include <leddevice/LedDevice.h>
|
||||||
|
|
||||||
/// Linear Smooting class
|
/// Linear Smooting class
|
||||||
///
|
///
|
||||||
|
69
libsrc/leddevice/CMakeLists.txt
Normal file
69
libsrc/leddevice/CMakeLists.txt
Normal file
@ -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}
|
||||||
|
)
|
126
libsrc/leddevice/LedDeviceFactory.cpp
Normal file
126
libsrc/leddevice/LedDeviceFactory.cpp
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
|
||||||
|
// Leddevice includes
|
||||||
|
#include <leddevice/LedDeviceFactory.h>
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
@ -9,7 +9,7 @@
|
|||||||
#include <libusb.h>
|
#include <libusb.h>
|
||||||
|
|
||||||
// Hyperion includes
|
// Hyperion includes
|
||||||
#include <hyperion/LedDevice.h>
|
#include <leddevice/LedDevice.h>
|
||||||
|
|
||||||
///
|
///
|
||||||
/// LedDevice implementation for a lightpack device (http://code.google.com/p/light-pack/)
|
/// LedDevice implementation for a lightpack device (http://code.google.com/p/light-pack/)
|
@ -10,7 +10,7 @@
|
|||||||
#include <libusb.h>
|
#include <libusb.h>
|
||||||
|
|
||||||
// Hyperion includes
|
// Hyperion includes
|
||||||
#include <hyperion/LedDevice.h>
|
#include <leddevice/LedDevice.h>
|
||||||
#include "LedDeviceLightpack.h"
|
#include "LedDeviceLightpack.h"
|
||||||
|
|
||||||
///
|
///
|
@ -7,7 +7,7 @@
|
|||||||
#include <hidapi/hidapi.h>
|
#include <hidapi/hidapi.h>
|
||||||
|
|
||||||
// Hyperion includes
|
// Hyperion includes
|
||||||
#include <hyperion/LedDevice.h>
|
#include <leddevice/LedDevice.h>
|
||||||
|
|
||||||
///
|
///
|
||||||
/// LedDevice implementation for a paintpack device ()
|
/// LedDevice implementation for a paintpack device ()
|
@ -3,8 +3,8 @@
|
|||||||
// STL includes0
|
// STL includes0
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
// Hyperion includes
|
// Leddevice includes
|
||||||
#include <hyperion/LedDevice.h>
|
#include <leddevice/LedDevice.h>
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Implementation of the LedDevice that write the led-colors to an
|
/// Implementation of the LedDevice that write the led-colors to an
|
@ -3,8 +3,8 @@
|
|||||||
// Serial includes
|
// Serial includes
|
||||||
#include <serial/serial.h>
|
#include <serial/serial.h>
|
||||||
|
|
||||||
// Hyperion includes
|
// Leddevice includes
|
||||||
#include <hyperion/LedDevice.h>
|
#include <leddevice/LedDevice.h>
|
||||||
|
|
||||||
///
|
///
|
||||||
/// The LedRs232Device implements an abstract base-class for LedDevices using a RS232-device.
|
/// The LedRs232Device implements an abstract base-class for LedDevices using a RS232-device.
|
@ -4,7 +4,7 @@
|
|||||||
#include <linux/spi/spidev.h>
|
#include <linux/spi/spidev.h>
|
||||||
|
|
||||||
// Hyperion includes
|
// Hyperion includes
|
||||||
#include <hyperion/LedDevice.h>
|
#include <leddevice/LedDevice.h>
|
||||||
|
|
||||||
///
|
///
|
||||||
/// The LedSpiDevice implements an abstract base-class for LedDevices using the SPI-device.
|
/// The LedSpiDevice implements an abstract base-class for LedDevices using the SPI-device.
|
@ -10,7 +10,7 @@
|
|||||||
// Local includes
|
// Local includes
|
||||||
#include <utils/ColorRgb.h>
|
#include <utils/ColorRgb.h>
|
||||||
|
|
||||||
#include "../libsrc/hyperion/device/LedDeviceWs2801.h"
|
#include "../libsrc/leddevice/LedDeviceWs2801.h"
|
||||||
|
|
||||||
void setColor(char* colorStr)
|
void setColor(char* colorStr)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user