Bugfixes:

- #3843
- #3844
- network scan on new install
- misc optimization
This commit is contained in:
Blaz Kristan 2024-03-22 20:49:13 +01:00
parent 3c23672347
commit ecfdc6f0a8
8 changed files with 23 additions and 9 deletions

View File

@ -632,12 +632,12 @@ static const char s_cfg_json[] PROGMEM = "/cfg.json";
void deserializeConfigFromFS() { void deserializeConfigFromFS() {
bool success = deserializeConfigSec(); bool success = deserializeConfigSec();
#ifdef WLED_ADD_EEPROM_SUPPORT
if (!success) { //if file does not exist, try reading from EEPROM if (!success) { //if file does not exist, try reading from EEPROM
#ifdef WLED_ADD_EEPROM_SUPPORT
deEEPSettings(); deEEPSettings();
return; return;
#endif
} }
#endif
if (!requestJSONBufferLock(1)) return; if (!requestJSONBufferLock(1)) return;

View File

@ -375,6 +375,7 @@
//Playlist option byte //Playlist option byte
#define PL_OPTION_SHUFFLE 0x01 #define PL_OPTION_SHUFFLE 0x01
#define PL_OPTION_RESTORE 0x02
// Segment capability byte // Segment capability byte
#define SEG_CAPABILITY_RGB 0x01 #define SEG_CAPABILITY_RGB 0x01

View File

@ -1984,7 +1984,7 @@ function makeP(i,pl)
<div class="sel">End preset:<br> <div class="sel">End preset:<br>
<div class="sel-p"><select class="sel-ple" id="pl${i}selEnd" onchange="plR(${i})" data-val=${plJson[i].end?plJson[i].end:0}> <div class="sel-p"><select class="sel-ple" id="pl${i}selEnd" onchange="plR(${i})" data-val=${plJson[i].end?plJson[i].end:0}>
<option value="0">None</option> <option value="0">None</option>
<option value="255">Restore preset</option> <option value="255" ${plJson[i].end && plJson[i].end==255?"selected":""}>Restore preset</option>
${makePlSel(plJson[i].end?plJson[i].end:0, true)} ${makePlSel(plJson[i].end?plJson[i].end:0, true)}
</select></div></div> </select></div></div>
</div> </div>

View File

@ -84,7 +84,7 @@
option.textContent = "Other network..."; option.textContent = "Other network...";
select.appendChild(option); select.appendChild(option);
if (input.value === "" || found) input.replaceWith(select); if (input.value === "" || input.value === "Your_Network" || found) input.replaceWith(select);
else select.remove(); else select.remove();
} }

View File

@ -233,6 +233,7 @@ const char *getPresetsFileName(bool persistent = true);
void initPresetsFile(); void initPresetsFile();
void handlePresets(); void handlePresets();
bool applyPreset(byte index, byte callMode = CALL_MODE_DIRECT_CHANGE); bool applyPreset(byte index, byte callMode = CALL_MODE_DIRECT_CHANGE);
bool applyPresetFromPlaylist(byte index);
void applyPresetWithFallback(uint8_t presetID, uint8_t callMode, uint8_t effectID = 0, uint8_t paletteID = 0); void applyPresetWithFallback(uint8_t presetID, uint8_t callMode, uint8_t effectID = 0, uint8_t paletteID = 0);
inline bool applyTemporaryPreset() {return applyPreset(255);}; inline bool applyTemporaryPreset() {return applyPreset(255);};
void savePreset(byte index, const char* pname = nullptr, JsonObject saveobj = JsonObject()); void savePreset(byte index, const char* pname = nullptr, JsonObject saveobj = JsonObject());

View File

