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:
- addyi
- Date:
- 2014-11-26
- Revision:
- 1:0072ef0302ec
- Parent:
- 0:76669ad2c30b
- Child:
- 2:14b38579386c
File content as of revision 1:0072ef0302ec:
#include "mbed.h"
DigitalIn b1(p8);
DigitalIn b2(p14);
DigitalOut led[] = {(LED1), (LED2),(LED3),(LED4)};
bool shortPress =false;
bool longPress = false;
int counterTime = 0;
int counterBlink=8;
Ticker timeTasterTest;
Ticker timeLedTest;
void tasterTest();
void ledTest();
int main()
{
timeTasterTest.attach(&tasterTest,0.01);
timeLedTest.attach(&ledTest,0.5);
while(1) {
}
}
void ledTest()
{
if(shortPress) {
if(counterBlink>0) {
led[3]=!led[3];
counterBlink--;
} else {
led[3]=0;
counterBlink=8;
shortPress=false;
}
}
if(longPress) {
led[3]=!led[3];
}
if(!longPress&&!shortPress) {
led[3]=0;
}
}
void tasterTest()
{
if(!b1) {
if(counterTime<500) {
longPress=false;
shortPress=true;
counterTime ++;
} else {
counterTime=0;
longPress=true;
shortPress=false;
}
} else {
if(longPress) {
counterTime=0;
longPress=false;
shortPress=false;
}
}
}