mirror of https://github.com/ARMmbed/mbed-os.git
A few improvements to the events documentation
parent
8545bf1212
commit
0abd141bf9
|
|
@ -23,8 +23,6 @@ The event loop must be created and started manually. The simplest way to achieve
|
||||||
#include "mbed.h"
|
#include "mbed.h"
|
||||||
#include "mbed_events.h"
|
#include "mbed_events.h"
|
||||||
|
|
||||||
using events::EventQueue;
|
|
||||||
|
|
||||||
// Create a queue that can hold a maximum of 32 events
|
// Create a queue that can hold a maximum of 32 events
|
||||||
Queue queue(32 * EVENTS_EVENT_SIZE);
|
Queue queue(32 * EVENTS_EVENT_SIZE);
|
||||||
// Create a thread that'll run the event queue's dispatch function
|
// Create a thread that'll run the event queue's dispatch function
|
||||||
|
|
@ -47,8 +45,6 @@ Once the event loop is created, it can be used for posting events. Let's conside
|
||||||
#include "mbed.h"
|
#include "mbed.h"
|
||||||
#include "mbed_events.h"
|
#include "mbed_events.h"
|
||||||
|
|
||||||
using events::EventQueue;
|
|
||||||
|
|
||||||
DigitalOut led1(LED1);
|
DigitalOut led1(LED1);
|
||||||
InterruptIn sw(SW2);
|
InterruptIn sw(SW2);
|
||||||
EventQueue queue(32 * EVENTS_EVENT_SIZE);
|
EventQueue queue(32 * EVENTS_EVENT_SIZE);
|
||||||
|
|
@ -74,7 +70,6 @@ int main() {
|
||||||
sw.rise(rise_handler);
|
sw.rise(rise_handler);
|
||||||
// The 'fall' handler will execute in the context of thread 't'
|
// The 'fall' handler will execute in the context of thread 't'
|
||||||
sw.fall(queue.event(fall_handler));
|
sw.fall(queue.event(fall_handler));
|
||||||
Thread::wait(osWaitForever);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue