supla-device
Toggle main menu visibility
Loading...
Searching...
No Matches
src
supla
control
lighting_pwm_leds.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_CONTROL_LIGHTING_PWM_LEDS_H_
20
#define SRC_SUPLA_CONTROL_LIGHTING_PWM_LEDS_H_
21
22
#include <stdint.h>
23
#include <supla/io.h>
24
25
#include "lighting_pwm_base.h"
26
27
namespace
Supla {
28
namespace
Control {
29
30
class
LightingPwmLeds :
public
LightingPwmBase
{
31
public
:
32
static
constexpr
int
kMaxOutputs = 5;
33
34
LightingPwmLeds(LightingPwmLeds *parent,
35
int
out1,
36
int
out2,
37
int
out3,
38
int
out4,
39
int
out5);
40
LightingPwmLeds(LightingPwmLeds *parent,
41
Supla::Io::IoPin
out1,
42
Supla::Io::IoPin
out2 = {},
43
Supla::Io::IoPin
out3 = {},
44
Supla::Io::IoPin
out4 = {},
45
Supla::Io::IoPin
out5 = {});
46
47
void
setRGBCCTValueOnDevice(uint32_t output[5],
int
usedOutputs)
override
;
48
void
onInit
()
override
;
49
void
onLoadConfig
(
SuplaDeviceClass
*sdc)
override
;
50
51
protected
:
52
struct
OutputState
{
53
Supla::Io::IoPin
pin;
54
int32_t lastSourceValue = -1;
55
int32_t lastDutyValue = -1;
56
};
57
58
void
applyPwmResolutionBitsToOutputs();
59
void
applyPwmFrequencyToOutputs();
60
void
applyDefaultChannelFunctions();
61
int
getConfiguredOutputsCount()
const
;
62
uint8_t getPwmResolutionBitsForOutput(
const
OutputState
&output)
const
;
63
uint32_t getPwmMaxValueForOutput(
const
OutputState
&output)
const
;
64
bool
isOutputSharedWithParent(
const
OutputState
&output)
const
;
65
66
OutputState
outputs[kMaxOutputs];
67
int
lastUsedOutputs = 0;
68
int
tryCounter = 0;
69
LightingPwmLeds *parentPwm =
nullptr
;
70
};
71
72
using
RGBWPwmBase =
LightingPwmLeds
;
73
74
}
// namespace Control
75
}
// namespace Supla
76
77
#endif
// SRC_SUPLA_CONTROL_LIGHTING_PWM_LEDS_H_
SuplaDeviceClass
Definition
SuplaDevice.h:163
Supla::Control::LightingPwmBase::LightingPwmBase
LightingPwmBase(LightingPwmBase *parent=nullptr)
Constructor.
Definition
lighting_pwm_base.cpp:103
Supla::Control::LightingPwmLeds
Definition
lighting_pwm_leds.h:30
Supla::Control::LightingPwmLeds::onLoadConfig
void onLoadConfig(SuplaDeviceClass *sdc) override
First method called on element in SuplaDevice.begin().
Definition
lighting_pwm_leds.cpp:217
Supla::Control::LightingPwmLeds::onInit
void onInit() override
Third method called on element in SuplaDevice.begin().
Definition
lighting_pwm_leds.cpp:223
Supla::Control::LightingPwmLeds::OutputState
Definition
lighting_pwm_leds.h:52
Supla::Io::IoPin
Definition
io_pin.h:28
Generated by
1.17.0