Newer
Older
/* mbed Microcontroller Library
* Copyright (c) 2019 ARM Limited
* SPDX-License-Identifier: Apache-2.0
*/
#include "ButtonEvent.h"
#include "ButtonEventDispatcher.h"
#undef __ARM_FP // fix FPU warning
#include "platform/mbed_thread.h"
DigitalOut led(LED1);
ButtonEventDispatcher bed;
Timer t;
void processButtonEvent(const ButtonEvent& e ) {
if(e.getType() == ButtonEvent::shortPress) {
led = !led; // toggle LED1
}
if(e.getType() == ButtonEvent::longPress) {
led = 0;
}
if(e.getType() == ButtonEvent::veryLongPress) {
led = 1;
}
}
unsigned int iterations = 0;
t.start();
while (t.elapsed_time() < 1000ms) {
iterations++;
bed.Dispatch(ButtonEvent(ButtonEvent::veryLongPress, ButtonEvent::button2));