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

Stream/serial input. Reads float values using Arduino built-in parseFloat(). More...

#include <StreamIn.h>

Inheritance diagram for pq::StreamIn:
Collaboration diagram for pq::StreamIn:

Public Member Functions

 StreamIn (Engine &engine=Engine::primary())
 Default constructor.
 
 StreamIn (Stream &stream, Engine &engine=Engine::primary())
 Constructor.
 
virtual float mapTo (float toLow, float toHigh)
 Maps value to new range.
 
virtual bool updated ()
 Returns true iff value was changed.
 
virtual void onUpdate (EventCallback callback)
 Registers event callback on finish event.
 
virtual float get ()
 Returns value in [0, 1].
 
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 put (float value)
 Pushes value into the unit.
 
 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

virtual void begin ()
 
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

float _nextValue
 
float _nextFraction
 
bool _nextIsValid: 1
 
bool _nextIsNegative: 1
 
bool _nextIsFraction: 1
 
bool _valueUpdated: 1
 
Stream * _stream
 
float _value
 

Detailed Description

Stream/serial input. Reads float values using Arduino built-in parseFloat().

Constructor & Destructor Documentation

◆ StreamIn() [1/2]

pq::StreamIn::StreamIn ( Engine engine = Engine::primary())

Default constructor.

Parameters
enginethe engine running this unit

◆ StreamIn() [2/2]

pq::StreamIn::StreamIn ( Stream &  stream,
Engine engine = Engine::primary() 
)

Constructor.

Parameters
streama reference to a Stream object
enginethe engine running this unit

Member Function Documentation

◆ begin()

void pq::StreamIn::begin ( )
protectedvirtual

Reimplemented from pq::Unit.

◆ eventTriggered()

virtual bool pq::StreamIn::eventTriggered ( EventType  eventType)
inlineprotectedvirtual

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

Reimplemented from pq::Unit.

◆ get()

virtual float pq::AnalogSource::get ( )
inlinevirtualinherited

Returns value in [0, 1].

Reimplemented from pq::Chainable.

Reimplemented in pq::AbstractWave.

◆ mapTo()

virtual float pq::StreamIn::mapTo ( float  toLow,
float  toHigh 
)
inlinevirtual

Maps value to new range.

Reimplemented from pq::AnalogSource.

◆ put()

virtual float pq::Chainable::put ( float  value)
inlinevirtualinherited

Pushes value into the unit.

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

Reimplemented in pq::Chronometer, pq::MinMaxScaler, pq::Normalizer, pq::PeakDetector, pq::DigitalUnit, pq::AnalogOut, pq::AbstractServoOut, pq::Ramp, pq::Smoother, pq::StreamOut, pq::PivotField, and pq::TimeSliceField< COUNT >.

◆ step()

void pq::StreamIn::step ( )
protectedvirtual

Reimplemented from pq::Unit.


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