Speeduino
Loading...
Searching...
No Matches
invertableOutputPin.h
Go to the documentation of this file.
1#pragma once
2
3#include "../../atomic.h"
4
11template <class TPin>
12class invertableOutputPinAdaper_t : public TPin
13{
14public:
15
17 void setInverted(bool isInverted) {
18 _isInverted = isInverted;
19 }
20
22 void setPinHigh(void) noexcept {
23 if (_isInverted) {
24 TPin::setPinLow();
25 } else {
26 TPin::setPinHigh();
27 }
28 }
29
31 void setPinLow(void) noexcept {
32 if (_isInverted) {
33 TPin::setPinHigh();
34 } else {
35 TPin::setPinLow();
36 }
37 }
38
39private:
40 bool _isInverted = false;
41};
An output pin that, optionally, can be have it's state inverted.
Definition invertableOutputPin.h:13
void setInverted(bool isInverted)
Set the inversion behavior.
Definition invertableOutputPin.h:17
void setPinHigh(void) noexcept
Set the pin high.
Definition invertableOutputPin.h:22
void setPinLow(void) noexcept
Set the pin low.
Definition invertableOutputPin.h:31