Merge pull request #124 from netmindz/auto-playlist
New Usermod - Auto Playlist
This commit is contained in:
@@ -65,10 +65,10 @@ void WS2812FX::setUpMatrix() {
|
||||
}
|
||||
|
||||
USER_PRINTF("setUpMatrix %d x %d\n", Segment::maxWidth, Segment::maxHeight);
|
||||
|
||||
|
||||
//WLEDMM recreate customMappingTable if more space needed
|
||||
if (Segment::maxWidth * Segment::maxHeight > customMappingTableSize) {
|
||||
size_t size = max(ledmapMaxSize, size_t(Segment::maxWidth * Segment::maxHeight));//TroyHack
|
||||
size_t size = max(ledmapMaxSize, size_t(Segment::maxWidth * Segment::maxHeight)); // TroyHacks
|
||||
USER_PRINTF("setupmatrix customMappingTable alloc %d from %d\n", size, customMappingTableSize);
|
||||
//if (customMappingTable != nullptr) delete[] customMappingTable;
|
||||
//customMappingTable = new uint16_t[size];
|
||||
|
||||
@@ -115,7 +115,7 @@ Segment::Segment(const Segment &orig) {
|
||||
|
||||
//WLEDMM: recreate ledsrgb if more space needed (will not free ledsrgb!)
|
||||
void Segment::allocLeds() {
|
||||
size_t size = sizeof(CRGB)*max((size_t) length(), ledmapMaxSize); //TroyHack
|
||||
size_t size = sizeof(CRGB)*max((size_t) length(), ledmapMaxSize); // TroyHacks
|
||||
if ((size < sizeof(CRGB)) || (size > 164000)) { //softhack too small (<3) or too large (>160Kb)
|
||||
DEBUG_PRINTF("allocLeds warning: size == %u !!\n", size);
|
||||
if (ledsrgb && (ledsrgbSize == 0)) {
|
||||
@@ -1552,7 +1552,7 @@ void WS2812FX::enumerateLedmaps() {
|
||||
|
||||
USER_PRINTF("enumerateLedmaps %s \"%s\"", fileName, name);
|
||||
if (isMatrix) {
|
||||
//WLEDMM calc ledmapMaxSize (TroyHack)
|
||||
//WLEDMM calc ledmapMaxSize (TroyHacks)
|
||||
char dim[34] = { '\0' };
|
||||
f.find("\"width\":");
|
||||
f.readBytesUntil('\n', dim, sizeof(dim)-1); //hack: use fileName as we have this allocated already
|
||||
@@ -2406,7 +2406,7 @@ bool WS2812FX::deserializeMap(uint8_t n) {
|
||||
|
||||
//WLEDMM recreate customMappingTable if more space needed
|
||||
if (Segment::maxWidth * Segment::maxHeight > customMappingTableSize) {
|
||||
size_t size = max(ledmapMaxSize, size_t(Segment::maxWidth * Segment::maxHeight));//TroyHack
|
||||
size_t size = max(ledmapMaxSize, size_t(Segment::maxWidth * Segment::maxHeight)); // TroyHacks
|
||||
USER_PRINTF("deserializemap customMappingTable alloc %u from %u\n", size, customMappingTableSize);
|
||||
//if (customMappingTable != nullptr) delete[] customMappingTable;
|
||||
//customMappingTable = new uint16_t[size];
|
||||
|
||||
@@ -142,6 +142,7 @@
|
||||
#define USERMOD_ID_WEATHER 91 //Usermod "usermod_v2_weather.h"
|
||||
#define USERMOD_ID_GAMES 92 //Usermod "usermod_v2_games.h"
|
||||
#define USERMOD_ID_ANIMARTRIX 93 //Usermod "usermod_v2_animartrix.h"
|
||||
#define USERMOD_ID_AUTOPLAYLIST 94 // Usermod usermod_v2_auto_playlist.h
|
||||
|
||||
//Access point behavior
|
||||
#define AP_BEHAVIOR_BOOT_NO_CONN 0 //Open AP when no connection after boot
|
||||
|
||||
@@ -208,6 +208,7 @@ void _overlayAnalogCountdown();
|
||||
void _overlayAnalogClock();
|
||||
|
||||
//playlist.cpp
|
||||
void suspendPlaylist(); // WLEDMM support function for auto playlist usermod
|
||||
void shufflePlaylist();
|
||||
void unloadPlaylist();
|
||||
int16_t loadPlaylist(JsonObject playlistObject, byte presetId = 0);
|
||||
|
||||
@@ -41,6 +41,12 @@ void shufflePlaylist() {
|
||||
DEBUG_PRINTLN(F("Playlist shuffle."));
|
||||
}
|
||||
|
||||
// WLEDMM supporting function for auto_playlist usermod
|
||||
// prevents the active playlist from progressing (until it gets unloaded)
|
||||
static bool playlistSuspended = false;
|
||||
void suspendPlaylist() {
|
||||
playlistSuspended = true;
|
||||
}
|
||||
|
||||
void unloadPlaylist() {
|
||||
if (playlistEntries != nullptr) {
|
||||
@@ -49,6 +55,7 @@ void unloadPlaylist() {
|
||||
}
|
||||
currentPlaylist = playlistIndex = -1;
|
||||
playlistLen = playlistEntryDur = playlistOptions = 0;
|
||||
playlistSuspended = false; // WLEDMM
|
||||
DEBUG_PRINTLN(F("Playlist unloaded."));
|
||||
}
|
||||
|
||||
@@ -125,6 +132,11 @@ void handlePlaylist() {
|
||||
// if fileDoc is not null JSON buffer is in use so just quit
|
||||
if (currentPlaylist < 0 || playlistEntries == nullptr || fileDoc != nullptr) return;
|
||||
|
||||
if (playlistSuspended) { // WLEDMM
|
||||
if (millis() - presetCycledTime > (100*playlistEntryDur)) presetCycledTime = millis(); // keep updating timer
|
||||
return; // but don't progress to next extry, and don't shuffle
|
||||
}
|
||||
|
||||
if (millis() - presetCycledTime > (100*playlistEntryDur)) {
|
||||
presetCycledTime = millis();
|
||||
if (bri == 0 || nightlightActive) return;
|
||||
|
||||
@@ -203,6 +203,9 @@
|
||||
#ifdef USERMOD_ANIMARTRIX
|
||||
#include "../usermods/usermod_v2_animartrix/usermod_v2_animartrix.h"
|
||||
#endif
|
||||
#ifdef USERMOD_AUTO_PLAYLIST
|
||||
#include "../usermods/usermod_v2_auto_playlist/usermod_v2_auto_playlist.h"
|
||||
#endif
|
||||
|
||||
void registerUsermods()
|
||||
{
|
||||
@@ -402,4 +405,9 @@ void registerUsermods()
|
||||
usermods.add(new AnimartrixUsermod("Animartrix", false));
|
||||
#endif
|
||||
|
||||
#ifdef USERMOD_AUTO_PLAYLIST
|
||||
usermods.add(new AutoPlaylistUsermod(false));
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user