Class that:
More...
#include <cs_SmartSwitch.h>
Class that:
- From intended intensity 0-100, decides whether to use the dimmer or relay.
- Checks if dimming is allowed, and if switching is allowed.
- Stores state in State class.
- [future] Slowly (seconds) fades to intended state.
◆ callback_on_intensity_change_t
Callback function definition.
◆ allowSwitching()
bool SmartSwitch::allowSwitching |
( |
| ) |
|
|
private |
Whether switch state is allowed to be changed.
◆ getActualState()
◆ getCurrentIntensity()
uint8_t SmartSwitch::getCurrentIntensity |
( |
| ) |
|
Get current switch intensity.
- Returns
- The current switch intensity: 0-100.
◆ getIntendedState()
uint8_t SmartSwitch::getIntendedState |
( |
| ) |
|
Get the intended switch state.
- Returns
- Intended switch intensity: 0-100.
◆ getIntensityFromSwitchState()
uint8_t SmartSwitch::getIntensityFromSwitchState |
( |
switch_state_t |
switchState | ) |
|
|
private |
Get intensity from a switch state.
◆ handleAllowDimmingSet()
void SmartSwitch::handleAllowDimmingSet |
( |
| ) |
|
|
private |
◆ handleCommandSetDimmer()
cs_ret_code_t SmartSwitch::handleCommandSetDimmer |
( |
uint8_t |
intensity | ) |
|
|
private |
◆ handleCommandSetRelay()
◆ handleEvent()
void SmartSwitch::handleEvent |
( |
event_t & |
evt | ) |
|
|
overridevirtual |
◆ handleUnexpectedStateChange()
void SmartSwitch::handleUnexpectedStateChange |
( |
switch_state_t |
newState | ) |
|
|
private |
Handle unexpected state change by safeSwitch.
◆ init()
◆ onUnexpextedIntensityChange()
Register a callback function that's called when state changes unexpectedly.
◆ resolveIntendedState()
From set intended state, try to set the relay and/or dimmer to correct values.
Does not set intended state.
◆ sendUnexpectedIntensityUpdate()
void SmartSwitch::sendUnexpectedIntensityUpdate |
( |
uint8_t |
newIntensity | ) |
|
|
private |
Send intensity update to listeners.
Only to be called when state changes due to events, not due to calls to set(). This prevents the user to get updates before the call is even finished, this is what return codes are for.
◆ set()
Set intended intensity.
Intended state is only changed by this function.
- Parameters
-
[in] | Intensity | value: 0-100 |
- Returns
- Return code. When it's not success, the current intensity might have changed to something else. ERR_NOT_POWERED when trying to dim while the dimmer is not powered.
◆ setAllowDimming()
Set allow dimming.
Also updates State.
◆ setDimmer()
cs_ret_code_t SmartSwitch::setDimmer |
( |
uint8_t |
intensity, |
|
|
bool |
fade = true |
|
) |
| |
|
private |
Set dimmer.
Checks if dimming and switching is allowed.
◆ setDimmerUnchecked()
cs_ret_code_t SmartSwitch::setDimmerUnchecked |
( |
uint8_t |
intensity, |
|
|
bool |
fade |
|
) |
| |
|
private |
Set dimmer without checks.
Also updates State.
◆ setRelay()
Set relay.
Checks if switching is allowed.
◆ setRelayUnchecked()
Set relay without checks.
Also updates State.
◆ setSwitchLock()
Set switch lock.
Also updates State.
◆ start()
void SmartSwitch::start |
( |
| ) |
|
Start switch.
To be called once there is enough power to switch relay, and enable dimmer.
◆ store()
Store switch state to State class.
Also updates storedState.
◆ TYPIFY() [1/3]
Cached value of what's stored in State.
◆ TYPIFY() [2/3]
Cached value of what's stored in State.
◆ TYPIFY() [3/3]
Cached value of what's stored in State.
◆ _allowSwitchingOverride
bool SmartSwitch::_allowSwitchingOverride = false |
|
private |
Override of switch lock, necessary to restore state at startup.
◆ _callbackOnIntensityChange
Callback to be called when switch state changes unexpectedly, so anything but set().
◆ _intendedState
uint8_t SmartSwitch::_intendedState |
|
private |
Intended switch state by the user, as percentage.
◆ _safeSwitch
The documentation for this class was generated from the following file: