Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
src/main.cpp@1:628e1249eaa1, 2019-03-01 (annotated)
- Committer:
- Condo2k4
- Date:
- Fri Mar 01 10:05:55 2019 +0000
- Revision:
- 1:628e1249eaa1
- Parent:
- 0:f43a2a24edc2
Minor clean up
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| Condo2k4 | 0:f43a2a24edc2 | 1 | #include <events/mbed_events.h> | 
| Condo2k4 | 0:f43a2a24edc2 | 2 | #include <mbed.h> | 
| Condo2k4 | 0:f43a2a24edc2 | 3 | #include "BLE_EH.h" | 
| Condo2k4 | 0:f43a2a24edc2 | 4 | |
| Condo2k4 | 1:628e1249eaa1 | 5 | static events::EventQueue event_queue(16 * EVENTS_EVENT_SIZE); | 
| Condo2k4 | 0:f43a2a24edc2 | 6 | |
| Condo2k4 | 0:f43a2a24edc2 | 7 | RawSerial serial(P0_6, P0_8, 115200); | 
| Condo2k4 | 0:f43a2a24edc2 | 8 | |
| Condo2k4 | 0:f43a2a24edc2 | 9 | void schedule_ble_events(BLE::OnEventsToProcessCallbackContext *context) { | 
| Condo2k4 | 0:f43a2a24edc2 | 10 | event_queue.call(Callback<void()>(&context->ble, &BLE::processEvents)); | 
| Condo2k4 | 0:f43a2a24edc2 | 11 | } | 
| Condo2k4 | 0:f43a2a24edc2 | 12 | |
| Condo2k4 | 0:f43a2a24edc2 | 13 | void buttonPress(int id) { | 
| Condo2k4 | 0:f43a2a24edc2 | 14 | serial.printf("Button Pressed: %d\n", id); | 
| Condo2k4 | 0:f43a2a24edc2 | 15 | } | 
| Condo2k4 | 0:f43a2a24edc2 | 16 | |
| Condo2k4 | 0:f43a2a24edc2 | 17 | InterruptIn b1(BUTTON1); | 
| Condo2k4 | 0:f43a2a24edc2 | 18 | InterruptIn b2(BUTTON2); | 
| Condo2k4 | 0:f43a2a24edc2 | 19 | InterruptIn b3(BUTTON3); | 
| Condo2k4 | 0:f43a2a24edc2 | 20 | InterruptIn b4(BUTTON4); | 
| Condo2k4 | 0:f43a2a24edc2 | 21 | |
| Condo2k4 | 0:f43a2a24edc2 | 22 | void alive() { | 
| Condo2k4 | 0:f43a2a24edc2 | 23 | serial.printf("Blink\n"); | 
| Condo2k4 | 0:f43a2a24edc2 | 24 | } | 
| Condo2k4 | 0:f43a2a24edc2 | 25 | |
| Condo2k4 | 0:f43a2a24edc2 | 26 | int main() { | 
| Condo2k4 | 0:f43a2a24edc2 | 27 | // serial.getc(); //DEBUG ONLY - pauses until first keypress | 
| Condo2k4 | 0:f43a2a24edc2 | 28 | serial.set_flow_control(SerialBase::RTSCTS, P0_5, P0_7); | 
| Condo2k4 | 0:f43a2a24edc2 | 29 | |
| Condo2k4 | 0:f43a2a24edc2 | 30 | BLE &ble = BLE::Instance(); | 
| Condo2k4 | 0:f43a2a24edc2 | 31 | ble.onEventsToProcess(schedule_ble_events); | 
| Condo2k4 | 0:f43a2a24edc2 | 32 | BLE_EH ble_eh(ble, event_queue); | 
| Condo2k4 | 0:f43a2a24edc2 | 33 | ble_eh.start(); | 
| Condo2k4 | 0:f43a2a24edc2 | 34 | serial.printf("BLE started\n"); | 
| Condo2k4 | 0:f43a2a24edc2 | 35 | |
| Condo2k4 | 0:f43a2a24edc2 | 36 | b1.rise(event_queue.event(&buttonPress, 1)); | 
| Condo2k4 | 0:f43a2a24edc2 | 37 | b2.rise(event_queue.event(&buttonPress, 2)); | 
| Condo2k4 | 0:f43a2a24edc2 | 38 | b3.rise(event_queue.event(&buttonPress, 3)); | 
| Condo2k4 | 0:f43a2a24edc2 | 39 | b4.rise(event_queue.event(&buttonPress, 4)); | 
| Condo2k4 | 0:f43a2a24edc2 | 40 | |
| Condo2k4 | 0:f43a2a24edc2 | 41 | event_queue.call_every(2000, &alive); | 
| Condo2k4 | 0:f43a2a24edc2 | 42 | event_queue.dispatch_forever(); | 
| Condo2k4 | 0:f43a2a24edc2 | 43 | return 0; | 
| Condo2k4 | 0:f43a2a24edc2 | 44 | } |