supla-device
Loading...
Searching...
No Matches
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 "lighting_pwm_base.h"
23
24#include <stdint.h>
25#include <supla/io.h>
26
27namespace Supla {
28namespace Control {
29
30class 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,
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 void setOutputIo(int outputIndex, Supla::Io::Base *io);
52 Supla::Io::Base *getOutputIo(int outputIndex) const;
53 int getOutputPin(int outputIndex) const;
54
55 protected:
56 void applyPwmFrequencyToOutputs();
57 void applyDefaultChannelFunctions();
58 int getConfiguredOutputsCount() const;
59
60 struct OutputState {
62 int32_t lastSourceValue = -1;
63 int32_t lastDutyValue = -1;
64 };
65
66 OutputState outputs[kMaxOutputs];
67 int tryCounter = 0;
68 LightingPwmLeds *parentPwm = nullptr;
69};
70
71using RGBWPwmBase = LightingPwmLeds;
72
73} // namespace Control
74} // namespace Supla
75
76#endif // SRC_SUPLA_CONTROL_LIGHTING_PWM_LEDS_H_
Definition SuplaDevice.h:162
LightingPwmBase(LightingPwmBase *parent=nullptr)
Constructor.
Definition lighting_pwm_base.cpp:101
Definition lighting_pwm_leds.h:30
void onLoadConfig(SuplaDeviceClass *sdc) override
First method called on element in SuplaDevice.begin().
Definition lighting_pwm_leds.cpp:176
void onInit() override
Third method called on element in SuplaDevice.begin().
Definition lighting_pwm_leds.cpp:181
Definition io.h:35
Definition lighting_pwm_leds.h:60
Definition io.h:67