mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Merge branch 'h801' of https://github.com/WoLpH/hyperion.ng into WoLpH-h801
Conflicts: libsrc/leddevice/LedDeviceTpm2net.cpp libsrc/leddevice/LedDeviceUdpRaw.cpp libsrc/leddevice/ProviderUdp.cpp libsrc/leddevice/ProviderUdp.h
This commit is contained in:
commit
4c78302473
@ -35,6 +35,7 @@ SET(Leddevice_HEADERS
|
|||||||
${CURRENT_SOURCE_DIR}/LedDeviceSedu.h
|
${CURRENT_SOURCE_DIR}/LedDeviceSedu.h
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceFile.h
|
${CURRENT_SOURCE_DIR}/LedDeviceFile.h
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceUdpRaw.h
|
${CURRENT_SOURCE_DIR}/LedDeviceUdpRaw.h
|
||||||
|
${CURRENT_SOURCE_DIR}/LedDeviceUdpH801.h
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceUdpE131.h
|
${CURRENT_SOURCE_DIR}/LedDeviceUdpE131.h
|
||||||
${CURRENT_SOURCE_DIR}/ProviderUdp.h
|
${CURRENT_SOURCE_DIR}/ProviderUdp.h
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.h
|
${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.h
|
||||||
@ -62,6 +63,7 @@ SET(Leddevice_SOURCES
|
|||||||
${CURRENT_SOURCE_DIR}/LedDeviceFile.cpp
|
${CURRENT_SOURCE_DIR}/LedDeviceFile.cpp
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.cpp
|
${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.cpp
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceUdpRaw.cpp
|
${CURRENT_SOURCE_DIR}/LedDeviceUdpRaw.cpp
|
||||||
|
${CURRENT_SOURCE_DIR}/LedDeviceUdpH801.cpp
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceUdpE131.cpp
|
${CURRENT_SOURCE_DIR}/LedDeviceUdpE131.cpp
|
||||||
${CURRENT_SOURCE_DIR}/ProviderUdp.cpp
|
${CURRENT_SOURCE_DIR}/ProviderUdp.cpp
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.cpp
|
${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.cpp
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "LedDeviceAtmo.h"
|
#include "LedDeviceAtmo.h"
|
||||||
#include "LedDeviceAdalightApa102.h"
|
#include "LedDeviceAdalightApa102.h"
|
||||||
#include "LedDeviceAtmoOrb.h"
|
#include "LedDeviceAtmoOrb.h"
|
||||||
|
#include "LedDeviceUdpH801.h"
|
||||||
|
|
||||||
#ifdef ENABLE_WS2812BPWM
|
#ifdef ENABLE_WS2812BPWM
|
||||||
#include "LedDeviceWS2812b.h"
|
#include "LedDeviceWS2812b.h"
|
||||||
@ -101,6 +102,7 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig)
|
|||||||
#endif
|
#endif
|
||||||
LedDevice::addToDeviceMap("philipshue", LedDevicePhilipsHue::construct);
|
LedDevice::addToDeviceMap("philipshue", LedDevicePhilipsHue::construct);
|
||||||
LedDevice::addToDeviceMap("atmoorb", LedDeviceAtmoOrb::construct);
|
LedDevice::addToDeviceMap("atmoorb", LedDeviceAtmoOrb::construct);
|
||||||
|
LedDevice::addToDeviceMap("h801", LedDeviceUdpH801::construct);
|
||||||
|
|
||||||
// direct usb
|
// direct usb
|
||||||
LedDevice::addToDeviceMap("hyperion-usbasp", LedDeviceHyperionUsbasp::construct);
|
LedDevice::addToDeviceMap("hyperion-usbasp", LedDeviceHyperionUsbasp::construct);
|
||||||
|
@ -27,5 +27,6 @@
|
|||||||
<file alias="schema-ws2801">schemas/schema-ws2801.json</file>
|
<file alias="schema-ws2801">schemas/schema-ws2801.json</file>
|
||||||
<file alias="schema-ws2812spi">schemas/schema-ws2812spi.json</file>
|
<file alias="schema-ws2812spi">schemas/schema-ws2812spi.json</file>
|
||||||
<file alias="schema-ws281x">schemas/schema-ws281x.json</file>
|
<file alias="schema-ws281x">schemas/schema-ws281x.json</file>
|
||||||
|
<file alias="schema-h801">schemas/schema-h801.json</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -25,6 +25,7 @@ bool LedDeviceTpm2net::setConfig(const Json::Value &deviceConfig)
|
|||||||
{
|
{
|
||||||
ProviderUdp::setConfig(deviceConfig,50200,104000);
|
ProviderUdp::setConfig(deviceConfig,50200,104000);
|
||||||
_tpm2_max = deviceConfig.get("max-packet",170).asInt();
|
_tpm2_max = deviceConfig.get("max-packet",170).asInt();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
65
libsrc/leddevice/LedDeviceUdpH801.cpp
Normal file
65
libsrc/leddevice/LedDeviceUdpH801.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
// STL includes
|
||||||
|
#include <cstring>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <QHostInfo>
|
||||||
|
|
||||||
|
// hyperion local includes
|
||||||
|
#include "LedDeviceUdpH801.h"
|
||||||
|
|
||||||
|
LedDeviceUdpH801::LedDeviceUdpH801(const Json::Value &deviceConfig)
|
||||||
|
: ProviderUdp()
|
||||||
|
{
|
||||||
|
setConfig(deviceConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LedDeviceUdpH801::setConfig(const Json::Value &deviceConfig)
|
||||||
|
{
|
||||||
|
/* The H801 port is fixed */
|
||||||
|
ProviderUdp::setConfig(deviceConfig, 30977, "255.255.255.255");
|
||||||
|
|
||||||
|
/* 10ms seems to be a safe default for the wait time */
|
||||||
|
_LatchTime_ns = deviceConfig.get("latchtime", 10000000).asInt();
|
||||||
|
|
||||||
|
_ids.clear();
|
||||||
|
for (Json::Value::ArrayIndex i = 0; i < deviceConfig["lightIds"].size(); i++) {
|
||||||
|
QString id(deviceConfig["lightIds"][i].asCString());
|
||||||
|
_ids.push_back(id.toInt(nullptr, 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
_message = QByteArray(_prefix_size + _colors + _id_size * _ids.size() + _suffix_size, 0x00);
|
||||||
|
_message[0] = 0xFB;
|
||||||
|
_message[1] = 0xEB;
|
||||||
|
|
||||||
|
for (int i = 0; i < _ids.length(); i++) {
|
||||||
|
_message[_prefix_size + _colors + i * _id_size + 0] = (_ids[i] >> 0x00) & 0xFF;
|
||||||
|
_message[_prefix_size + _colors + i * _id_size + 1] = (_ids[i] >> 0x08) & 0xFF;
|
||||||
|
_message[_prefix_size + _colors + i * _id_size + 2] = (_ids[i] >> 0x10) & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug(_log, "H801 using %s:%d", _address.toString().toStdString().c_str(), _port);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
LedDevice* LedDeviceUdpH801::construct(const Json::Value &deviceConfig)
|
||||||
|
{
|
||||||
|
return new LedDeviceUdpH801(deviceConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
int LedDeviceUdpH801::write(const std::vector<ColorRgb> &ledValues)
|
||||||
|
{
|
||||||
|
ColorRgb color = ledValues[0];
|
||||||
|
_message[_prefix_size + 0] = color.red;
|
||||||
|
_message[_prefix_size + 1] = color.green;
|
||||||
|
_message[_prefix_size + 2] = color.blue;
|
||||||
|
|
||||||
|
return writeBytes(_message.size(), reinterpret_cast<const uint8_t*>(_message.data()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int LedDeviceUdpH801::switchOff()
|
||||||
|
{
|
||||||
|
return write(std::vector<ColorRgb>(_ledCount, ColorRgb{0, 0, 0}));
|
||||||
|
}
|
||||||
|
|
54
libsrc/leddevice/LedDeviceUdpH801.h
Normal file
54
libsrc/leddevice/LedDeviceUdpH801.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QtCore>
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QUdpSocket>
|
||||||
|
|
||||||
|
// STL includes
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
// hyperion includes
|
||||||
|
#include "ProviderUdp.h"
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Implementation of the LedDevice interface for sending led colors via udp.
|
||||||
|
///
|
||||||
|
class LedDeviceUdpH801: public ProviderUdp
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
QList<int> _ids;
|
||||||
|
QByteArray _message;
|
||||||
|
const int _prefix_size = 2;
|
||||||
|
const int _colors = 5;
|
||||||
|
const int _id_size = 3;
|
||||||
|
const int _suffix_size = 1;
|
||||||
|
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Constructs specific LedDevice
|
||||||
|
///
|
||||||
|
/// @param deviceConfig json device config
|
||||||
|
///
|
||||||
|
LedDeviceUdpH801(const Json::Value &deviceConfig);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Sets configuration
|
||||||
|
///
|
||||||
|
/// @param deviceConfig the json device config
|
||||||
|
/// @return true if success
|
||||||
|
bool setConfig(const Json::Value &deviceConfig);
|
||||||
|
|
||||||
|
/// constructs leddevice
|
||||||
|
static LedDevice* construct(const Json::Value &deviceConfig);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Writes the led color values to the led-device
|
||||||
|
///
|
||||||
|
/// @param ledValues The color-value per led
|
||||||
|
/// @return Zero on succes else negative
|
||||||
|
///
|
||||||
|
virtual int write(const std::vector<ColorRgb> &ledValues);
|
||||||
|
|
||||||
|
/// Switch the leds off
|
||||||
|
virtual int switchOff();
|
||||||
|
};
|
@ -28,7 +28,11 @@ ProviderUdp::~ProviderUdp()
|
|||||||
_udpSocket->close();
|
_udpSocket->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
bool ProviderUdp::setConfig(const Json::Value &deviceConfig, int defaultLatchTime, int defaultPort, std::string defaultHost)
|
bool ProviderUdp::setConfig(const Json::Value &deviceConfig, int defaultLatchTime, int defaultPort, std::string defaultHost)
|
||||||
|
=======
|
||||||
|
bool ProviderUdp::setConfig(const Json::Value &deviceConfig, int defaultPort, std::string defaultHost)
|
||||||
|
>>>>>>> ad785b9eba371bca0829b8dc7df80c30afdc052a
|
||||||
{
|
{
|
||||||
QString host = QString::fromStdString(deviceConfig.get("host",defaultHost).asString());
|
QString host = QString::fromStdString(deviceConfig.get("host",defaultHost).asString());
|
||||||
|
|
||||||
@ -48,7 +52,11 @@ bool ProviderUdp::setConfig(const Json::Value &deviceConfig, int defaultLatchTim
|
|||||||
Debug( _log, "Successfully parsed %s as a hostname.", deviceConfig["host"].asString().c_str());
|
Debug( _log, "Successfully parsed %s as a hostname.", deviceConfig["host"].asString().c_str());
|
||||||
_address = info.addresses().first();
|
_address = info.addresses().first();
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
|
=======
|
||||||
|
|
||||||
|
>>>>>>> ad785b9eba371bca0829b8dc7df80c30afdc052a
|
||||||
_port = deviceConfig.get("port", defaultPort).asUInt();
|
_port = deviceConfig.get("port", defaultPort).asUInt();
|
||||||
if ( _port<=0 || _port > 65535)
|
if ( _port<=0 || _port > 65535)
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,11 @@ public:
|
|||||||
///
|
///
|
||||||
ProviderUdp();
|
ProviderUdp();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructs specific LedDevice
|
||||||
|
///
|
||||||
|
ProviderUdp();
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor of the LedDevice; closes the output device if it is open
|
/// Destructor of the LedDevice; closes the output device if it is open
|
||||||
///
|
///
|
||||||
|
27
libsrc/leddevice/schemas/schema-h801.json
Normal file
27
libsrc/leddevice/schemas/schema-h801.json
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"type":"object",
|
||||||
|
"required":true,
|
||||||
|
"properties":{
|
||||||
|
"host" : {
|
||||||
|
"type": "string",
|
||||||
|
"title":"Target IP",
|
||||||
|
"default": "255.255.255.255",
|
||||||
|
"propertyOrder" : 1
|
||||||
|
},
|
||||||
|
"port" : {
|
||||||
|
"type": "integer",
|
||||||
|
"title":"Port",
|
||||||
|
"default": 30977,
|
||||||
|
"propertyOrder" : 2
|
||||||
|
},
|
||||||
|
"lightIds": {
|
||||||
|
"type": "array",
|
||||||
|
"title":"Light ids",
|
||||||
|
"items" : {
|
||||||
|
"type" : "string"
|
||||||
|
},
|
||||||
|
"propertyOrder" : 3
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": true
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user