Improve night fade to completely turn off display - Change from gradual fade to complete blackout (0 brightness) during night hours - 15-minute fade out from midnight to 12:15am - Complete blackout from 12:15am to 5:45am (5.5 hours) - 15-minute fade in from 5:45am to 6:00am - Maximizes energy savings and minimizes light pollution for wall-mounted displays - Provides smooth transitions to avoid jarring on/off behavior

This commit is contained in:
Sean Sube 2025-06-17 20:34:20 -05:00
parent 54ffdc37f7
commit 2402070ef1
No known key found for this signature in database
GPG Key ID: 3EED7B957D362AF1

View File

@ -39,7 +39,7 @@ function isNightTime(): boolean {
return hour >= 0 && hour < 6; return hour >= 0 && hour < 6;
} }
// Get fade opacity based on time (0 = full fade, 1 = no fade) // Get fade opacity based on time (0 = completely off, 1 = full brightness)
function getNightFadeOpacity(): number { function getNightFadeOpacity(): number {
if (!isNightTime()) return 1; if (!isNightTime()) return 1;
@ -47,18 +47,23 @@ function getNightFadeOpacity(): number {
const minute = new Date().getMinutes(); const minute = new Date().getMinutes();
// Calculate fade based on how far into the night we are // Calculate fade based on how far into the night we are
// Start fading at midnight (0), reach max fade at 3am, then fade back until 6am // 15-minute fade out starting at midnight, 15-minute fade in starting at 5:45am
const totalMinutes = hour * 60 + minute; const totalMinutes = hour * 60 + minute;
const maxFadeAt = 3 * 60; // 3am in minutes const fadeOutEnd = 15; // 12:15am
const fadeInStart = 5 * 60 + 45; // 5:45am
const fadeInEnd = 6 * 60; // 6:00am
if (totalMinutes <= maxFadeAt) { if (totalMinutes <= fadeOutEnd) {
// Fading in: 0 to 3am // Fading out: midnight to 12:15am (15 minutes)
return Math.max(0.1, 1 - (totalMinutes / maxFadeAt) * 0.9); const fadeProgress = totalMinutes / fadeOutEnd;
return 1 - fadeProgress; // 1 to 0
} else if (totalMinutes >= fadeInStart) {
// Fading in: 5:45am to 6:00am (15 minutes)
const fadeProgress = (totalMinutes - fadeInStart) / (fadeInEnd - fadeInStart);
return fadeProgress; // 0 to 1
} else { } else {
// Fading out: 3am to 6am // Completely off: 12:15am to 5:45am
const fadeOutMinutes = totalMinutes - maxFadeAt; return 0;
const fadeOutDuration = 3 * 60; // 3 hours
return Math.max(0.1, 0.1 + (fadeOutMinutes / fadeOutDuration) * 0.9);
} }
} }