Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
cs_TwilightHandler.h
Go to the documentation of this file.
1/*
2 * Author: Crownstone Team
3 * Copyright: Crownstone (https://crownstone.rocks)
4 * Date: Dec 5, 2019
5 * License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)
6 */
7#pragma once
8
10#include <common/cs_Component.h>
13#include <time/cs_Time.h>
14
15#include <optional>
16
17class TwilightHandler : public EventListener, public Component {
18public:
25 cs_ret_code_t init() override;
26
36 void handleEvent(event_t& evt) override;
37
47 bool update();
48
52 std::optional<uint8_t> getValue();
53
54private:
63 std::optional<uint8_t> computeIntendedState(Time currentTime);
64
65 std::optional<uint8_t> _currentIntendedState = 100;
66
70 bool _isActive = true;
71
76};
Keeps track of the behaviours that are active on this crownstone.
Definition: cs_BehaviourStore.h:25
Helper class to manage decoupling of components.
Definition: cs_Component.h:35
Event listener.
Definition: cs_EventListener.h:17
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Sep 24,...
Definition: cs_Time.h:14
Definition: cs_TwilightHandler.h:17
BehaviourStore * _behaviourStore
cached reference to the behaviour store.
Definition: cs_TwilightHandler.h:75
std::optional< uint8_t > computeIntendedState(Time currentTime)
Given current time, query the behaviourstore and check if there any valid ones.
std::optional< uint8_t > _currentIntendedState
Definition: cs_TwilightHandler.h:65
bool _isActive
Is this handler active?
Definition: cs_TwilightHandler.h:70
cs_ret_code_t init() override
Initialize this class:
void handleEvent(event_t &evt) override
Computes the twilight state of this crownstone based on the stored behaviours, and then dispatches an...
bool update()
Acquires the current time and presence information.
std::optional< uint8_t > getValue()
Returns currentIntendedState.
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Oct 9,...
Definition: cs_Event.h:26
uint16_t cs_ret_code_t
Definition: cs_Typedefs.h:21