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

A generic class representing a simple analog input. More...

#include <PqInputs.h>

Inheritance diagram for pq::AnalogIn:
Collaboration diagram for pq::AnalogIn:

Public Member Functions

 AnalogIn (uint8_t pin, Engine &engine=Engine::primary())
 Constructor.
 
 AnalogIn (uint8_t pin, uint8_t mode, Engine &engine=Engine::primary())
 
virtual float get ()
 Returns value in [0, 1].
 
virtual float mapTo (float toLow, float toHigh)
 Maps value to new range.
 
float read () const
 Direcly reads value from the pin (bypasses mode, smoothing, and engine).
 
int rawRead () const
 Directly reads raw value from the pin (bypasses mode, smoothing, and engine).
 
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.
 
uint8_t pin () const
 Returns the pin this component is attached to.
 
uint8_t mode () const
 Returns the mode of the component.
 
virtual void mode (uint8_t mode)
 Changes the mode of the component.
 
virtual void smooth (float smoothTime=PLAQUETTE_DEFAULT_SMOOTH_WINDOW)
 Apply smoothing to object.
 
virtual void noSmooth ()
 Remove smoothing.
 
virtual void timeWindow (float seconds)
 Changes the smoothing window (expressed in seconds).
 
float timeWindow () const
 Returns the smoothing window (expressed in seconds).
 
virtual void cutoff (float hz)
 Changes the smoothing window cutoff frequency (expressed in Hz).
 
float cutoff () const
 Returns the smoothing window cutoff frequency (expressed in Hz).
 

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 float _read ()
 
virtual float _sampleRate () const
 
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.
 
virtual void _begin ()
 
virtual void _step ()
 
virtual float _smoothed ()
 

Protected Attributes

uint8_t _pin
 
uint8_t _mode
 
MovingAverage _avg
 

Detailed Description

A generic class representing a simple analog input.

Constructor & Destructor Documentation

◆ AnalogIn()

pq::AnalogIn::AnalogIn ( uint8_t  pin,
Engine engine = Engine::primary() 
)

Constructor.

Parameters
pinthe pin number
modethe mode (DIRECT or INVERTED)

Member Function Documentation

◆ _read()

float pq::AnalogIn::_read ( )
protectedvirtual

Implements pq::Smoothable.

◆ _sampleRate()

virtual float pq::AnalogIn::_sampleRate ( ) const
inlineprotectedvirtual

Implements pq::Smoothable.

◆ begin()

void pq::AnalogIn::begin ( )
protectedvirtual

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()

virtual float pq::AnalogIn::get ( )
inlinevirtual

Returns value in [0, 1].

Reimplemented from pq::Chainable.

◆ mapTo()

float pq::AnalogIn::mapTo ( float  toLow,
float  toHigh 
)
virtual

Maps value to new range.

Reimplemented from pq::Chainable.

◆ mode()

virtual void pq::PinConfig::mode ( uint8_t  mode)
inlinevirtualinherited

Changes the mode of the component.

Reimplemented in pq::DigitalIn, and pq::DigitalOut.

◆ 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::AnalogIn::step ( )
protectedvirtual

Reimplemented from pq::Unit.


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