Plaquette
 
Loading...
Searching...
No Matches
pq::Chronometer Class Reference
Inheritance diagram for pq::Chronometer:
Collaboration diagram for pq::Chronometer:

Public Member Functions

 Chronometer (Engine &engine=Engine::primary())
 Constructor.
 
virtual float get ()
 Returns elapsed time since start (in seconds).
 
virtual float put (float value)
 Sets current time in seconds and returns it.
 
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.
 
virtual void pause ()
 Interrupts the chronometer.
 
virtual void resume ()
 Resumes process.
 
virtual float elapsed () const
 The time currently elapsed by the chronometer (in seconds).
 
virtual bool hasPassed (float timeout) const
 Returns true iff elapsed time has passed given timeout.
 
virtual bool hasPassed (float timeout, bool restartIfPassed)
 
virtual void setTime (float time)
 Forces current time (in seconds).
 
virtual void addTime (float time)
 Adds/subtracts time to the chronometer.
 
virtual bool isRunning () const
 Returns true iff the chronometer is currently running.
 
bool isStarted () const
 
virtual void start ()
 Starts/restarts the chronometer.
 
virtual void stop ()
 Interrupts the chronometer and resets to zero.
 
virtual void togglePause ()
 Toggles pause/unpause.
 

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 _time () 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 update ()
 
virtual void _setRunning (bool isRunning)
 

Protected Attributes

float _startTime
 
float _offsetTime
 
float _elapsedTime
 
bool _isRunning
 

Member Function Documentation

◆ _setRunning()

virtual void pq::AbstractChronometer::_setRunning ( bool  isRunning)
inlineprotectedvirtualinherited

Implements pq::Timeable.

◆ _time()

float pq::Chronometer::_time ( ) const
protectedvirtual

◆ addTime()

void pq::AbstractChronometer::addTime ( float  time)
virtualinherited

Adds/subtracts time to the chronometer.

Implements pq::Timeable.

◆ begin()

void pq::Chronometer::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::Chronometer::get ( )
inlinevirtual

Returns elapsed time since start (in seconds).

Reimplemented from pq::Chainable.

◆ hasPassed()

bool pq::AbstractChronometer::hasPassed ( float  timeout,
bool  restartIfPassed 
)
virtualinherited
Deprecated:
Returns true iff elapsed time has passed given timeout (optional argument to automatically restart if true).

◆ isRunning()

virtual bool pq::AbstractChronometer::isRunning ( ) const
inlinevirtualinherited

Returns true iff the chronometer is currently running.

Implements pq::Timeable.

◆ isStarted()

bool pq::AbstractChronometer::isStarted ( ) const
inlineinherited

◆ mapTo()

virtual float pq::Chainable::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.

◆ pause()

void pq::AbstractChronometer::pause ( )
virtualinherited

Interrupts the chronometer.

Reimplemented from pq::Timeable.

◆ put()

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

Sets current time in seconds and returns it.

Reimplemented from pq::Chainable.

◆ resume()

void pq::AbstractChronometer::resume ( )
virtualinherited

Resumes process.

Reimplemented from pq::Timeable.

◆ setTime()

void pq::AbstractChronometer::setTime ( float  time)
virtualinherited

Forces current time (in seconds).

Implements pq::Timeable.

Reimplemented in pq::Alarm, and pq::Ramp.

◆ start()

void pq::Timeable::start ( )
virtualinherited

Starts/restarts the chronometer.

Reimplemented in pq::AbstractTimer, and pq::Ramp.

◆ step()

void pq::Chronometer::step ( )
protectedvirtual

Reimplemented from pq::Unit.


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