supla-device
Toggle main menu visibility
Loading...
Searching...
No Matches
src
supla
device
status_led.h
1
/*
2
Copyright (C) AC SOFTWARE SP. Z O.O.
3
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License
6
as published by the Free Software Foundation; either version 2
7
of the License, or (at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
*/
18
19
#ifndef SRC_SUPLA_DEVICE_STATUS_LED_H_
20
#define SRC_SUPLA_DEVICE_STATUS_LED_H_
21
22
#include <supla/control/blinking_led.h>
23
24
namespace
Supla {
25
26
namespace
Io {
27
class
Base
;
28
}
// namespace Io
29
30
enum
LedMode : uint8_t {
31
LED_ON_WHEN_CONNECTED
/* default */
,
32
LED_OFF_WHEN_CONNECTED,
33
LED_ALWAYS_OFF,
34
LED_IN_CONFIG_MODE_ONLY
35
};
36
37
// States SERVER_CONNECTING, REGISTERED_AND_READY, PACZKOW_WE_HAVE_A_PROBLEM
38
// may be different in multiprotocol scenario. We consider error as highest
39
// priority LED status, then SERVER_CONNECTING, and lowest priority has
40
// REGISTERED_AND_READY state. So for all states where Supla protocol has
41
// SERVER_CONNECTING and REGISTERED_AND_READY we check also other protocol
42
// layers state if they doesn't have any higher priority state.
43
enum
LedSequence : uint8_t {
44
NETWORK_CONNECTING
/* initial state 2000/2000 ms */
,
45
SERVER_CONNECTING
/* flashing 500/500 ms */
,
46
REGISTERED_AND_READY
/* stable ON or OFF depending on config */
,
47
CONFIG_MODE
/* quick flashing 100/100 ms */
,
48
SW_DOWNLOAD
/* very fast flashing 20/20 ms */
,
49
PACZKOW_WE_HAVE_A_PROBLEM
/* some problem 300/100 ms */
,
50
TESTING_PROCEDURE,
/* used to indicate almost finished test 50/50 ms */
51
CUSTOM_SEQUENCE,
/* values set manually, state changes ignored */
52
NOT_CONFIGURED_MODE,
/* double blink, pause */
53
};
54
55
namespace
Device {
56
57
58
class
StatusLed :
public
Supla::Control::BlinkingLed
{
59
public
:
60
explicit
StatusLed(
Supla::Io::Base
*io, uint8_t outPin,
bool
invert =
false
);
61
explicit
StatusLed(uint8_t outPin,
bool
invert =
false
);
62
63
void
onLoadConfig
(
SuplaDeviceClass
*)
override
;
64
void
iterateAlways
()
override
;
65
void
onDeviceConfigChange
(uint64_t fieldBit)
override
;
66
67
// Enables custom LED sequence based on given durations.
68
// Automatic sequence change will be disabled.
69
void
setCustomSequence(uint32_t onDurationMs,
70
uint32_t offDurationMs,
71
uint32_t pauseDurrationMs = 0,
72
uint8_t onLimit = 0,
73
uint8_t repeatLimit = 0,
74
bool
startWithOff =
true
)
override
;
75
76
enum
LedSequence getCurrentSequence()
const
;
77
78
// Restores automatic LED sequence change based on device state.
79
// It is enabled by default, so if it wasn't disabled by calling
80
// setCustomSequence, then there is no need to call it.
81
void
setAutoSequence();
82
83
// Sets status LED mode
84
void
setMode(LedMode newMode);
85
LedMode getMode()
const
;
86
void
storeModeToConfig();
87
void
setDefaultMode(
enum
LedMode newMode);
88
void
setUseDeviceConfig(
bool
value);
89
void
identify();
90
91
protected
:
92
LedSequence currentSequence = NETWORK_CONNECTING;
93
LedMode ledMode = LED_ON_WHEN_CONNECTED;
94
int8_t defaultMode = 0;
95
bool
useDeviceConfig =
true
;
96
};
97
98
}
// namespace Device
99
}
// namespace Supla
100
101
#endif
// SRC_SUPLA_DEVICE_STATUS_LED_H_
SuplaDeviceClass
Definition
SuplaDevice.h:163
Supla::Control::BlinkingLed
Definition
blinking_led.h:31
Supla::Device::StatusLed::onLoadConfig
void onLoadConfig(SuplaDeviceClass *) override
First method called on element in SuplaDevice.begin().
Definition
status_led.cpp:44
Supla::Device::StatusLed::onDeviceConfigChange
void onDeviceConfigChange(uint64_t fieldBit) override
Method called when device config is changed.
Definition
status_led.cpp:352
Supla::Device::StatusLed::iterateAlways
void iterateAlways() override
Method called on each SuplaDevice iteration.
Definition
status_led.cpp:112
Supla::Io::Base
Definition
io.h:36
Generated by
1.17.0