User Manual
Example
// configure pins PD0 and PD1 as pulse input channels
pulse_in_start((unsigned char[]) {IO_D0, IO_C3}, 2);
struct PulseInputStruct pulseInfo;
get_pulse_info(1, &pulseInfo); // get pulse info for pin PC3
if (pulseInfo.newPulse & HIGH_PULSE)
someFunction(pulseInfo.lastHighPulse);
// configure pins PD0 and PD1 as pulse input channels
OrangutanPulseIn::start((unsigned char[]) {IO_D0, IO_C3}, 2);
struct PulseInputStruct pulseInfo;
OrangutanPulseIn::getPulseInfo(1, &pulseInfo); // get pulse info for pin PC3
if (pulseInfo.newPulse & HIGH_PULSE)
someFunction(pulseInfo.lastHighPulse);
static unsigned char OrangutanPulseIn::newPulse(unsigned char channel)
unsigned char new_pulse(unsigned char channel)
This function returns the newPulse flags for the specified pulse input channel and then clears them, so
subsequent new_pulse() calls will return zero until the next new pulse is received. The return value of
this fuction will be 0 only if no new pulses have been received. It will be non-zero if a new high or
low pulse has been received. You can check the type of new pulse by looking at the HIGH_PULSE and
LOW_PULSE bits of the return value.
Example
// check for new pulses on pulse input channel 0:
unsigned char newPulse = new_pulse(0);
if (newPulse) // if there has been a new pulse of any kind
doSomething();
if (newPulse & HIGH_PULSE) // if there has been a new high pulse
doSomethingElse();
// check for new pulses on pulse input channel 0:
unsigned char newPulse = OrangutanPulseIn::newPulse(0);
if (newPulse) // if there has been a new pulse of any kind
doSomething();
if (newPulse & HIGH_PULSE) // if there has been a new high pulse
doSomethingElse();
static unsigned char OrangutanPulseIn::newHighPulse(unsigned char channel)
unsigned char new_high_pulse(unsigned char channel)
This function returns the newPulse flags if there is a new high pulse on the specified pulse input channel
(i.e. the return value is non-zero), else it returns zero. It also clears the HIGH_PULSE bit of the newPulse
flag byte, so subsequent new_high_pulse() calls will return zero until the next new high pulse is received.
The LOW_PULSE bit is not changed by this function.
static unsigned char OrangutanPulseIn::newLowPulse(unsigned char channel)
unsigned char new_low_pulse(unsigned char channel)
This function returns the newPulse flags if there is a new low pulse on the specified pulse input channel
(i.e. the return value is non-zero), else it returns zero. It also clears the LOW_PULSE bit of the newPulse
flag byte, so subsequent new_low_pulse() calls will return zero until the next new low pulse is received.
The HIGH_PULSE bit is not changed by this function.
static unsigned long OrangutanPulseIn::getLastHighPulse(unsigned char channel)
unsigned long get_last_high_pulse(unsigned char channel)
Pololu AVR Library Command Reference © 2001–2015 Pololu Corporation
8. Orangutan Pulse/PWM Inputs Page 33 of 65