Skip to content

Commit b7334ad

Browse files
committed
1. Reworked the generated code. Optimized it here and there. Reused
ledRGB(W)Count variable from LedDevice instead of creating a new locally 2. Fixed the problem where DMX Max channel count was hardcoded to 512. WLED e.g. in MultiRGB mode relies on 510 (3*170) channels. On other hand for MultiRGBW it expect 512 (4*128) channels. So obviously it has to be a parameter. 3. Updated corresponding configuration for WebUI
1 parent 20ad969 commit b7334ad

File tree

4 files changed

+44
-35
lines changed

4 files changed

+44
-35
lines changed

assets/webconfig/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@
688688
"edt_dev_spec_devices_discovery_inprogress": "Discovery in progress",
689689
"edt_dev_spec_dithering_title": "Dithering",
690690
"edt_dev_spec_dmaNumber_title": "DMA channel",
691+
"edt_dev_spec_dmx_max_title": "DMX maximal number of channels",
691692
"edt_dev_spec_fullBrightnessAtStart_title": "Full brightness at start",
692693
"edt_dev_spec_gamma_title": "Gamma",
693694
"edt_dev_spec_globalBrightnessControlMaxLevel_title": "Max Current Level",

libsrc/leddevice/dev_net/LedDeviceUdpE131.cpp

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ const int DMX_MAX = 512; // 512 usable slots
4040
LedDeviceUdpE131::LedDeviceUdpE131(const QJsonObject &deviceConfig)
4141
: ProviderUdp(deviceConfig)
4242
, _whiteAlgorithm(RGBW::WhiteAlgorithm::INVALID)
43-
, _ledRGBWCount(0)
4443
{
4544
}
4645

@@ -60,6 +59,7 @@ bool LedDeviceUdpE131::init(const QJsonObject &deviceConfig)
6059
_port = deviceConfig[CONFIG_PORT].toInt(E131_DEFAULT_PORT);
6160

6261
_e131_universe = deviceConfig["universe"].toInt(1);
62+
_e131_dmx_max = deviceConfig["dmx-max"].toInt(DMX_MAX);
6363
_e131_source_name = deviceConfig["source-name"].toString("hyperion on "+QHostInfo::localHostName());
6464
QString _json_cid = deviceConfig["cid"].toString("");
6565

@@ -74,17 +74,6 @@ bool LedDeviceUdpE131::init(const QJsonObject &deviceConfig)
7474
}
7575
Debug(_log, "whiteAlgorithm : %s", QSTRING_CSTR(whiteAlgorithmStr));
7676

