Plaquette
 
Loading...
Searching...
No Matches
pq::Monitor Class Reference

Write-only monitor unit for textual output. More...

#include <Monitor.h>

Inheritance diagram for pq::Monitor:
Collaboration diagram for pq::Monitor:

Public Member Functions

 Monitor (unsigned long baudRate, Engine &engine=Engine::primary())
 Construct a Monitor using the default Serial device.
 
 Monitor (SerialType &device, unsigned long baudRate, Engine &engine=Engine::primary())
 Construct a Monitor using a specific serial device.
 
 Monitor (Print &device, Engine &engine=Engine::primary())
 Construct a Monitor using a generic Print backend.
 
Print & device () const
 Get the current Print backend.
 
void precision (uint8_t digits)
 Set the number of digits to print after the decimal point.
 
uint8_t precision () const
 Get the number of digits to print after the decimal point by default.
 
float put (float value) override
 Pushes value into the unit.
 
float get () override
 Returns value (last value that was put()).
 
virtual size_t write (uint8_t b) override
 Core Print override.
 
size_t print (double v)
 
size_t println (double v)
 
virtual void clearEvents ()
 
float seconds () const
 Returns engine time in seconds.
 
uint32_t milliSeconds () const
 Returns engine time in milliseconds.
 
uint64_t microSeconds () const
 Returns engine time in microseconds.
 
unsigned long nSteps () const
 Returns number of engine steps.
 
float sampleRate () const
 Returns engine sample rate.
 
float samplePeriod () const
 Returns enginesample period.
 
 operator float ()
 Object can be used directly to access its value.
 
virtual float mapTo (float toLow, float toHigh)
 Maps value to new range.
 
 operator bool ()
 Operator that allows usage in conditional expressions.
 

Static Public Member Functions

static bool analogToDigital (float f)
 Converts analog (float) value to digital (bool) value.
 
static float digitalToAnalog (bool b)
 Converts digital (bool) value to analog (float) value.
 

Protected Member Functions

void begin () override
 Ensure the underlying device is started (idempotent).
 
virtual void step ()
 
virtual bool eventTriggered (EventType eventType)
 Returns true iff an event of a certain type has been triggered.
 
virtual void onEvent (EventCallback callback, EventType eventType)
 Registers event callback.
 
Engineengine () const
 Returns the engine that owns this unit.
 

Protected Attributes

Print * _device = nullptr
 
bool _isSerial: 1
 
bool _begun: 1
 
uint8_t _digits: 6
 
unsigned long _baudRate = 0
 
float _value
 

Detailed Description

Write-only monitor unit for textual output.

Monitor is a Plaquette Unit and a Print proxy. It is intended for human-readable output (debugging, status messages) and deliberately does not expose Stream read functionality to avoid blocking behavior.

The backend can be any Print-compatible object (Serial, file, etc.). When bound to a serial device, Monitor can auto-start it at a given baud rate.

Constructor & Destructor Documentation

◆ Monitor()

pq::Monitor::Monitor ( Print &  device,
Engine engine = Engine::primary() 
)
explicit

Construct a Monitor using a generic Print backend.

No auto-start is performed.

Member Function Documentation

◆ begin()

void pq::Monitor::begin ( )
overrideprotectedvirtual

Ensure the underlying device is started (idempotent).

For non-serial backends, this is a no-op.

Reimplemented from pq::Unit.

◆ eventTriggered()

virtual bool pq::Unit::eventTriggered ( EventType  eventType)
inlineprotectedvirtualinherited

Returns true iff an event of a certain type has been triggered.

Reimplemented in pq::AbstractWave, pq::Alarm, pq::Metronome, pq::PeakDetector, pq::DigitalSource, pq::Ramp, pq::StreamIn, and pq::TimeSliceField< COUNT >.

◆ get()

float pq::Monitor::get ( )
inlineoverridevirtual

Returns value (last value that was put()).

Reimplemented from pq::Flowable.

◆ mapTo()

virtual float pq::Flowable::mapTo ( float  toLow,
float  toHigh 
)
inlinevirtualinherited

Maps value to new range.

This function guarantees that the value is within [toLow, toHigh]. If the unit's values are unbounded, returns get() constrained to [toLow, toHigh].

Reimplemented in pq::Normalizer, pq::DigitalUnit, pq::AnalogSource, pq::AnalogIn, pq::Ramp, pq::StreamIn, and pq::StreamOut.

◆ put()

float pq::Monitor::put ( float  value)
overridevirtual

Pushes value into the unit.

Parameters
valuethe value sent to the unit
Returns
the new value of the unit

Reimplemented from pq::Flowable.

◆ write()

size_t pq::Monitor::write ( uint8_t  b)
overridevirtual

Core Print override.

All print()/println() calls funnel through this method.


The documentation for this class was generated from the following files: