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

Chronometer class which becomes "on" after a given duration. More...

#include <Alarm.h>

Inheritance diagram for pq::Alarm:
Collaboration diagram for pq::Alarm:

Public Member Functions

 Alarm (Engine &engine=Engine::primary())
 Constructor.
 
 Alarm (float duration, Engine &engine=Engine::primary())
 Constructor with duration.
 
virtual bool finished ()
 Returns true iff the alarm just finished its process this step.
 
virtual void onFinish (EventCallback callback)
 Registers event callback on finish event.
 
virtual void setTime (float time)
 Set alarm at specific time.
 
virtual bool isOn ()
 Returns true iff the input is "on".
 
virtual bool putOn (bool value)
 Pushes value into the unit.
 
virtual bool rose ()
 Returns true if the value rose.
 
virtual bool fell ()
 Returns true if the value fell.
 
virtual bool changed ()
 Returns true if the value changed.
 
virtual bool toggle ()
 Switches between on and off.
 
virtual int8_t changeState ()
 Difference between current and previous value of the unit.
 
virtual void onRise (EventCallback callback)
 Registers event callback on rise event.
 
virtual void onFall (EventCallback callback)
 Registers event callback on fall event.
 
virtual void onChange (EventCallback callback)
 Registers event callback on change event.
 
virtual bool isOff ()
 Returns true iff the input is "off".
 
virtual int getInt ()
 Returns value as integer (0 or 1).
 
virtual float get ()
 Returns value as float (either 0.0 or 1.0).
 
virtual bool on ()
 Sets output to "on" (ie. true, 1).
 
virtual bool off ()
 Sets output to "off" (ie. false, 0).
 
virtual float put (float value)
 Pushes value into the unit.
 
virtual float mapTo (float toLow, float toHigh)
 Maps value to new range.
 
 operator bool ()
 Operator that allows usage in conditional expressions.
 
 operator float ()
 
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.
 
virtual void start ()
 Starts/restarts the chronometer.
 
virtual void start (float duration)
 Starts/restarts the chronometer with specific duration.
 
virtual void duration (float duration)
 Sets the duration of the chronometer.
 
virtual float duration () const
 Returns duration.
 
virtual float progress () const
 The progress of the timer process (in %).
 
virtual bool isFinished () const
 Returns true iff the chronometer has finished its process.
 
virtual bool isComplete () const
 
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 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 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 bool eventTriggered (EventType eventType)
 Returns true iff an event of a certain type has been triggered.
 
virtual float _time () const
 
void _updateChangeState ()
 
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

bool _onValue: 1
 
bool _prevOnValue: 1
 
int8_t _changeState: 2
 
uint8_t _data: 4
 
float _duration
 
float _invDuration
 
float _startTime
 
float _offsetTime
 
float _elapsedTime
 
bool _isRunning
 

Detailed Description

Chronometer class which becomes "on" after a given duration.

Constructor & Destructor Documentation

◆ Alarm() [1/2]

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

Constructor.

Parameters
enginethe engine running this unit

◆ Alarm() [2/2]

pq::Alarm::Alarm ( float  duration,
Engine engine = Engine::primary() 
)

Constructor with duration.

Parameters
durationduration of the alarm
enginethe engine running this unit

Member Function Documentation

◆ _setRunning()

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

Implements pq::Timeable.

◆ _time()

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

◆ addTime()

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

Adds/subtracts time to the chronometer.

Implements pq::Timeable.

◆ begin()

void pq::Alarm::begin ( )
protectedvirtual

Reimplemented from pq::Unit.

◆ duration() [1/2]

virtual float pq::AbstractTimer::duration ( ) const
inlinevirtualinherited

Returns duration.

Reimplemented in pq::Ramp.

◆ duration() [2/2]

void pq::AbstractTimer::duration ( float  duration)
virtualinherited

Sets the duration of the chronometer.

Reimplemented in pq::Ramp.

◆ eventTriggered()

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

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

Reimplemented from pq::DigitalSource.

◆ get()

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

Returns value as float (either 0.0 or 1.0).

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

◆ isComplete()

virtual bool pq::AbstractTimer::isComplete ( ) const
inlinevirtualinherited

◆ isOn()

virtual bool pq::DigitalSource::isOn ( )
inlinevirtualinherited

Returns true iff the input is "on".

Reimplemented from pq::DigitalUnit.

◆ 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::DigitalUnit::mapTo ( float  toLow,
float  toHigh 
)
inlinevirtualinherited

Maps value to new range.

Reimplemented from pq::Chainable.

◆ pause()

void pq::AbstractChronometer::pause ( )
virtualinherited

Interrupts the chronometer.

Reimplemented from pq::Timeable.

◆ put()

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

Pushes value into the unit.

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

Reimplemented from pq::Chainable.

Reimplemented in pq::PeakDetector.

◆ putOn()

virtual bool pq::DigitalSource::putOn ( bool  value)
inlinevirtualinherited

Pushes value into the unit.

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

Reimplemented from pq::DigitalUnit.

◆ resume()

void pq::AbstractChronometer::resume ( )
virtualinherited

Resumes process.

Reimplemented from pq::Timeable.

◆ setTime()

void pq::Alarm::setTime ( float  time)
virtual

Set alarm at specific time.

Reimplemented from pq::AbstractChronometer.

◆ start()

void pq::AbstractTimer::start ( )
virtualinherited

Starts/restarts the chronometer.

Reimplemented from pq::Timeable.

Reimplemented in pq::Ramp.

◆ step()

void pq::Alarm::step ( )
protectedvirtual

Reimplemented from pq::Unit.


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