Metro
A metronome digital source unit. Emits an “on” signal at a regular pace.
Example
#include <Plaquette.h>
Metro myMetro(0.5); // a metronome with a half-second duration
DigitalOut led(13);
void begin() {
}
void step() {
if (myMetro)
{
// Change LED state.
led.toggle();
}
}
Reference
-
class Metro : public DigitalSource
Chronometer digital unit which emits 1/true/”on” for one frame, at a regular pace.
Public Functions
-
Metro(float period = 1.0f)
Constructor.
- Parameters:
period – the period of oscillation (in seconds)
-
virtual void period(float period)
Sets the period (in seconds).
- Parameters:
period – the period of oscillation (in seconds)
-
inline virtual float period() const
Returns the period (in seconds).
-
virtual void frequency(float frequency)
Sets the frequency (in Hz).
- Parameters:
frequency – the frequency of oscillation (in Hz)
-
inline virtual float frequency() const
Returns the frequency (in Hz).
-
virtual void phase(float phase)
Sets the phase (ie.
the offset, in % of period).
- Parameters:
phase – the phase (in % of period)
-
inline virtual float phase() const
Returns the phase (in % of period).
-
inline virtual bool isOn()
Returns true iff the input is “on”.
-
inline virtual bool rose()
Returns true if the value rose.
-
inline virtual bool fell()
Returns true if the value fell.
-
inline virtual bool changed()
Returns true if the value changed.
-
inline virtual int8_t changeState()
Difference between current and previous value of the unit.
-
inline virtual bool isOff()
Returns true iff the input is “off”.
-
inline virtual int getInt()
Returns value as integer (0 or 1).
-
inline virtual float get()
Returns value as float (either 0.0 or 1.0).
-
Metro(float period = 1.0f)