Skip to content

Commit

Permalink
fix ESPixelStick v4 DMX upload, it shares Pixel/Serial ports, Serial …
Browse files Browse the repository at this point in the history
…will override Pixel Ports
  • Loading branch information
computergeek1507 committed Aug 22, 2024
1 parent 2efc5b9 commit 6f1488a
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 118 deletions.
238 changes: 121 additions & 117 deletions xLights/controllers/ESPixelStick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,145 +465,149 @@ bool ESPixelStick::SetOutputsV4(ModelManager* allmodels, OutputManager* outputMa
GetOutputConfig(outputConfig);

for (int x = 0; x < cud.GetMaxPixelPort(); x++) {
UDControllerPort* port = cud.GetControllerPixelPort(x + 1);
std::string const proto = MapV4Type(port->GetProtocol());
std::string const pixels = std::to_string(port->Pixels());
int brightness{ -1 };
float gamma{ -1.0F };
std::string colorOrder;
int groupCount{ -1 };
int startNulls{ -1 };
int endNulls{ -1 };
auto s = port->GetModels().front();
if (s) {
brightness = s->GetBrightness(-1);
colorOrder = MapV4ColorOrder(s->GetColourOrder(""));
gamma = s->GetGamma(-1.0F);
int gc = s->GetGroupCount(-1);
if (gc == 0) {
gc = 1;
if (cud.HasPixelPort(x + 1)) {
UDControllerPort* port = cud.GetControllerPixelPort(x + 1);
std::string const proto = MapV4Type(port->GetProtocol());
std::string const pixels = std::to_string(port->Pixels());
int brightness{ -1 };
float gamma{ -1.0F };
std::string colorOrder;
int groupCount{ -1 };
int startNulls{ -1 };
int endNulls{ -1 };
auto s = port->GetModels().front();
if (s) {
brightness = s->GetBrightness(-1);
colorOrder = MapV4ColorOrder(s->GetColourOrder(""));
gamma = s->GetGamma(-1.0F);
int gc = s->GetGroupCount(-1);
if (gc == 0) {
gc = 1;
}
groupCount = gc;
startNulls = s->GetStartNullPixels(-1);
endNulls = s->GetEndNullPixels(-1);
}
groupCount = gc;
startNulls = s->GetStartNullPixels(-1);
endNulls = s->GetEndNullPixels(-1);
}

std::string outidx = std::to_string(x);
std::string curIdx = std::to_string(outputConfig["channels"][outidx]["type"].AsInt());
if (outputConfig["channels"][outidx][curIdx]["type"].AsString() != proto) {
changed = true;
for (int i = 0; i < 20; i++) {
std::string idx = std::to_string(i);
if (!outputConfig["channels"][outidx].HasMember(idx)) {
return false;
}
if (outputConfig["channels"][outidx][idx]["type"].AsString() == proto) {
//found the new element, flip over to using that protocol
outputConfig["channels"][outidx]["type"] = i;
curIdx = idx;
break;
std::string outidx = std::to_string(x);
std::string curIdx = std::to_string(outputConfig["channels"][outidx]["type"].AsInt());
if (outputConfig["channels"][outidx][curIdx]["type"].AsString() != proto) {
changed = true;
for (int i = 0; i < 20; i++) {
std::string idx = std::to_string(i);
if (!outputConfig["channels"][outidx].HasMember(idx)) {
return false;
}
if (outputConfig["channels"][outidx][idx]["type"].AsString() == proto) {
// found the new element, flip over to using that protocol
outputConfig["channels"][outidx]["type"] = i;
curIdx = idx;
break;
}
}
}
}
if (proto == "WS2811" || proto == "TM1814") {
if (gamma > -1.0F) {
if (gamma < 1.0F) {
gamma = 1.0F;
if (proto == "WS2811" || proto == "TM1814") {
if (gamma > -1.0F) {
if (gamma < 1.0F) {
gamma = 1.0F;
}
if (gamma > 5.0F) {
gamma = 5.0F;
}
std::string const s_gamma = std::to_string(gamma);
if (s_gamma != outputConfig["channels"][outidx][curIdx]["gamma"].AsString()) {
changed = true;
outputConfig["channels"][outidx][curIdx]["gamma"] = s_gamma;
}
}
if (gamma > 5.0F) {
gamma = 5.0F;
if (brightness != -1) {
int b = brightness;
if (b > 100) {
b = 100;
}

std::string const b2 = std::to_string(b);
if (b2 != outputConfig["channels"][outidx][curIdx]["brightness"].AsString()) {
changed = true;
outputConfig["channels"][outidx][curIdx]["brightness"] = b2;
}
}
std::string const s_gamma = std::to_string(gamma);
if (s_gamma != outputConfig["channels"][outidx][curIdx]["gamma"].AsString()) {
if (!colorOrder.empty() && colorOrder != outputConfig["channels"][outidx][curIdx]["color_order"].AsString()) {
changed = true;
outputConfig["channels"][outidx][curIdx]["gamma"] = s_gamma;
outputConfig["channels"][outidx][curIdx]["color_order"] = colorOrder;
}
}
if (brightness != -1) {
int b = brightness;
if (b > 100) {
b = 100;
if (groupCount != -1) {
std::string const s_groupCount = std::to_string(groupCount);
if (s_groupCount != outputConfig["channels"][outidx][curIdx]["group_size"].AsString()) {
changed = true;
outputConfig["channels"][outidx][curIdx]["group_size"] = s_groupCount;
}
}

std::string const b2 = std::to_string(b);
if (b2 != outputConfig["channels"][outidx][curIdx]["brightness"].AsString()) {
changed = true;
outputConfig["channels"][outidx][curIdx]["brightness"] = b2;
if (startNulls != -1) {
std::string const s_startNulls = std::to_string(startNulls);
if (s_startNulls != outputConfig["channels"][outidx][curIdx]["prependnullcount"].AsString()) {
changed = true;
outputConfig["channels"][outidx][curIdx]["prependnullcount"] = s_startNulls;
}
}
}
if (!colorOrder.empty() && colorOrder != outputConfig["channels"][outidx][curIdx]["color_order"].AsString()) {
changed = true;
outputConfig["channels"][outidx][curIdx]["color_order"] = colorOrder;
}
if (groupCount != -1) {
std::string const s_groupCount = std::to_string(groupCount);
if (s_groupCount != outputConfig["channels"][outidx][curIdx]["group_size"].AsString()) {
changed = true;
outputConfig["channels"][outidx][curIdx]["group_size"] = s_groupCount;
if (endNulls != -1) {
std::string const s_endNulls = std::to_string(endNulls);
if (s_endNulls != outputConfig["channels"][outidx][curIdx]["appendnullcount"].AsString()) {
changed = true;
outputConfig["channels"][outidx][curIdx]["appendnullcount"] = s_endNulls;
}
}
}
if (startNulls != -1) {
std::string const s_startNulls = std::to_string(startNulls);
if (s_startNulls != outputConfig["channels"][outidx][curIdx]["prependnullcount"].AsString()) {
if (pixels != outputConfig["channels"][outidx][curIdx]["pixel_count"].AsString()) {
changed = true;
outputConfig["channels"][outidx][curIdx]["prependnullcount"] = s_startNulls;
outputConfig["channels"][outidx][curIdx]["pixel_count"] = pixels;
}
}
if (endNulls != -1) {
std::string const s_endNulls = std::to_string(endNulls);
if (s_endNulls != outputConfig["channels"][outidx][curIdx]["appendnullcount"].AsString()) {
changed = true;
outputConfig["channels"][outidx][curIdx]["appendnullcount"] = s_endNulls;
} else if (proto == "GECE") {
if (brightness != -1) {
int b = brightness;
if (b > 100) {
b = 100;
}
std::string const b2 = std::to_string(b);
if (b2 != outputConfig["channels"][outidx][curIdx]["brightness"].AsString()) {
changed = true;
outputConfig["channels"][outidx][curIdx]["brightness"] = b2;
}
}
}
if (pixels != outputConfig["channels"][outidx][curIdx]["pixel_count"].AsString()) {
changed = true;
outputConfig["channels"][outidx][curIdx]["pixel_count"] = pixels;
}
} else if (proto == "GECE") {
if (brightness != -1) {
int b = brightness;
if (b > 100) {
b = 100;
}
std::string const b2 = std::to_string(b);
if (b2 != outputConfig["channels"][outidx][curIdx]["brightness"].AsString()) {

if (pixels != outputConfig["channels"][outidx][curIdx]["pixel_count"].AsString()) {
changed = true;
outputConfig["channels"][outidx][curIdx]["brightness"] = b2;
outputConfig["channels"][outidx][curIdx]["pixel_count"] = pixels;
}
}

if (pixels != outputConfig["channels"][outidx][curIdx]["pixel_count"].AsString()) {
changed = true;
outputConfig["channels"][outidx][curIdx]["pixel_count"] = pixels;
}
}
}
for (int x = 0; x < cud.GetMaxSerialPort(); x++) {
UDControllerPort* port = cud.GetControllerSerialPort(x + 1);
std::string proto = MapV4Type(port->GetProtocol());
std::string channels = std::to_string(port->Channels());

std::string outidx = std::to_string(x + rules->GetMaxPixelPort());
std::string curIdx = std::to_string(outputConfig["channels"][outidx]["type"].AsInt());
if (outputConfig["channels"][outidx][curIdx]["type"].AsString() != proto) {
changed = true;
for (int i = 0; i < 20; i++) {
std::string idx = std::to_string(i);
if (!outputConfig["channels"][outidx].HasMember(idx)) {
return false;
}
if (outputConfig["channels"][outidx][idx]["type"].AsString() == proto) {
//found the new element, flip over to using that protocol
outputConfig["channels"][outidx]["type"] = i;
curIdx = idx;
break;
if (cud.HasSerialPort(x + 1)) {
UDControllerPort* port = cud.GetControllerSerialPort(x + 1);
std::string proto = MapV4Type(port->GetProtocol());
std::string channels = std::to_string(port->Channels());

std::string outidx = std::to_string(x);
std::string curIdx = std::to_string(outputConfig["channels"][outidx]["type"].AsInt());
if (outputConfig["channels"][outidx][curIdx]["type"].AsString() != proto) {
changed = true;
for (int i = 0; i < 20; i++) {
std::string idx = std::to_string(i);
if (!outputConfig["channels"][outidx].HasMember(idx)) {
return false;
}
if (outputConfig["channels"][outidx][idx]["type"].AsString() == proto) {
// found the new element, flip over to using that protocol
outputConfig["channels"][outidx]["type"] = i;
curIdx = idx;
break;
}
}
}
}
if (channels != outputConfig["channels"][outidx][curIdx]["num_chan"].AsString()) {
changed = true;
outputConfig["channels"][outidx][curIdx]["num_chan"] = channels;
if (channels != outputConfig["channels"][outidx][curIdx]["num_chan"].AsString()) {
changed = true;
outputConfig["channels"][outidx][curIdx]["num_chan"] = channels;
}
}
}
if (changed)
Expand Down
2 changes: 1 addition & 1 deletion xLights/controllers/Experience.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ int32_t Experience::SetInputUniverses(wxJSONValue& data, Controller* controller)
} else {
//should never hit this
DisplayError(wxString::Format(
"Invalud Input Type For Experience Controller %s.",
"Invalid Input Type For Experience Controller %s.",
out->GetType())
.ToStdString());
return startChannel;
Expand Down

0 comments on commit 6f1488a

Please sign in to comment.