Skip to main content

compute_auto_frontlight_levels

Function compute_auto_frontlight_levels 

Source
pub fn compute_auto_frontlight_levels(
    now: DateTime<Local>,
    coordinates: Coordinates,
    night_brightness: LightLevel,
    current_intensity: LightLevel,
) -> LightLevels
Expand description

Computes the frontlight levels that should be active at the given time.

Brightness switches between current_intensity during daylight hours and night_brightness while the sun is down. Warmth ramps over a fixed transition window before sunrise and before sunset, reaching fully cool at sunrise and fully warm at sunset.

When sunrise or sunset cannot be determined (polar regions), the function falls back to constant levels: polar night (no sunrise) returns night_brightness with full warmth, polar day (no sunset) returns current_intensity with zero warmth.