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

private handling namespace, used for unit testing More...

Classes

struct  ButtonEvent
 
struct  ButtonEventQueueLock
 Hold _buttonEventQueueMutex for the scope. More...
 

Functions

bool pop_button_event (ButtonEvent &event)
 Pop the oldest button event. Thread safe. Return false if there is no event.
 
size_t get_button_event_count ()
 Return the number of stored button events. Thread safe.
 
void clear_button_events ()
 Drop all stored button events. Thread safe.
 
bool push_button_event (const ButtonEvent &event, const size_t maxFillPercent)
 Push a button event, if the queue fill stays below maxFillPercent. Thread safe.
 
void handle_brightness_change (uint8_t consecutiveButtonCheck, uint32_t buttonHoldDuration, bool isEndOfHoldEvent)
 Handle a brightness change control: 1 long clic raises brightness to maximum, then goes down if press continue, then shuts down the system. 2 long clics lower brightness to minimum, then if press continue shuts down the system.
 

Variables

static etl::queue< ButtonEvent, maxButtonEventStore > buttonEventQueue
 Button event asynchroneous queue: filled by the button thread, emptied by the main loop. etl::queue is not thread safe: only access it under _buttonEventQueueMutex.
 
static hal::mutex::hal_mutex_t _buttonEventQueueMutex
 Guards buttonEventQueue. Never held while running the button callbacks. Not recursive.
 
static const bool _isButtonEventQueueMutexInit
 Initialized at program start: events can be pushed as soon as the button thread starts.
 
static constexpr size_t maxButtonEventStore
 this event count should be high enough to not miss clicks and ramp events
 

Detailed Description

private handling namespace, used for unit testing

Function Documentation

◆ handle_brightness_change()

void lampda::logic::inputs::__private::handle_brightness_change ( uint8_t  consecutiveButtonCheck,
uint32_t  buttonHoldDuration,
bool  isEndOfHoldEvent 
)

Handle a brightness change control: 1 long clic raises brightness to maximum, then goes down if press continue, then shuts down the system. 2 long clics lower brightness to minimum, then if press continue shuts down the system.

< keep track of the ramp side : up of down

< keep track of the latest brightness saturation press duration

user controled brightness, no more sunrise

go up

Variable Documentation

◆ _isButtonEventQueueMutexInit

const bool lampda::logic::inputs::__private::_isButtonEventQueueMutexInit
static
Initial value:
=
(hal::mutex::hal_mutex_init(&_buttonEventQueueMutex), true)

Initialized at program start: events can be pushed as soon as the button thread starts.

◆ maxButtonEventStore

constexpr size_t lampda::logic::inputs::__private::maxButtonEventStore
staticconstexpr
Initial value:
=
15

this event count should be high enough to not miss clicks and ramp events