supla-device
Loading...
Searching...
No Matches
roller_shutter.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_ROLLER_SHUTTER_H_
5#define SRC_SUPLA_CONTROL_ROLLER_SHUTTER_H_
6
7#include <supla/io.h>
8
9#include "roller_shutter_interface.h"
10
11namespace Supla {
12
13namespace Io {
14class Base;
15}
16
17namespace Html {
18class RollerShutterParameters;
19}
20
21namespace Control {
22
24 public:
37 int pinUp,
38 int pinDown,
39 bool highIsOn = true,
40 bool tiltFunctionsEnabled = false);
50 RollerShutter(int pinUp = -1,
51 int pinDown = -1,
52 bool highIsOn = true,
53 bool tiltFunctionsEnabled = false);
63 Supla::Io::IoPin pinDown,
64 bool tiltFunctionsEnabled = false);
65
66 void onInit() override;
67 void onTimer() override;
68
69 void setPinUp(int pin);
70 void setPinDown(int pin);
71
72 void setTargetPosition(int newPosition,
73 int newTilt = UNKNOWN_POSITION) override;
74
75 protected:
76 // GPIO outputs must be configured before the movement engine can run.
77 // Command-driven implementations provide their own readiness check.
78 virtual bool isOutputReady() const;
79
81 Supla::Io::IoPin pinDown,
82 bool tiltFunctionsEnabled,
83 Supla::Channel &externalChannel,
84 ElementMode mode);
85
86 virtual void stopMovement();
87 virtual void relayDownOn();
88 virtual void relayUpOn();
89 virtual void relayDownOff();
90 virtual void relayUpOff();
91 virtual void startClosing();
92 virtual void startOpening();
93 virtual void switchOffRelays();
94 void calculateCurrentPositionAndTilt();
95
96 void initGpio(const Supla::Io::IoPin &pin);
97
98 Supla::Io::IoPin pinUp;
99 Supla::Io::IoPin pinDown;
100
101 uint32_t lastMovementStartTime = 0;
102 uint32_t doNothingTime = 0;
103
104 uint32_t operationTimeoutMs = 0;
105 bool invalidTiltConfigurationWarningLogged = false;
106 bool invalidTiltConfigurationFallbackActive = false;
107 bool invalidTiltOnlyRuntimeWarningLogged = false;
108};
109
110} // namespace Control
111} // namespace Supla
112
113#endif // SRC_SUPLA_CONTROL_ROLLER_SHUTTER_H_
Definition channel.h:26
Definition roller_shutter_interface.h:58
Definition roller_shutter.h:23
void onTimer() override
Method called on timer interupt.
Definition roller_shutter.cpp:162
void onInit() override
Third method called on element in SuplaDevice.begin()
Definition roller_shutter.cpp:73
RollerShutter(Supla::Io::Base *io, int pinUp, int pinDown, bool highIsOn=true, bool tiltFunctionsEnabled=false)
Constructor.
Definition roller_shutter.cpp:28
Definition roller_shutter_parameters.h:20
Definition io.h:23
Definition io_pin.h:14