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.
Diff: main.cpp
- Revision:
- 2:d4fab8f3f21f
- Parent:
- 1:c5769cd78933
- Child:
- 3:c048b13bc1d0
--- a/main.cpp Wed Oct 22 06:52:32 2014 +0000
+++ b/main.cpp Wed Oct 22 07:01:00 2014 +0000
@@ -20,50 +20,45 @@
// Die Start-Taste ein 3.mal betätigen:
// Alle LEDs aus.
-
-//volatile uint8_t count;
-volatile unsigned int count;
volatile unsigned int event=0;
volatile int led=0;
-int ledsEin();
-int msec300TimerOn();
-int ledsTogglen();
-int startTimer();
+void switchled();
+void blinkled();
-
-int msec300TimerOn()
+void ledsSwitchTimer()
{
- startTimer();
- return(1);
+ tick.attach(&switchled, 0.2);
}
-int stopTimer()
+void ledsBlinkTimer()
+{
+ tick.attach(&blinkled, 0.2);
+}
+
+void stopTimer()
{
led1 = 0;
led2 = 0;
led3 = 0;
led4 = 0;
tick.detach();
- return(2);
}
-int ledsTogglen()
+void ledsEin()
+{
+ led1 = 1;
+ led2 = 1;
+ led3 = 1;
+ led4 = 1;
+}
+
+void ledsTogglen()
{
led1 = !led1;
led2 = !led2;
led3 = !led3;
led4 = !led4;
- return(3);
-}
-
-int ledsEin()
-{
- led1 = 1;
- led2 = 1;
- led3 = 1;
- led4 = 1;
- return(4);
}
void switchled()
@@ -94,41 +89,11 @@
led++;
}
-int ledsSwitch()
-{
- tick.attach(&switchled, 0.2);
- return(0);
-}
-
-// interrupt SR
-void blink()
+void blinkled()
{
ledsTogglen();
}
-// functions
-int startTimer()
-{
- tick.attach(&blink, 0.2);
- return(0);
-}
-
-void debounce(PinName name, unsigned char samples)
-{
- DigitalIn joystick(name);
-
- for(unsigned char j = 0; j < samples; j++)
- {
- if(joystick == 1)
- j++;
- else
- j = 0;
-
- if(j == samples)
- break;
- }
-}
-
void doEvent()
{
switch(event)
@@ -141,14 +106,14 @@
break;
case 1:
led = 0;
- ledsSwitch();
+ ledsSwitchTimer();
break;
case 2:
stopTimer();
ledsTogglen();
break;
case 3:
- msec300TimerOn();
+ ledsBlinkTimer();
break;
case 4:
stopTimer();