18 static constexpr uint32_t BrightnessSunTime_min = BrightnessSunTime;
19 static constexpr uint32_t BrightnessSunTime_s = BrightnessSunTime_min * 60;
20 static constexpr uint32_t BrightnessSunTime_ms = BrightnessSunTime_s * 1000;
21 static constexpr uint16_t brightnessDecreasePerLoop = 1;
32 bool is_enabled()
const {
return endTime_s > 0; }
101 uint32_t trueBrightnessSunTime_ms = BrightnessSunTime_ms;
148inline void sun_timers_cancel_all()
154inline void sun_timers_brightness_lock_all(
const bool shouldLock)
Sun timer operations handler All sun operations are exclusive, thay cannot run at the same time.
Definition: sun_timers.h:16
bool cancel()
Cancel the current active timer.
Definition: sun_timers.cpp:20
virtual bool should_accept_start() const =0
Overloadable: A timer can refuse to start under some conditions.
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.
Definition: sun_timers.cpp:135
virtual void sun_timer_progress_update_callback(const float progress) const =0
Wrapper to the custom user code to call for a sun timer update.
uint32_t get_loop_timing_ms() const
Compute the timing delay of the loop to stay at the target brightness control frequency.
Definition: sun_timers.cpp:123
float signal_sun_update() const
Signal a sun timer update to consummers.
Definition: sun_timers.cpp:158
void set_deadline(const uint32_t timeshutdown_s)
Start the sun timer with a deadline, or prolonge the current sun timer.
Definition: sun_timers.cpp:51
volatile uint32_t endTime_s
End of the timer operation, in the lamp time counter. 0 when the timer is not running....
Definition: sun_timers.h:95
void sun_process_loop()
sun process task INTERNAL USE ONLY
Definition: sun_timers.cpp:185
static constexpr uint16_t minimalSunUpdateCalls
minimum calls to the update sunset function that will be made
Definition: sun_timers.h:26
static constexpr uint16_t minimalSunLoopDuration_ms
Minimum time between sunset loop calls.
Definition: sun_timers.h:28
virtual void end_of_timer_handle()=0
Called when the timer reaches its target. The brightness scale is left as is by the release: the hand...
bool isAllowedToControlBrightness
Is the handler allowed to control lamp brightness.
Definition: sun_timers.h:97
void shortcut_to_brightness_phase()
Shortcut the whole timer to the brightness control phase.
Definition: sun_timers.cpp:171
void lock_brightness_update(bool shouldLock)
Lock the hability of the sunset timer to control the brightness.
Definition: sun_timers.h:52
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 sh...
Definition: sun_timers.cpp:101
float get_percent_of_advance() const
Return the sun timer progress between 0 to 1.
Definition: sun_timers.cpp:143
static constexpr uint16_t brightnessIncreasePerLoop
Brightness increase per loop call during the brightness phase.
Definition: sun_timers.h:24
bool release()
Release the timer, without restoring the brightness scale.
Definition: sun_timers.cpp:29
virtual void timer_brightness_progress_update(const float progress)=0
Called when the timer progresses through the brightness phase.
Timer to start the system and ramp up brightness until we reach back the latest user set brightness.
Definition: sun_timers.h:126
void end_of_timer_handle() override
Called when the timer reaches its target. The brightness scale is left as is by the release: the hand...
Definition: sun_timers.cpp:334
void cancel_at_current_brightness()
Cancel the timer, and keep the brightness reached by the sunrise as the new saved brightness.
Definition: sun_timers.cpp:316
void timer_brightness_progress_update(const float progress) override
Called when the timer progresses through the brightness phase.
Definition: sun_timers.cpp:344
bool should_accept_start() const override
Definition: sun_timers.cpp:308
void sun_timer_progress_update_callback(const float progress) const override
Wrapper to the custom user code to call for a sun timer update.
Definition: sun_timers.cpp:329
Timer to slowly ramp down the brightness until zero then shutdown.
Definition: sun_timers.h:106
void timer_brightness_progress_update(const float progress) override
Called when the timer progresses through the brightness phase.
Definition: sun_timers.cpp:291
bool should_accept_start() const override
Definition: sun_timers.cpp:246
void end_of_timer_handle() override
Called when the timer reaches its target. The brightness scale is left as is by the release: the hand...
Definition: sun_timers.cpp:282
void bump_timer()
signal to the timer that some time may be added. Only add time if the timer is in the fadeout phase
Definition: sun_timers.cpp:254
void sun_timer_progress_update_callback(const float progress) const override
Wrapper to the custom user code to call for a sun timer update.
Definition: sun_timers.cpp:277
void sun_timers_init_all()
init all timers: call once on program start
Definition: sun_timers.cpp:391
SunsetTimer sunset_timer
object to access to control the timers
Definition: sun_timers.cpp:237
Program scope.
Definition: control_fixed_modes.hpp:14