@@ -2273,16 +2273,16 @@ void WS2812FX::loadCustomPalettes() {
|
|||||||
|
|
||||||
if (readObjectFromFile(fileName, nullptr, &pDoc)) {
|
if (readObjectFromFile(fileName, nullptr, &pDoc)) {
|
||||||
JsonArray pal = pDoc[F("palette")];
|
JsonArray pal = pDoc[F("palette")];
|
||||||
if (!pal.isNull() && pal.size()>4) { // not an empty palette (at least 2 entries)
|
if (!pal.isNull() && pal.size()>3) { // not an empty palette (at least 2 entries)
|
||||||
if (pal[0].is<int>() && pal[1].is<const char *>()) {
|
if (pal[0].is<int>() && pal[1].is<const char *>()) {
|
||||||
// we have an array of index & hex strings
|
// we have an array of index & hex strings
|
||||||
size_t palSize = min(pal.size(), (size_t)36); // WLEDMM use native min/max
|
size_t palSize = min(pal.size(), (size_t)36); // WLEDMM use native min/max
|
||||||
palSize -= palSize % 2; // make sure size is multiple of 2
|
palSize -= palSize % 2; // make sure size is multiple of 2
|
||||||
for (size_t i=0, j=0; i<palSize && pal[i].as<int>()<256; i+=2, j+=4) {
|
for (unsigned i=0, j=0; i<palSize && pal[i].as<int>()<256; i+=2, j+=4) {
|
||||||
uint8_t rgbw[] = {0,0,0,0};
|
uint8_t rgbw[] = {0,0,0,0};
|
||||||
tcp[ j ] = (uint8_t) pal[ i ].as<int>(); // index
|
tcp[ j ] = (uint8_t) pal[ i ].as<int>(); // index
|
||||||
colorFromHexString(rgbw, pal[i+1].as<const char *>()); // will catch non-string entires
|
colorFromHexString(rgbw, pal[i+1].as<const char *>()); // will catch non-string entires
|
||||||
for (size_t c=0; c<3; c++) tcp[j+1+c] = rgbw[c]; // only use RGB component
|
for (unsigned c=0; c<3; c++) tcp[j+1+c] = gamma8(rgbw[c]); // only use RGB component
|
||||||
DEBUG_PRINTF("%d(%d) : %d %d %d\n", i, int(tcp[j]), int(tcp[j+1]), int(tcp[j+2]), int(tcp[j+3]));
|
DEBUG_PRINTF("%d(%d) : %d %d %d\n", i, int(tcp[j]), int(tcp[j+1]), int(tcp[j+2]), int(tcp[j+3]));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -2290,13 +2290,15 @@ void WS2812FX::loadCustomPalettes() {
|
|||||||
palSize -= palSize % 4; // make sure size is multiple of 4
|
palSize -= palSize % 4; // make sure size is multiple of 4
|
||||||
for (size_t i=0; i<palSize && pal[i].as<int>()<256; i+=4) {
|
for (size_t i=0; i<palSize && pal[i].as<int>()<256; i+=4) {
|
||||||
tcp[ i ] = (uint8_t) pal[ i ].as<int>(); // index
|
tcp[ i ] = (uint8_t) pal[ i ].as<int>(); // index
|
||||||
tcp[i+1] = (uint8_t) pal[i+1].as<int>(); // R
|
tcp[i+1] = gamma8((uint8_t) pal[i+1].as<int>()); // R
|
||||||
tcp[i+2] = (uint8_t) pal[i+2].as<int>(); // G
|
tcp[i+2] = gamma8((uint8_t) pal[i+2].as<int>()); // G
|
||||||
tcp[i+3] = (uint8_t) pal[i+3].as<int>(); // B
|
tcp[i+3] = gamma8((uint8_t) pal[i+3].as<int>()); // B
|
||||||
DEBUG_PRINTF("%d(%d) : %d %d %d\n", i, int(tcp[i]), int(tcp[i+1]), int(tcp[i+2]), int(tcp[i+3]));
|
DEBUG_PRINTF("%d(%d) : %d %d %d\n", i, int(tcp[i]), int(tcp[i+1]), int(tcp[i+2]), int(tcp[i+3]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
customPalettes.push_back(targetPalette.loadDynamicGradientPalette(tcp));
|
customPalettes.push_back(targetPalette.loadDynamicGradientPalette(tcp));
|
||||||
|
} else {
|
||||||
|
DEBUG_PRINTLN(F("Wrong palette format."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 2404090
|
#define VERSION 2404091
|
||||||
|
|
||||||
// WLEDMM - you can check for this define in usermods, to only enabled WLEDMM specific code in the "right" fork. Its not defined in AC WLED.
|
// WLEDMM - you can check for this define in usermods, to only enabled WLEDMM specific code in the "right" fork. Its not defined in AC WLED.
|
||||||
#define _MoonModules_WLED_
|
#define _MoonModules_WLED_
|
||||||
|
|||||||
Reference in New Issue
Block a user