Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
lampda::logic::SunriseTimer Class Reference

Timer to start the system and ramp up brightness until we reach back the latest user set brightness. More...

#include <sun_timers.h>

Inheritance diagram for lampda::logic::SunriseTimer:
lampda::logic::SunTimerBase< 3 >

Public Member Functions

void cancel_at_current_brightness ()
 Cancel the timer, and keep the brightness reached by the sunrise as the new saved brightness.
 
bool is_enabled () const
 
uint32_t get_remaining_time_s () const
 Return the time left before the end of the timer, in seconds. 0 if the timer is not enabled.
 
bool cancel ()
 Cancel the current active timer.
 
void set_deadline (const uint32_t timeshutdown_s)
 Start the sun timer with a deadline, or prolonge the current sun timer.
 
void add_time_minutes (const uint8_t time_minutes)
 Add some time to the current timer, or start it with a target time in minutes. This time cannot be shorter than BrightnessSunTime_min.
 
void lock_brightness_update (bool shouldLock)
 Lock the hability of the sunset timer to control the brightness.
 
void shortcut_to_brightness_phase ()
 Shortcut the whole timer to the brightness control phase.
 
void sun_process_loop ()
 sun process task INTERNAL USE ONLY
 

Static Public Attributes

static constexpr uint32_t BrightnessSunTime_min
 
static constexpr uint32_t BrightnessSunTime_s
 
static constexpr uint32_t BrightnessSunTime_ms
 
static constexpr uint16_t brightnessDecreasePerLoop
 
static constexpr uint16_t brightnessIncreasePerLoop
 Brightness increase per loop call during the brightness phase.
 
static constexpr uint16_t minimalSunUpdateCalls
 minimum calls to the update sunset function that will be made
 
static constexpr uint16_t minimalSunLoopDuration_ms
 Minimum time between sunset loop calls.
 

Protected Member Functions

bool should_accept_start () const override
 
void sun_timer_progress_update_callback (const float progress) const override
 Wrapper to the custom user code to call for a sun timer update.
 
void end_of_timer_handle () override
 Called when the timer reaches its target. The brightness scale is left as is by the release: the handle must set it.
 
void timer_brightness_progress_update (const float progress) override
 Called when the timer progresses through the brightness phase.
 
bool release ()
 Release the timer, without restoring the brightness scale.
 
uint32_t get_loop_timing_ms () const
 Compute the timing delay of the loop to stay at the target brightness control frequency.
 
float get_percent_of_advance () const
 Return the sun timer progress between 0 to 1.
 
float signal_sun_update () const
 Signal a sun timer update to consummers.
 

Protected Attributes

volatile uint32_t endTime_s
 End of the timer operation, in the lamp time counter. 0 when the timer is not running. Atomic: the timer task and the main loop (inputs, CLI) can both release it.
 
bool isAllowedToControlBrightness
 Is the handler allowed to control lamp brightness.
 

Detailed Description

Timer to start the system and ramp up brightness until we reach back the latest user set brightness.

Member Function Documentation

◆ cancel()

bool lampda::logic::SunTimerBase< T >::cancel
inherited

Cancel the current active timer.

Returns
true if the timer was running. Only one caller can release a running timer, so a timer canceled from another thread never runs its end of timer handle

◆ end_of_timer_handle()

void lampda::logic::SunriseTimer::end_of_timer_handle ( )
overrideprotectedvirtual

Called when the timer reaches its target. The brightness scale is left as is by the release: the handle must set it.

Implements lampda::logic::SunTimerBase< 3 >.

◆ release()

bool lampda::logic::SunTimerBase< T >::release
protectedinherited

Release the timer, without restoring the brightness scale.

Returns
true if the timer was running. See cancel

◆ should_accept_start()

bool lampda::logic::SunriseTimer::should_accept_start ( ) const
overrideprotectedvirtual

SUNRISE

Implements lampda::logic::SunTimerBase< 3 >.

◆ signal_sun_update()

float lampda::logic::SunTimerBase< T >::signal_sun_update
protectedinherited

Signal a sun timer update to consummers.

Returns
the progress between 0 and 1

◆ sun_timer_progress_update_callback()

void lampda::logic::SunriseTimer::sun_timer_progress_update_callback ( const float  progress) const
overrideprotectedvirtual

Wrapper to the custom user code to call for a sun timer update.

Parameters
[in]progressbetween 0 and 1

Implements lampda::logic::SunTimerBase< 3 >.

◆ timer_brightness_progress_update()

void lampda::logic::SunriseTimer::timer_brightness_progress_update ( const float  progress)
overrideprotectedvirtual

Called when the timer progresses through the brightness phase.

Implements lampda::logic::SunTimerBase< 3 >.


The documentation for this class was generated from the following files: