Plaquette
 
Loading...
Searching...
No Matches
Monitor.h
1/*
2 * Monitor.h
3 *
4 * (c) 2025 Sofian Audry :: info(@)sofianaudry(.)com
5 * (c) 2025 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_MONITOR_H_
22#define PQ_MONITOR_H_
23
24#include "PqCore.h"
25#include "pq_serial.h"
26
27namespace pq {
28
40class Monitor : public Unit, public Print {
41public:
45 explicit Monitor(unsigned long baudRate,
47
51 Monitor(SerialType& device, unsigned long baudRate,
53
58 explicit Monitor(Print& device,
60
62 Print& device() const { return *_device; }
63
67 void precision(uint8_t digits);
68
70 uint8_t precision() const { return _digits; }
71
77 float put(float value) override;
78
80 float get() override { return _value; }
81
87 virtual size_t write(uint8_t b) override;
88
89 using Print::print;
90 using Print::println;
91
92 size_t print(double v);
93 size_t println(double v);
94
95 // // This is to support all the Print methods
96 // using Print::write;
97
98protected:
104 void begin() override;
105
106 Print* _device = nullptr;
107 bool _isSerial : 1;
108 bool _begun : 1;
109 uint8_t _digits : 6;
110
111 unsigned long _baudRate = 0;
112
113 float _value;
114};
115
116} // namespace pq
117
118#endif // PQ_MONITOR_H_
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
Write-only monitor unit for textual output.
Definition Monitor.h:40
float put(float value) override
Pushes value into the unit.
Definition Monitor.cpp:95
uint8_t precision() const
Get the number of digits to print after the decimal point by default.
Definition Monitor.h:70
void begin() override
Ensure the underlying device is started (idempotent).
Definition Monitor.cpp:53
float get() override
Returns value (last value that was put()).
Definition Monitor.h:80
Print & device() const
Get the current Print backend.
Definition Monitor.h:62
virtual size_t write(uint8_t b) override
Core Print override.
Definition Monitor.cpp:79
A generic class representing a unit in the system.
Definition PqCore.h:373
Engine * engine() const
Returns the engine that owns this unit.
Definition PqCore.h:420