77-
// Calculate RGBW count
78-
if (_whiteAlgorithm == RGBW::WhiteAlgorithm::WHITE_OFF)
79-
{
80-
_ledRGBWCount = _ledCount * 3;
81-
}
82-
else
83-
{
84-
_ledRGBWCount = _ledCount * 4;
85-
}
86-
87-
8877
if (_json_cid.isEmpty())
8978
{
9079
_e131_cid = QUuid::createUuid();
@@ -164,7 +153,7 @@ int LedDeviceUdpE131::write(const std::vector<ColorRgb> &ledValues)
164153
{
165154
int retVal = 0;
166155
int thisChannelCount = 0;
167-
int dmxChannelCount = _ledRGBWCount; // Use _ledRGBWCount
156+
int dmxChannelCount = (_whiteAlgorithm == RGBW::WhiteAlgorithm::WHITE_OFF) ? _ledRGBCount : _ledRGBWCount; // if white_off we expect 3 channels per LED otherwise 4
168157

169158
// Create a temporary buffer for RGB or RGBW data
170159
std::vector<uint8_t> tempBuffer(dmxChannelCount);
@@ -193,26 +182,26 @@ int LedDeviceUdpE131::write(const std::vector<ColorRgb> &ledValues)
193182

194183
for (int rawIdx = 0; rawIdx < dmxChannelCount; rawIdx++)
195184
{
196-
if (rawIdx % DMX_MAX == 0) // start of new packet
185+
if (rawIdx % _e131_dmx_max == 0) // start of new packet
197186
{
198-
thisChannelCount = (dmxChannelCount - rawIdx < DMX_MAX) ? dmxChannelCount % DMX_MAX : DMX_MAX;
187+
thisChannelCount = (dmxChannelCount - rawIdx < _e131_dmx_max) ? dmxChannelCount % _e131_dmx_max : _e131_dmx_max;
199188
// is this the last packet? ? ^^ last packet : ^^ earlier packets
200189

201-
prepare(_e131_universe + rawIdx / DMX_MAX, thisChannelCount);
190+
prepare(_e131_universe + rawIdx / _e131_dmx_max, thisChannelCount);
202191
e131_packet.sequence_number = _e131_seq;
203192
}
204193

205-
e131_packet.property_values[1 + rawIdx % DMX_MAX] = rawDataPtr[rawIdx];
194+
e131_packet.property_values[1 + rawIdx % _e131_dmx_max] = rawDataPtr[rawIdx];
206195

207196
// is this the last byte of last packet || last byte of other packets
208-
if ((rawIdx == dmxChannelCount - 1) || (rawIdx % DMX_MAX == DMX_MAX - 1))
197+
if ((rawIdx == dmxChannelCount - 1) || (rawIdx % _e131_dmx_max == _e131_dmx_max - 1))
209198
{
210199
#undef e131debug
211200
#if e131debug
212201
Debug (_log, "send packet: rawidx %d dmxchannelcount %d universe: %d, packetsz %d"
213202
, rawIdx
214203
, dmxChannelCount
215-
, _e131_universe + rawIdx / DMX_MAX
204+
, _e131_universe + rawIdx / _e131_dmx_max
216205
, E131_DMP_DATA + 1 + thisChannelCount
217206
);
218207
#endif

libsrc/leddevice/dev_net/LedDeviceUdpE131.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,13 @@ class LedDeviceUdpE131 : public ProviderUdp
141141
e131_packet_t e131_packet;
142142
uint8_t _e131_seq = 0;
143143
uint8_t _e131_universe = 1;
144+
int _e131_dmx_max = 512;
144145
uint8_t _acn_id[12] = {0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e, 0x31, 0x37, 0x00, 0x00, 0x00 };
145146
QString _e131_source_name;
146147
QUuid _e131_cid;
147148

148149
// RGBW specific members
149150
RGBW::WhiteAlgorithm _whiteAlgorithm;
150-
int _ledRGBWCount;
151151
ColorRgbw _temp_rgbw;
152152
};
153153

libsrc/leddevice/schemas/schema-e131.json

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
"default": 1,
2323
"propertyOrder": 3
2424
},
25+
"dmx-max": {
26+
"type": "integer",
27+
"title": "edt_dev_spec_dmx_max_title",
28+
"default": 512,
29+
"propertyOrder": 4
30+
},
2531
"latchTime": {
2632
"type": "integer",
2733
"title": "edt_dev_spec_latchtime_title",
@@ -30,30 +36,43 @@
3036
"minimum": 0,
3137
"maximum": 1000,
3238
"access": "expert",
33-
"propertyOrder": 4
39+
"propertyOrder": 5
3440
},
3541
"cid": {
3642
"type": "string",
3743
"title": "edt_dev_spec_cid_title",
38-
"propertyOrder": 5
44+
"propertyOrder": 6
3945
},
46+
4047
"whiteAlgorithm": {
4148
"type": "string",
42-
"title": "edt_dev_spec_white_algorithm_title",
43-
"enum": [
44-
"white_off",
45-
"subtractive",
46-
"additive"
49+
"title":"edt_dev_spec_whiteLedAlgor_title",
50+
"enum" : [
51+
"subtract_minimum",
52+
"sub_min_cool_adjust",
53+
"sub_min_warm_adjust",
54+
"cold_white",
55+
"neutral_white",
56+
"auto",
57+
"auto_max",
58+
"auto_accurate",
59+
"white_off"
4760
],
4861
"default": "white_off",
49-
"propertyOrder": 6,
50-
"options": {
51-
"enum_titles": [
52-
"edt_dev_spec_white_algorithm_white_off",
53-
"edt_dev_spec_white_algorithm_subtractive",
54-
"edt_dev_spec_white_algorithm_additive"
55-
]
56-
}
62+
"options" : {
63+
"enum_titles" : [
64+
"edt_dev_enum_subtract_minimum",
65+
"edt_dev_enum_sub_min_cool_adjust",
66+
"edt_dev_enum_sub_min_warm_adjust",
67+
"edt_dev_enum_cold_white",
68+
"edt_dev_enum_neutral_white",
69+
"edt_dev_enum_auto",
70+
"edt_dev_enum_auto_max",
71+
"edt_dev_enum_auto_accurate",
72+
"edt_dev_enum_white_off"
73+
]
74+
},
75+
"propertyOrder" : 7
5776
}
5877
},
5978
"additionalProperties": true

0 commit comments

Comments
 (0)