Lights the barrery LED one-by-one, in an interval of 0.5 seconds. When button A is pressed, the LEDS hold.

Dependencies:   FRDM-TFC mbed

Files at this revision

API Documentation at this revision

Comitter:
NoamVH
Date:
Sat Feb 27 13:57:43 2016 +0000
Parent:
0:f74a732ac3ae
Child:
2:61a8e97a0875
Commit message:
Discovered the function TFC_SetBatteryLED_Level( i ) from the TFC API, which cuts the code to half length and makes things much more simple.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Feb 24 20:56:06 2016 +0000
+++ b/main.cpp	Sat Feb 27 13:57:43 2016 +0000
@@ -1,29 +1,6 @@
 #include "mbed.h"
 #include "TFC.h"
 
-void LED(int i)
-{
-    switch(i) {
-        case 0:
-            TFC_BAT_LED0_ON;
-            break;
-        case 1:
-            TFC_BAT_LED1_ON;
-            break;
-        case 2:
-            TFC_BAT_LED2_ON;
-            break;
-        case 3:
-            TFC_BAT_LED3_ON;
-            break;
-        default:
-            TFC_BAT_LED0_OFF;
-            TFC_BAT_LED1_OFF;
-            TFC_BAT_LED2_OFF;
-            TFC_BAT_LED3_OFF;
-    }
-}
-
 int main()
 {
     TFC_Init();
@@ -31,15 +8,15 @@
     for(;;) {
         if(TFC_PUSH_BUTTON_0_PRESSED)
             while(TFC_PUSH_BUTTON_0_PRESSED) {
-                LED(i);
+                TFC_SetBatteryLED_Level(i);
             }
 
         else
-            LED(i);
+            TFC_SetBatteryLED_Level(i);
             wait(0.5);
-            i++;
             if(i>4)
                 i = 0;
+    i++;
     }
 }