supla-device
Loading...
Searching...
No Matches
lighting_pwm_leds.h
1// SPDX-FileCopyrightText: AC SOFTWARE SP. Z O.O.
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#ifndef SRC_SUPLA_CONTROL_LIGHTING_PWM_LEDS_H_
5#define SRC_SUPLA_CONTROL_LIGHTING_PWM_LEDS_H_
6
7#include <stdint.h>
8#include <supla/io.h>
9
10#include "lighting_pwm_base.h"
11
12namespace Supla {
13namespace Control {
14
16 public:
17 static constexpr int kMaxOutputs = 5;
18
20 int out1,
21 int out2,
22 int out3,
23 int out4,
24 int out5);
27 Supla::Io::IoPin out2 = {},
28 Supla::Io::IoPin out3 = {},
29 Supla::Io::IoPin out4 = {},
30 Supla::Io::IoPin out5 = {});
31
32 void setRGBCCTValueOnDevice(uint32_t output[5], int usedOutputs) override;
33 void onInit() override;
34 void onLoadConfig(SuplaDeviceClass *sdc) override;
35
36 protected:
37 struct OutputState {
39 int32_t lastSourceValue = -1;
40 int32_t lastDutyValue = -1;
41 };
42
43 void applyPwmResolutionBitsToOutputs();
44 void applyPwmFrequencyToOutputs();
45 void applyDefaultChannelFunctions();
46 int getConfiguredOutputsCount() const;
47 uint8_t getPwmResolutionBitsForOutput(const OutputState &output) const;
48 uint32_t getPwmMaxValueForOutput(const OutputState &output) const;
49 bool isOutputSharedWithParent(const OutputState &output) const;
50
51 OutputState outputs[kMaxOutputs];
52 int lastUsedOutputs = 0;
53 int tryCounter = 0;
54 LightingPwmLeds *parentPwm = nullptr;
55};
56
58
59} // namespace Control
60} // namespace Supla
61
62#endif // SRC_SUPLA_CONTROL_LIGHTING_PWM_LEDS_H_
Definition SuplaDevice.h:167
Definition lighting_pwm_base.h:48
Definition lighting_pwm_leds.h:15
void onLoadConfig(SuplaDeviceClass *sdc) override
First method called on element in SuplaDevice.begin().
Definition lighting_pwm_leds.cpp:202
void onInit() override
Third method called on element in SuplaDevice.begin()
Definition lighting_pwm_leds.cpp:208
Definition lighting_pwm_leds.h:37
Definition io_pin.h:14