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.
main.cpp
- Committer:
- JMF
- Date:
- 2018-08-30
- Revision:
- 0:377a50b631cf
File content as of revision 0:377a50b631cf:
#include "mbed.h"
#include "Button.hpp"
void br_callback(int dur)
{
printf("\r\n!! button RELEASE called, press time: %d msec\r\n", dur);
}
void bp_callback(void)
{
printf("\r\n!! button PRESS called\r\n");
}
int main() {
int k, dur;
Button* button_ptr;
printf("Testing button class\r\n");
printf("Test Standard polling type implementation\r\n");
button_ptr = new Button(USER_BUTTON, Button::ActiveHigh);
while( (k=button_ptr->chkButton_press(&dur)) == 0 )
/* wait */;
printf(">Button pressed %d times, last was %d msec\r\n",k,dur);
delete button_ptr;
printf("\nTest with Release callback\r\n");
button_ptr = new Button(USER_BUTTON, Button::ActiveHigh, br_callback);
while( (k=button_ptr->chkButton_press(&dur)) == 0 )
/* wait */;
printf(">Button pressed %d times, last was %d msec\r\n",k,dur);
delete button_ptr;
printf("\nTest with Press & Release callback\r\n");
button_ptr = new Button(USER_BUTTON, Button::ActiveHigh, br_callback);
button_ptr->setButton_press_cb(bp_callback);
while( (k=button_ptr->chkButton_press(&dur)) == 0 )
/* wait */;
printf(">Button pressed %d times, last was %d msec\r\n",k,dur);
while (1) {
wait(.5);
}
}