Skip to content

Commit

Permalink
Support Skydimo devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Lord-Grey committed Jul 13, 2024
1 parent 01608f2 commit c31fd6e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Support for ftdi chip based LED-devices with ws2812, sk6812 apa102 LED types (Many thanks to @nurikk) (#1746)
- Support for Skydimo devices (being an Adalight variant)
- Support gaps on Matrix Layout (#1696)
- Windows: Added a new grabber that uses the DXGI DDA (Desktop Duplication API). This has much better performance than the DX grabber as it does more of its work on the GPU.

Expand Down
1 change: 1 addition & 0 deletions assets/webconfig/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@
"edt_dev_spec_port_expl": "Service Port [1-65535]",
"edt_dev_spec_port_title": "Port",
"edt_dev_spec_printTimeStamp_title": "Add timestamp",
"edt_dev_spec_skydimo_mode_title": "Skydimo Mode",
"edt_dev_spec_stream_protocol_title": "Streaming protocol",
"edt_dev_spec_pwmChannel_title": "PWM channel",
"edt_dev_spec_razer_device_title": "Razer Chroma Device",
Expand Down
56 changes: 32 additions & 24 deletions libsrc/leddevice/dev_serial/LedDeviceAdalight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ bool LedDeviceAdalight::init(const QJsonObject &deviceConfig)
case Adalight::ADA:
Debug( _log, "Adalight driver uses standard Adalight protocol");
break;

case Adalight::SKYDIMO:
Debug( _log, "Adalight driver uses Skydimo protocol");
break;

default:
Error( _log, "Adalight driver - unsupported protocol");
return false;
Expand All @@ -71,18 +76,13 @@ bool LedDeviceAdalight::init(const QJsonObject &deviceConfig)

void LedDeviceAdalight::prepareHeader()
{
// create ledBuffer
uint totalLedCount = _ledCount;
_bufferLength = static_cast<qint64>(HEADER_SIZE + _ledRGBCount);

switch (_streamProtocol) {
case Adalight::LBAPA:
{
const unsigned int startFrameSize = 4;
const unsigned int bytesPerRGBLed = 4;
const unsigned int endFrameSize = qMax<unsigned int>(((_ledCount + 15) / 16), bytesPerRGBLed);
_bufferLength = HEADER_SIZE + (_ledCount * bytesPerRGBLed) + startFrameSize + endFrameSize;

_ledBuffer.resize(static_cast<size_t>(_bufferLength), 0x00);

// init constant data values
Expand All @@ -91,39 +91,47 @@ void LedDeviceAdalight::prepareHeader()
_ledBuffer[iLed*4+HEADER_SIZE] = 0xFF;
}
}
break;

case Adalight::AWA:
_bufferLength += 8;
[[fallthrough]];
case Adalight::ADA:
[[fallthrough]];
default:
totalLedCount -= 1;
break;
case Adalight::SKYDIMO:
{
_bufferLength = static_cast<qint64>(HEADER_SIZE + _ledRGBCount);
_ledBuffer.resize(static_cast<size_t>(_bufferLength), 0x00);
break;
_ledBuffer[0] = 'A';
_ledBuffer[1] = 'd';
_ledBuffer[2] = 'a';
_ledBuffer[3] = 0;
_ledBuffer[4] = 0;
_ledBuffer[5] = static_cast<quint8>(_ledCount);
}

_ledBuffer[0] = 'A';
if (_streamProtocol == Adalight::AWA )
break;
case Adalight::AWA:
{
_bufferLength = static_cast<qint64>(HEADER_SIZE + _ledRGBCount + 8);
_ledBuffer.resize(static_cast<size_t>(_bufferLength), 0x00);
_ledBuffer[0] = 'A';
_ledBuffer[1] = 'w';
_ledBuffer[2] = _white_channel_calibration ? 'A' : 'a';
qToBigEndian<quint16>(static_cast<quint16>(_ledCount-1), &_ledBuffer[3]);
_ledBuffer[5] = _ledBuffer[3] ^ _ledBuffer[4] ^ 0x55; // Checksum
}
else
{
break;
case Adalight::ADA:
[[fallthrough]];
default:
_bufferLength = static_cast<qint64>(HEADER_SIZE + _ledRGBCount);
_ledBuffer.resize(static_cast<size_t>(_bufferLength), 0x00);
_ledBuffer[0] = 'A';
_ledBuffer[1] = 'd';
_ledBuffer[2] = 'a';
qToBigEndian<quint16>(static_cast<quint16>(_ledCount-1), &_ledBuffer[3]);
_ledBuffer[5] = _ledBuffer[3] ^ _ledBuffer[4] ^ 0x55; // Checksum
break;
}

qToBigEndian<quint16>(static_cast<quint16>(totalLedCount), &_ledBuffer[3]);
_ledBuffer[5] = _ledBuffer[3] ^ _ledBuffer[4] ^ 0x55; // Checksum

Debug( _log, "Adalight header for %d leds (size: %d): %c%c%c 0x%02x 0x%02x 0x%02x", _ledCount, _ledBuffer.size(),
_ledBuffer[0], _ledBuffer[1], _ledBuffer[2], _ledBuffer[3], _ledBuffer[4], _ledBuffer[5] );
}


int LedDeviceAdalight::write(const std::vector<ColorRgb> & ledValues)
{
if (_ledCount != ledValues.size())
Expand Down
3 changes: 2 additions & 1 deletion libsrc/leddevice/dev_serial/LedDeviceAdalight.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ typedef enum ProtocolType
{
ADA = 0,
LBAPA,
AWA
AWA,
SKYDIMO
} PROTOCOLTYPE;
}

Expand Down
4 changes: 2 additions & 2 deletions libsrc/leddevice/schemas/schema-adalight.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"streamProtocol": {
"type": "string",
"title": "edt_dev_spec_stream_protocol_title",
"enum": [ "0", "1", "2" ],
"enum": [ "0", "1", "2", "3" ],
"default": "0",
"options": {
"enum_titles": [ "edt_dev_spec_ada_mode_title", "edt_dev_spec_LBap102Mode_title","edt_dev_spec_awa_mode_title" ]
"enum_titles": [ "edt_dev_spec_ada_mode_title", "edt_dev_spec_LBap102Mode_title","edt_dev_spec_awa_mode_title", "edt_dev_spec_skydimo_mode_title" ]
},
"propertyOrder": 2
},
Expand Down

0 comments on commit c31fd6e

Please sign in to comment.