#include <cs_TwilightHandler.h>
◆ computeIntendedState()
std::optional< uint8_t > TwilightHandler::computeIntendedState |
( |
Time |
currentTime | ) |
|
|
private |
Given current time, query the behaviourstore and check if there any valid ones.
Returns an empty optional if time is invalid, or this isActive==false. Else returns a non-empty optional containing the conflict resolved value of all active twilights, defaulting to 100 if none are active.
◆ getValue()
std::optional< uint8_t > TwilightHandler::getValue |
( |
| ) |
|
Returns currentIntendedState.
◆ handleEvent()
void TwilightHandler::handleEvent |
( |
event_t & |
evt | ) |
|
|
overridevirtual |
Computes the twilight state of this crownstone based on the stored behaviours, and then dispatches an event.
Events:
- EVT_PRESENCE_MUTATION
- EVT_BEHAVIOURSTORE_MUTATION
- STATE_BEHAVIOUR_SETTINGS
Implements EventListener.
◆ init()
Initialize this class:
- Read settings from flash.
- Start listening for events.
- obtain reference to behaviourstore
Reimplemented from Component.
◆ update()
bool TwilightHandler::update |
( |
| ) |
|
Acquires the current time and presence information.
Checks the intended state by looping over the active behaviours and if the intendedState differs from previousIntendedState dispatch an event to communicate a state update.
if time is not valid, aborts method execution and returns false. returns true when value was updated, false else.
◆ _behaviourStore
cached reference to the behaviour store.
(obtained at init)
◆ _currentIntendedState
std::optional<uint8_t> TwilightHandler::_currentIntendedState = 100 |
|
private |
◆ _isActive
bool TwilightHandler::_isActive = true |
|
private |
The documentation for this class was generated from the following file: