Plaquette
Loading...
Searching...
No Matches
PqOutputs.h
1/*
2 * PqOutputs.h
3 *
4 * (c) 2015 Sofian Audry :: info(@)sofianaudry(.)com
5 * (c) 2015 Thomas O Fredericks :: tof(@)t-o-f(.)info
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef PQ_OUTPUTS_H_
22#define PQ_OUTPUTS_H_
23
24#include "PqCore.h"
25
26namespace pq {
27
29class AnalogOut : public AnalogSource, public PinConfig {
30public:
36
42 AnalogOut(uint8_t pin, uint8_t mode, Engine& engine = Engine::primary());
43
44 virtual ~AnalogOut() {}
45
47 virtual float put(float value);
48
50 virtual void invert() { put(1-get()); }
51
53 void write(float value);
54
56 void rawWrite(int value);
57
58protected:
59 virtual void begin();
60 virtual void step();
61};
62
64class DigitalOut : public DigitalSource, public PinConfig {
65public:
71
77 DigitalOut(uint8_t pin, uint8_t mode, Engine& engine = Engine::primary());
78
79 virtual ~DigitalOut() {}
80
82 virtual void mode(uint8_t mode);
83
85 void write(bool value);
86
88 void write(float value);
89
91 void rawWrite(int value);
92
93protected:
94 virtual void begin();
95 virtual void step();
96
97 virtual void _init();
98};
99
100} // namespace pq
101
102#endif
void rawWrite(int value)
Direclty writes raw value to the pin (bypasses mode and engine).
Definition PqOutputs.cpp:50
AnalogOut(uint8_t pin, Engine &engine=Engine::primary())
Constructor with default mode DIRECT.
Definition PqOutputs.cpp:26
virtual void invert()
Inverts value by calling put(1-get()) (eg. 0.2 becomes 0.8).
Definition PqOutputs.h:50
virtual float put(float value)
Pushes value into the component and returns its (possibly filtered) value.
Definition PqOutputs.cpp:38
void write(float value)
Direclty writes value in [0, 1] to the pin (bypasses mode and engine).
Definition PqOutputs.cpp:45
AnalogSource(Engine &engine)
Constructor.
Definition PqCore.h:485
virtual float get()
Returns value in [0, 1].
Definition PqCore.h:490
virtual void mode(uint8_t mode)
Changes the mode of the component.
Definition PqOutputs.cpp:70
void write(bool value)
Directly writes value to the pin (bypasses mode and engine).
Definition PqOutputs.cpp:79
void rawWrite(int value)
Directly writes HIGH or LOW value to the pin (bypasses mode and engine).
Definition PqOutputs.cpp:87
DigitalOut(uint8_t pin, Engine &engine=Engine::primary())
Constructor with default mode DIRECT.
Definition PqOutputs.cpp:61
DigitalSource(Engine &engine)
Constructor.
Definition PqCore.h:503
The main Plaquette static class containing all the units.
Definition PqCore.h:63
static Engine & primary()
Returns the main instance of Plaquette.
Definition PqCore.cpp:30
uint8_t pin() const
Returns the pin this component is attached to.
Definition PqCore.h:730
uint8_t mode() const
Returns the mode of the component.
Definition PqCore.h:733
Engine * engine() const
Returns the engine that owns this unit.
Definition PqCore.h:420