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

A generic class representing a simple PWM output. More...

#include <PqOutputs.h>

Inheritance diagram for pq::AnalogOut:
Collaboration diagram for pq::AnalogOut:

Public Member Functions

 AnalogOut (uint8_t pin, Engine &engine=Engine::primary())
 Constructor with default mode DIRECT.
 
 AnalogOut (uint8_t pin, uint8_t mode, Engine &engine=Engine::primary())
 Constructor.
 
virtual float put (float value)
 Pushes value into the component and returns its (possibly filtered) value.
 
virtual void invert ()
 Inverts value by calling put(1-get()) (eg. 0.2 becomes 0.8).
 
void write (float value)
 Direclty writes value in [0, 1] to the pin (bypasses mode and engine).
 
void rawWrite (int value)
 Direclty writes raw value to the pin (bypasses mode and engine).
 
virtual float get ()
 Returns value in [0, 1].
 
virtual float mapTo (float toLow, float toHigh)
 Maps value to new range.
 
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.
 
 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.
 

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 step ()
 
virtual void begin ()
 
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 _value
 
uint8_t _pin
 
uint8_t _mode
 

Detailed Description

A generic class representing a simple PWM output.

Constructor & Destructor Documentation

◆ AnalogOut() [1/2]

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

Constructor with default mode DIRECT.

Parameters
pinthe pin number

◆ AnalogOut() [2/2]

pq::AnalogOut::AnalogOut ( uint8_t  pin,
uint8_t  mode,
Engine engine = Engine::primary() 
)

Constructor.

Parameters
pinthe pin number
modethe mode (DIRECT or INVERTED)

Member Function Documentation

◆ 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::AnalogSource::get ( )
inlinevirtualinherited

Returns value in [0, 1].

Reimplemented from pq::Chainable.

Reimplemented in pq::AbstractWave.

◆ mapTo()

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

Maps value to new range.

Reimplemented from pq::Chainable.

Reimplemented in pq::Normalizer, pq::StreamIn, and pq::StreamOut.

◆ mode()

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

Changes the mode of the component.

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

◆ put()

float pq::AnalogOut::put ( float  value)
virtual

Pushes value into the component and returns its (possibly filtered) value.

Reimplemented from pq::Chainable.

◆ step()

void pq::AnalogOut::step ( )
protectedvirtual

Reimplemented from pq::Unit.


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