functionality_enabled logic
This commit is contained in:
@@ -22,6 +22,7 @@ class AutoPlaylistUsermod : public Usermod {
|
||||
bool autoChange = false;
|
||||
byte lastAutoPlaylist = 0;
|
||||
unsigned long change_timer = millis();
|
||||
unsigned long autochange_timer = millis();
|
||||
|
||||
uint_fast32_t energy = 0;
|
||||
|
||||
@@ -85,6 +86,8 @@ class AutoPlaylistUsermod : public Usermod {
|
||||
|
||||
uint8_t *fftResult = (uint8_t*)um_data->u_data[2];
|
||||
|
||||
energy = 0;
|
||||
|
||||
for (int i=0; i < NUM_GEQ_CHANNELS; i++) {
|
||||
energy += fftResult[i];
|
||||
}
|
||||
@@ -136,12 +139,12 @@ class AutoPlaylistUsermod : public Usermod {
|
||||
// the current music, especially after track changes or during
|
||||
// sparce intros and breakdowns.
|
||||
|
||||
if (change_interval > ideal_change_min && distance_tracker <= 1000) {
|
||||
if (change_interval > ideal_change_min && distance_tracker <= 100) {
|
||||
|
||||
change_threshold_change = distance_tracker-change_threshold;
|
||||
change_threshold = distance_tracker;
|
||||
|
||||
if (change_threshold_change > 9999999) change_threshold_change = 0;
|
||||
if (change_threshold_change > 9999) change_threshold_change = 0; // cosmetic for debug
|
||||
|
||||
if (functionality_enabled) {
|
||||
#ifdef USERMOD_AUTO_PLAYLIST_DEBUG
|
||||
@@ -157,7 +160,7 @@ class AutoPlaylistUsermod : public Usermod {
|
||||
|
||||
}
|
||||
|
||||
if (functionality_enabled && distance <= change_threshold && change_interval > change_lockout && volumeSmth > 1.0f) {
|
||||
if (distance <= change_threshold && change_interval > change_lockout && volumeSmth > 1.0f) {
|
||||
|
||||
change_threshold_change = change_threshold-(distance*0.9f);
|
||||
|
||||
@@ -175,6 +178,8 @@ class AutoPlaylistUsermod : public Usermod {
|
||||
|
||||
distance_tracker = UINT_FAST32_MAX;
|
||||
|
||||
if (functionality_enabled) {
|
||||
|
||||
if (autoChangeIds.size() == 0) {
|
||||
if(currentPlaylist < 1) return;
|
||||
|
||||
@@ -224,6 +229,8 @@ class AutoPlaylistUsermod : public Usermod {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lastchange = millis();
|
||||
change_timer = millis();
|
||||
|
||||
@@ -292,7 +299,10 @@ class AutoPlaylistUsermod : public Usermod {
|
||||
USER_PRINTLN("AutoPlaylist: End of silence");
|
||||
changePlaylist(musicPlaylist);
|
||||
}
|
||||
if (autoChange) change(um_data);
|
||||
if (autoChange && millis() >= autochange_timer+22) {
|
||||
change(um_data);
|
||||
autochange_timer = millis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user