Select custom palette bugfix.
This commit is contained in:
parent
8e30e4925c
commit
8899684092
@ -191,7 +191,7 @@ private:
|
|||||||
re_sortModes(modes_qstrings, modes_alpha_indexes, strip.getModeCount(), MODE_SORT_SKIP_COUNT);
|
re_sortModes(modes_qstrings, modes_alpha_indexes, strip.getModeCount(), MODE_SORT_SKIP_COUNT);
|
||||||
|
|
||||||
palettes_qstrings = re_findModeStrings(JSON_palette_names, strip.getPaletteCount());
|
palettes_qstrings = re_findModeStrings(JSON_palette_names, strip.getPaletteCount());
|
||||||
palettes_alpha_indexes = re_initIndexArray(strip.getPaletteCount());
|
palettes_alpha_indexes = re_initIndexArray(strip.getPaletteCount()); // only use internal palettes
|
||||||
|
|
||||||
// How many palette names start with '*' and should not be sorted?
|
// How many palette names start with '*' and should not be sorted?
|
||||||
// (Also skipping the first one, 'Default').
|
// (Also skipping the first one, 'Default').
|
||||||
|
@ -767,7 +767,7 @@ class WS2812FX { // 96 bytes
|
|||||||
inline uint8_t getSegmentsNum(void) { return _segments.size(); } // returns currently present segments
|
inline uint8_t getSegmentsNum(void) { return _segments.size(); } // returns currently present segments
|
||||||
inline uint8_t getCurrSegmentId(void) { return _segment_index; }
|
inline uint8_t getCurrSegmentId(void) { return _segment_index; }
|
||||||
inline uint8_t getMainSegmentId(void) { return _mainSegment; }
|
inline uint8_t getMainSegmentId(void) { return _mainSegment; }
|
||||||
inline uint8_t getPaletteCount() { return 13 + GRADIENT_PALETTE_COUNT; }
|
inline uint8_t getPaletteCount() { return 13 + GRADIENT_PALETTE_COUNT; } // will only return built-in palette count
|
||||||
inline uint8_t getTargetFps() { return _targetFps; }
|
inline uint8_t getTargetFps() { return _targetFps; }
|
||||||
inline uint8_t getModeCount() { return _modeCount; }
|
inline uint8_t getModeCount() { return _modeCount; }
|
||||||
|
|
||||||
|
@ -418,12 +418,7 @@ void Segment::setMode(uint8_t fx, bool loadDefaults) {
|
|||||||
sOpt = extractModeDefaults(fx, "mi"); if (sOpt >= 0) mirror = (bool)sOpt; // NOTE: setting this option is a risky business
|
sOpt = extractModeDefaults(fx, "mi"); if (sOpt >= 0) mirror = (bool)sOpt; // NOTE: setting this option is a risky business
|
||||||
sOpt = extractModeDefaults(fx, "rY"); if (sOpt >= 0) reverse_y = (bool)sOpt;
|
sOpt = extractModeDefaults(fx, "rY"); if (sOpt >= 0) reverse_y = (bool)sOpt;
|
||||||
sOpt = extractModeDefaults(fx, "mY"); if (sOpt >= 0) mirror_y = (bool)sOpt; // NOTE: setting this option is a risky business
|
sOpt = extractModeDefaults(fx, "mY"); if (sOpt >= 0) mirror_y = (bool)sOpt; // NOTE: setting this option is a risky business
|
||||||
sOpt = extractModeDefaults(fx, "pal");
|
sOpt = extractModeDefaults(fx, "pal"); if (sOpt >= 0) setPalette(sOpt);
|
||||||
if (sOpt >= 0 && (size_t)sOpt < strip.getPaletteCount() + strip.customPalettes.size()) {
|
|
||||||
if (sOpt != palette) {
|
|
||||||
palette = sOpt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
stateChanged = true; // send UDP/WS broadcast
|
stateChanged = true; // send UDP/WS broadcast
|
||||||
}
|
}
|
||||||
@ -431,14 +426,14 @@ void Segment::setMode(uint8_t fx, bool loadDefaults) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Segment::setPalette(uint8_t pal) {
|
void Segment::setPalette(uint8_t pal) {
|
||||||
if (pal < strip.getPaletteCount()) {
|
if (pal < 245 && pal > GRADIENT_PALETTE_COUNT+13) pal = 0; // built in palettes
|
||||||
|
if (pal > 245 && (strip.customPalettes.size() == 0 || 255U-pal > strip.customPalettes.size()-1)) pal = 0; // custom palettes
|
||||||
if (pal != palette) {
|
if (pal != palette) {
|
||||||
if (strip.paletteFade) startTransition(strip.getTransition());
|
if (strip.paletteFade) startTransition(strip.getTransition());
|
||||||
palette = pal;
|
palette = pal;
|
||||||
}
|
|
||||||
}
|
|
||||||
stateChanged = true; // send UDP/WS broadcast
|
stateChanged = true; // send UDP/WS broadcast
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 2D matrix
|
// 2D matrix
|
||||||
uint16_t Segment::virtualWidth() const {
|
uint16_t Segment::virtualWidth() const {
|
||||||
|
@ -1535,8 +1535,8 @@ function requestJson(command=null)
|
|||||||
if (json.info) {
|
if (json.info) {
|
||||||
let i = json.info;
|
let i = json.info;
|
||||||
// append custom palettes (when loading for the 1st time)
|
// append custom palettes (when loading for the 1st time)
|
||||||
if (!command && isEmpty(lastinfo) && i.leds && i.leds.cpal) {
|
if (!command && isEmpty(lastinfo) && i.cpalcount) {
|
||||||
for (let j = 0; j<i.leds.cpal; j++) {
|
for (let j = 0; j<i.cpalcount; j++) {
|
||||||
let div = d.createElement("div");
|
let div = d.createElement("div");
|
||||||
gId('pallist').appendChild(div);
|
gId('pallist').appendChild(div);
|
||||||
div.outerHTML = generateListItemHtml(
|
div.outerHTML = generateListItemHtml(
|
||||||
|
1873
wled00/html_ui.h
1873
wled00/html_ui.h
File diff suppressed because it is too large
Load Diff
@ -110,7 +110,7 @@ void changePalette(uint8_t pal)
|
|||||||
for (uint8_t i = 0; i < strip.getSegmentsNum(); i++) {
|
for (uint8_t i = 0; i < strip.getSegmentsNum(); i++) {
|
||||||
Segment& seg = strip.getSegment(i);
|
Segment& seg = strip.getSegment(i);
|
||||||
if (!seg.isActive() || !seg.isSelected()) continue;
|
if (!seg.isActive() || !seg.isSelected()) continue;
|
||||||
seg.palette = pal;
|
seg.setPalette(pal);
|
||||||
}
|
}
|
||||||
setValuesFromFirstSelectedSeg();
|
setValuesFromFirstSelectedSeg();
|
||||||
} else {
|
} else {
|
||||||
|
@ -190,7 +190,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
|||||||
getVal(elem["ix"], &seg.intensity);
|
getVal(elem["ix"], &seg.intensity);
|
||||||
|
|
||||||
uint8_t pal = seg.palette;
|
uint8_t pal = seg.palette;
|
||||||
if (getVal(elem["pal"], &pal, 1, strip.getPaletteCount())) seg.setPalette(pal);
|
if (getVal(elem["pal"], &pal)) seg.setPalette(pal);
|
||||||
|
|
||||||
getVal(elem["c1"], &seg.custom1);
|
getVal(elem["c1"], &seg.custom1);
|
||||||
getVal(elem["c2"], &seg.custom2);
|
getVal(elem["c2"], &seg.custom2);
|
||||||
@ -566,7 +566,6 @@ void serializeInfo(JsonObject root)
|
|||||||
leds[F("maxseg")] = strip.getMaxSegments();
|
leds[F("maxseg")] = strip.getMaxSegments();
|
||||||
//leds[F("actseg")] = strip.getActiveSegmentsNum();
|
//leds[F("actseg")] = strip.getActiveSegmentsNum();
|
||||||
//leds[F("seglock")] = false; //might be used in the future to prevent modifications to segment config
|
//leds[F("seglock")] = false; //might be used in the future to prevent modifications to segment config
|
||||||
leds[F("cpal")] = strip.customPalettes.size(); //number of custom palettes
|
|
||||||
|
|
||||||
#ifndef WLED_DISABLE_2D
|
#ifndef WLED_DISABLE_2D
|
||||||
if (strip.isMatrix) {
|
if (strip.isMatrix) {
|
||||||
@ -636,6 +635,7 @@ void serializeInfo(JsonObject root)
|
|||||||
|
|
||||||
root[F("fxcount")] = strip.getModeCount();
|
root[F("fxcount")] = strip.getModeCount();
|
||||||
root[F("palcount")] = strip.getPaletteCount();
|
root[F("palcount")] = strip.getPaletteCount();
|
||||||
|
root[F("cpalcount")] = strip.customPalettes.size(); //number of custom palettes
|
||||||
|
|
||||||
JsonArray ledmaps = root.createNestedArray(F("maps"));
|
JsonArray ledmaps = root.createNestedArray(F("maps"));
|
||||||
for (size_t i=0; i<10; i++) {
|
for (size_t i=0; i<10; i++) {
|
||||||
|
@ -411,10 +411,10 @@ void handleNotifications()
|
|||||||
for (size_t i = 0; i < strip.getSegmentsNum(); i++) {
|
for (size_t i = 0; i < strip.getSegmentsNum(); i++) {
|
||||||
Segment& seg = strip.getSegment(i);
|
Segment& seg = strip.getSegment(i);
|
||||||
if (!seg.isActive() || !seg.isSelected()) continue;
|
if (!seg.isActive() || !seg.isSelected()) continue;
|
||||||
if (udpIn[8] < strip.getModeCount()) strip.setMode(i, udpIn[8]);
|
seg.setMode(udpIn[8]);
|
||||||
seg.speed = udpIn[9];
|
seg.speed = udpIn[9];
|
||||||
if (version > 2) seg.intensity = udpIn[16];
|
if (version > 2) seg.intensity = udpIn[16];
|
||||||
if (version > 4 && udpIn[19] < strip.getPaletteCount()) seg.palette = udpIn[19];
|
if (version > 4) seg.setPalette(udpIn[19]);
|
||||||
}
|
}
|
||||||
stateChanged = true;
|
stateChanged = true;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 2211220
|
#define VERSION 2211250
|
||||||
|
|
||||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||||
//#define WLED_USE_MY_CONFIG
|
//#define WLED_USE_MY_CONFIG
|
||||||
|
Loading…
Reference in New Issue
Block a user