Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Functions | Variables
lampda::logic::sunset Namespace Reference

Sunset timer handler. More...

Functions

bool is_enabled ()
 Indicate if the sunset is set.
 
uint32_t get_sunset_loop_timing_ms ()
 
float get_percent_of_advance ()
 Return the percent of advance of the sunset timer, from 0 to 1. 1 is end of process.
 
float signal_sunset_update ()
 Send the timer update signal to consummers Returns the progress.
 
void sunset_process_loop ()
 
void init ()
 call once on program start
 
void set_deadline (const uint32_t timeshutdown_s)
 Set the sunset timer to a known clock deadline, replacing existing timers. Start the timer, or upate it if needed.
 
void add_time_minutes (const uint8_t time_minutes)
 add some time to the sunset timer. Limited in the range [1; 10] minutes. If the timer is not started yet, will start it.
 
void shortcut_to_phaseout ()
 If a timer is enabled, shortcut it to the start of the shutdown animation.
 
void bump_timer ()
 signal to the timer that some time may be added. Only add time if the timer is in the fadeout phase
 
void cancel_timer ()
 cancel the current active timer
 
void lock_brightness_update (bool shouldLock)
 Lock the hability of the sunset timer to control the brightness.
 

Variables

volatile uint32_t sunsetTimerEndTime_s = 0
 
bool isAllowedToControlBrightness = true
 
static constexpr uint32_t brightnessRampDownTime_min = 3
 
static constexpr uint32_t brightnessRampDownTime_s = brightnessRampDownTime_min * 60
 
static constexpr uint32_t brightnessRampDownTime_ms = brightnessRampDownTime_s * 1000
 
static constexpr uint16_t brightnessDecreasePerLoop = 1
 
static constexpr uint16_t minimalSunsetUpdateCalls = 50
 minimum calls to the update sunset function that will be made
 
static constexpr uint16_t minimalSunsetLoopDuration_ms = 5
 Minimum time between sunset loop calls.
 

Detailed Description

Sunset timer handler.

Function Documentation

◆ is_enabled()

bool lampda::logic::sunset::is_enabled ( )

Indicate if the sunset is set.

True if timer is running.

◆ set_deadline()

void lampda::logic::sunset::set_deadline ( const uint32_t  timeshutdown_s)

Set the sunset timer to a known clock deadline, replacing existing timers. Start the timer, or upate it if needed.

Parameters
[in]timeshutdown_sThe new time limit. It must be greater than the current time