24#include "PlotterFormat.h"
29enum PlotterFormatPreset {
38 const char*
labels =
nullptr,
42 unsigned long baudRate,
43 const char*
labels =
nullptr,
47 const char*
labels =
nullptr,
54 const char*
labels()
const {
return _labels; }
57 void format(PlotterFormatPreset preset);
69 void precision(uint8_t digits) { _digits = digits; }
79 float put(
float value)
override;
82 float get()
override {
return _lastValue; }
91 void begin()
override;
96 Print* _out =
nullptr;
99 SerialType* _serial =
nullptr;
100 unsigned long _baudRate = 0;
106 const char* _labels =
nullptr;
107 uint16_t _labelCount = 0;
108 bool _headerPrinted =
false;
111 uint8_t _digits = PLAQUETTE_PRINT_DEFAULT_DIGITS;
114 bool _rowOpen =
false;
115 uint16_t _valueIndex = 0;
117 float _lastValue = 0.0f;
120 bool _plotOpen =
true;
123 bool _scheduleBeginPlot =
false;
124 bool _scheduleEndRow =
false;
131 void _rebuildFormat(PlotterFormatPreset preset);
132 void _ensureHeader();
133 void _openRowIfNeeded();
134 void _closeRowIfOpen(
bool printEndRow);
137 void _printValue(
float value);
140 static bool _isSpace(
char c);
141 static LabelView _trimSpaces(
const char* start,
const char* end);
143 uint16_t _countLabels(
const char* schema)
const;
144 LabelView _labelAt(uint16_t index)
const;
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
float get() override
Returns last value.
Definition Plotter.h:82
PlotterFormat format()
Returns current format.
Definition Plotter.h:63
const char * labels() const
Returns labels.
Definition Plotter.h:54
void beginPlot()
Begins new plot.
Definition Plotter.cpp:107
void precision(uint8_t digits)
Sets decimal precision of values.
Definition Plotter.h:69
float put(float value) override
Pushes value into the unit.
Definition Plotter.cpp:160
void endPlot()
Ends current plot.
Definition Plotter.cpp:117
uint8_t precision() const
Returns the decimal precision of values.
Definition Plotter.h:72
static PlotterFormat formatFromPreset(PlotterFormatPreset preset, const char *labelsSchema=nullptr)
Returns a PlotterFormat based on presets and labels.
Definition Plotter.cpp:57
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
Lightweight non-owning view of a label (no allocation).
Definition PlotterFormat.h:34