mirror of
https://github.com/wled/WLED.git
synced 2025-04-23 22:37:18 +00:00
Update usermod internal temperature
Enabled the storing the currently active preset or playlist for it to be restored later
This commit is contained in:
parent
3815516022
commit
78e7312adf
@ -11,6 +11,8 @@ private:
|
||||
unsigned long lastTime = 0;
|
||||
bool isEnabled = false;
|
||||
float temperature = 0.0f;
|
||||
uint8_t previousPlaylist = 0; // Stores the playlist that was active before high-temperature activation
|
||||
uint8_t previousPreset = 0; // Stores the preset that was active before high-temperature activation
|
||||
uint8_t presetToActivate = 0; // Preset to activate when temp goes above threshold (0 = disabled)
|
||||
float activationThreshold = 95.0f; // Temperature threshold to trigger high-temperature actions
|
||||
float resetMargin = 2.0f; // Margin below the activation threshold (Prevents frequent toggling when close to threshold)
|
||||
@ -49,15 +51,26 @@ public:
|
||||
temperature = roundf(temperatureRead() * 10) / 10;
|
||||
#endif
|
||||
|
||||
// Check if temperature has gone above the threshold
|
||||
// Check if temperature has exceeded the activation threshold
|
||||
if (temperature >= activationThreshold) {
|
||||
// Update the state flag if not already set
|
||||
if (!isAboveThreshold){
|
||||
if (!isAboveThreshold) {
|
||||
isAboveThreshold = true;
|
||||
}
|
||||
// Activate the 'over-threshold' preset if it's not already active
|
||||
// Check if a 'high temperature' preset is configured and it's not already active
|
||||
if (presetToActivate != 0 && currentPreset != presetToActivate) {
|
||||
saveTemporaryPreset(); // Save current state to a temporary preset to allow re-activation later
|
||||
// If a playlist is active, store it for reactivation later
|
||||
if (currentPlaylist > 0) {
|
||||
previousPlaylist = currentPlaylist;
|
||||
}
|
||||
// If a preset is active, store it for reactivation later
|
||||
else if (currentPreset > 0) {
|
||||
previousPreset = currentPreset;
|
||||
// If no playlist or preset is active, save current state for reactivation later
|
||||
} else {
|
||||
saveTemporaryPreset();
|
||||
}
|
||||
// Activate the 'high temperature' preset
|
||||
applyPreset(presetToActivate);
|
||||
}
|
||||
}
|
||||
@ -67,9 +80,25 @@ public:
|
||||
if (isAboveThreshold){
|
||||
isAboveThreshold = false;
|
||||
}
|
||||
// Revert back to the original preset
|
||||
if (currentPreset == presetToActivate){
|
||||
applyTemporaryPreset(); // Restore the previous state which was stored to the temporary preset
|
||||
// Check if the 'high temperature' preset is active
|
||||
if (currentPreset == presetToActivate) {
|
||||
// Check if a previous playlist was stored
|
||||
if (previousPlaylist > 0) {
|
||||
// Reactivate the stored playlist
|
||||
applyPreset(previousPlaylist);
|
||||
// Clear the stored playlist
|
||||
previousPlaylist = 0;
|
||||
}
|
||||
// Check if a previous preset was stored
|
||||
else if (previousPreset > 0) {
|
||||
// Reactivate the stored preset
|
||||
applyPreset(previousPreset);
|
||||
// Clear the stored preset
|
||||
previousPreset = 0;
|
||||
// If no previous playlist or preset was stored, revert to the stored state
|
||||
} else {
|
||||
applyTemporaryPreset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user