api / mbed / trunk / Timeout

Timeout

class Timeout : public Ticker

A Timeout is used to call a function at a point in the future

You can use as many seperate Timeout objects as you require.

Example

// Blink until timeout.

#include "mbed.h"

Timeout timeout;
DigitalOut led(LED1);

int on = 1;

void attimeout() {
    on = 0;
}

int main() {
    timeout.attach(&attimeout, 5);
    while(on) {
        led = !led;
        wait(0.2);
    }
}
TimeoutA Timeout is used to call a function at a point in the future
Functions
attachAttach a function to be called by the Timeout, specifiying the delay in seconds
attachAttach a member function to be called by the Timeout, specifiying the delay in seconds
attach_usAttach a function to be called by the Timeout, specifiying the delay in micro-seconds
attach_usAttach a member function to be called by the Timeout, specifiying the delay in micro-seconds
detachDetach the function

Functions

attach

void attach(void (*fptr)(void),
float t)

Attach a function to be called by the Timeout, specifiying the delay in seconds

Variables

fptrpointer to the function to be called
tthe time before the call in seconds

attach

template<typename T> void attach(*tptr,
void (T::*mptr)(void),
float t)

Attach a member function to be called by the Timeout, specifiying the delay in seconds

Variables

tptrpointer to the object to call the member function on
mptrpointer to the member function to be called
tthe time before the calls in seconds

attach_us

void attach_us(void (*fptr)(void),
unsigned int t)

Attach a function to be called by the Timeout, specifiying the delay in micro-seconds

Variables

fptrpointer to the function to be called
tthe time before the call in micro-seconds

attach_us

template<typename T> void attach_us(*tptr,
void (T::*mptr)(void),
unsigned int t)

Attach a member function to be called by the Timeout, specifiying the delay in micro-seconds

Variables

tptrpointer to the object to call the member function on
mptrpointer to the member function to be called
tthe time before the call in micro-seconds

detach

void detach()

Detach the function

class Timeout : public Ticker
A Timeout is used to call a function at a point in the future
void attach(void (*fptr)(void),
float t)
Attach a function to be called by the Timeout, specifiying the delay in seconds
void attach_us(void (*fptr)(void),
unsigned int t)
Attach a function to be called by the Timeout, specifiying the delay in micro-seconds
void detach()
Detach the function