mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Add Karatelight support (#487)
* Add Karatelight support * Add Karatelight Schema * Actually use the new schema file * Put karate device to USB group in webinterface
This commit is contained in:
parent
fa75143dbf
commit
bc4007ac67
@ -474,7 +474,7 @@ $(document).ready(function() {
|
|||||||
devRPiPWM = ['ws281x'];
|
devRPiPWM = ['ws281x'];
|
||||||
devRPiGPIO = ['piblaster'];
|
devRPiGPIO = ['piblaster'];
|
||||||
devNET = ['atmoorb', 'fadecandy', 'philipshue', 'tinkerforge', 'tpm2net', 'udpe131', 'udpartnet', 'udph801', 'udpraw'];
|
devNET = ['atmoorb', 'fadecandy', 'philipshue', 'tinkerforge', 'tpm2net', 'udpe131', 'udpartnet', 'udph801', 'udpraw'];
|
||||||
devUSB = ['adalight', 'dmx', 'atmo', 'hyperionusbasp', 'lightpack', 'multilightpack', 'paintpack', 'rawhid', 'sedu', 'tpm2'];
|
devUSB = ['adalight', 'dmx', 'atmo', 'hyperionusbasp', 'lightpack', 'multilightpack', 'paintpack', 'rawhid', 'sedu', 'tpm2', 'karate'];
|
||||||
|
|
||||||
var optArr = [[]];
|
var optArr = [[]];
|
||||||
optArr[1]=[];
|
optArr[1]=[];
|
||||||
|
@ -30,5 +30,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-karate">schemas/schema-karate.json</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
59
libsrc/leddevice/dev_serial/LedDeviceKarate.cpp
Normal file
59
libsrc/leddevice/dev_serial/LedDeviceKarate.cpp
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
// hyperion local includes
|
||||||
|
#include "LedDeviceKarate.h"
|
||||||
|
|
||||||
|
LedDeviceKarate::LedDeviceKarate(const QJsonObject &deviceConfig)
|
||||||
|
: ProviderRs232()
|
||||||
|
{
|
||||||
|
_deviceReady = init(deviceConfig);
|
||||||
|
connect(this,SIGNAL(receivedData(QByteArray)),this,SLOT(receivedData(QByteArray)));
|
||||||
|
}
|
||||||
|
|
||||||
|
LedDevice* LedDeviceKarate::construct(const QJsonObject &deviceConfig)
|
||||||
|
{
|
||||||
|
return new LedDeviceKarate(deviceConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LedDeviceKarate::init(const QJsonObject &deviceConfig)
|
||||||
|
{
|
||||||
|
ProviderRs232::init(deviceConfig);
|
||||||
|
|
||||||
|
if (_ledCount != 16)
|
||||||
|
{
|
||||||
|
Error( _log, "%d channels configured. This should always be 16!", _ledCount);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ledBuffer.resize(4 + _ledCount * 3); // 4-byte header, 3 RGB values
|
||||||
|
_ledBuffer[0] = 0xAA; // Startbyte
|
||||||
|
_ledBuffer[1] = 0x12; // Send all Channels in Batch
|
||||||
|
_ledBuffer[2] = 0x00; // Checksum
|
||||||
|
_ledBuffer[3] = _ledCount * 3; // Number of Databytes send
|
||||||
|
|
||||||
|
Debug( _log, "Karatelight header for %d leds: 0x%02x 0x%02x 0x%02x 0x%02x", _ledCount,
|
||||||
|
_ledBuffer[0], _ledBuffer[1], _ledBuffer[2], _ledBuffer[3] );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LedDeviceKarate::write(const std::vector<ColorRgb> &ledValues)
|
||||||
|
{
|
||||||
|
for (signed iLed=0; iLed<_ledCount; iLed++)
|
||||||
|
{
|
||||||
|
|
||||||
|
const ColorRgb& rgb = ledValues[iLed];
|
||||||
|
_ledBuffer[iLed*3+4] = rgb.green;
|
||||||
|
_ledBuffer[iLed*3+5] = rgb.blue;
|
||||||
|
_ledBuffer[iLed*3+6] = rgb.red;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calc Checksum
|
||||||
|
_ledBuffer[2] = _ledBuffer[0] ^ _ledBuffer[1];
|
||||||
|
for (unsigned int i = 3; i < _ledBuffer.size(); i++)
|
||||||
|
_ledBuffer[2] ^= _ledBuffer[i];
|
||||||
|
|
||||||
|
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
void LedDeviceKarate::receivedData(QByteArray data)
|
||||||
|
{
|
||||||
|
Debug(_log, ">>received %d bytes data %s", data.size(),data.data());
|
||||||
|
}
|
36
libsrc/leddevice/dev_serial/LedDeviceKarate.h
Normal file
36
libsrc/leddevice/dev_serial/LedDeviceKarate.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// hyperion incluse
|
||||||
|
#include "ProviderRs232.h"
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Implementation of the LedDevice interface for writing to serial device using tpm2 protocol.
|
||||||
|
///
|
||||||
|
class LedDeviceKarate : public ProviderRs232
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Constructs specific LedDevice
|
||||||
|
///
|
||||||
|
/// @param deviceConfig json device config
|
||||||
|
///
|
||||||
|
LedDeviceKarate(const QJsonObject &deviceConfig);
|
||||||
|
|
||||||
|
/// constructs leddevice
|
||||||
|
static LedDevice* construct(const QJsonObject &deviceConfig);
|
||||||
|
|
||||||
|
virtual bool init(const QJsonObject &deviceConfig);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void receivedData(QByteArray data);
|
||||||
|
|
||||||
|
private:
|
||||||
|
///
|
||||||
|
/// 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);
|
||||||
|
};
|
36
libsrc/leddevice/schemas/schema-karate.json
Normal file
36
libsrc/leddevice/schemas/schema-karate.json
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"type":"object",
|
||||||
|
"required":true,
|
||||||
|
"properties":{
|
||||||
|
"output": {
|
||||||
|
"type": "string",
|
||||||
|
"title":"edt_dev_spec_outputPath_title",
|
||||||
|
"default":"/dev/ttyACM0",
|
||||||
|
"propertyOrder" : 1
|
||||||
|
},
|
||||||
|
"rate": {
|
||||||
|
"type": "integer",
|
||||||
|
"title":"edt_dev_spec_baudrate_title",
|
||||||
|
"default": 1000000,
|
||||||
|
"propertyOrder" : 2
|
||||||
|
},
|
||||||
|
"delayAfterConnect": {
|
||||||
|
"type": "integer",
|
||||||
|
"title":"edt_dev_spec_delayAfterConnect_title",
|
||||||
|
"default": 1500,
|
||||||
|
"append" : "ms",
|
||||||
|
"propertyOrder" : 3
|
||||||
|
},
|
||||||
|
"latchTime": {
|
||||||
|
"type": "integer",
|
||||||
|
"title":"edt_dev_spec_latchtime_title",
|
||||||
|
"default": 15,
|
||||||
|
"append" : "edt_append_ms",
|
||||||
|
"minimum": 1,
|
||||||
|
"maximum": 1000,
|
||||||
|
"access" : "expert",
|
||||||
|
"propertyOrder" : 4
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": true
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user