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:
parent
54ffdc37f7
commit
2402070ef1
@ -39,7 +39,7 @@ function isNightTime(): boolean {
|
||||
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 {
|
||||
if (!isNightTime()) return 1;
|
||||
|
||||
@ -47,18 +47,23 @@ function getNightFadeOpacity(): number {
|
||||
const minute = new Date().getMinutes();
|
||||
|
||||
// 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 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) {
|
||||
// Fading in: 0 to 3am
|
||||
return Math.max(0.1, 1 - (totalMinutes / maxFadeAt) * 0.9);
|
||||
if (totalMinutes <= fadeOutEnd) {
|
||||
// Fading out: midnight to 12:15am (15 minutes)
|
||||
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 {
|
||||
// Fading out: 3am to 6am
|
||||
const fadeOutMinutes = totalMinutes - maxFadeAt;
|
||||
const fadeOutDuration = 3 * 60; // 3 hours
|
||||
return Math.max(0.1, 0.1 + (fadeOutMinutes / fadeOutDuration) * 0.9);
|
||||
// Completely off: 12:15am to 5:45am
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user