@ -109,7 +109,10 @@ int16_t loadPlaylist(JsonObject playlistObj, byte presetId) {
if (playlistRepeat > 0) playlistRepeat++; //add one extra repetition immediately since it will be deducted on first start if (playlistRepeat > 0) playlistRepeat++; //add one extra repetition immediately since it will be deducted on first start
playlistEndPreset = playlistObj["end"] | 0; playlistEndPreset = playlistObj["end"] | 0;
// if end preset is 255 restore original preset (if any running) upon playlist end // if end preset is 255 restore original preset (if any running) upon playlist end
if (playlistEndPreset == 255 && currentPreset > 0) playlistEndPreset = currentPreset; if (playlistEndPreset == 255 && currentPreset > 0) {
playlistEndPreset = currentPreset;
playlistOptions |= PL_OPTION_RESTORE; // for async save operation
}
if (playlistEndPreset > 250) playlistEndPreset = 0; if (playlistEndPreset > 250) playlistEndPreset = 0;
shuffle = shuffle || playlistObj["r"]; shuffle = shuffle || playlistObj["r"];
if (shuffle) playlistOptions |= PL_OPTION_SHUFFLE; if (shuffle) playlistOptions |= PL_OPTION_SHUFFLE;
@ -135,7 +138,7 @@ void handlePlaylist() {
if (!playlistIndex) { if (!playlistIndex) {
if (playlistRepeat == 1) { //stop if all repetitions are done if (playlistRepeat == 1) { //stop if all repetitions are done
unloadPlaylist(); unloadPlaylist();
if (playlistEndPreset) applyPreset(playlistEndPreset); if (playlistEndPreset) applyPresetFromPlaylist(playlistEndPreset);
return; return;
} }
if (playlistRepeat > 1) playlistRepeat--; // decrease repeat count on each index reset if not an endless playlist if (playlistRepeat > 1) playlistRepeat--; // decrease repeat count on each index reset if not an endless playlist
@ -146,7 +149,7 @@ void handlePlaylist() {
jsonTransitionOnce = true; jsonTransitionOnce = true;
strip.setTransition(fadeTransition ? playlistEntries[playlistIndex].tr * 100 : 0); strip.setTransition(fadeTransition ? playlistEntries[playlistIndex].tr * 100 : 0);
playlistEntryDur = playlistEntries[playlistIndex].dur; playlistEntryDur = playlistEntries[playlistIndex].dur;
applyPreset(playlistEntries[playlistIndex].preset); applyPresetFromPlaylist(playlistEntries[playlistIndex].preset);
} }
} }
@ -157,7 +160,7 @@ void serializePlaylist(JsonObject sObj) {
JsonArray dur = playlist.createNestedArray("dur"); JsonArray dur = playlist.createNestedArray("dur");
JsonArray transition = playlist.createNestedArray(F("transition")); JsonArray transition = playlist.createNestedArray(F("transition"));
playlist[F("repeat")] = (playlistIndex < 0 && playlistRepeat > 0) ? playlistRepeat - 1 : playlistRepeat; // remove added repetition count (if not yet running) playlist[F("repeat")] = (playlistIndex < 0 && playlistRepeat > 0) ? playlistRepeat - 1 : playlistRepeat; // remove added repetition count (if not yet running)
playlist["end"] = playlistEndPreset; playlist["end"] = playlistOptions & PL_OPTION_RESTORE ? 255 : playlistEndPreset;
playlist["r"] = playlistOptions & PL_OPTION_SHUFFLE; playlist["r"] = playlistOptions & PL_OPTION_SHUFFLE;
for (int i=0; i<playlistLen; i++) { for (int i=0; i<playlistLen; i++) {
ps.add(playlistEntries[i].preset); ps.add(playlistEntries[i].preset);

View File

@ -117,6 +117,15 @@ void initPresetsFile()
f.close(); f.close();
} }
bool applyPresetFromPlaylist(byte index)
{
DEBUG_PRINT(F("Request to apply preset: "));
DEBUG_PRINTLN(index);
presetToApply = index;
callModeToApply = CALL_MODE_DIRECT_CHANGE;
return true;
}
bool applyPreset(byte index, byte callMode) bool applyPreset(byte index, byte callMode)
{ {
unloadPlaylist(); // applying a preset unloads the playlist (#3827) unloadPlaylist(); // applying a preset unloads the playlist (#3827)

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2403190 #define VERSION 2403220
//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