Maxint R&D / Mbed 2 deprecated mBuino_Dice

Dependencies:   mbed

Fork of mBuino_Dice by Valentin Ivanov

Files at this revision

API Documentation at this revision

Comitter:
maxint
Date:
Tue Sep 16 08:19:55 2014 +0000
Parent:
5:e2f89a6f4d6c
Commit message:
0.1.140916 Using the Outrageous Circuits mBuino platform instead of LPC11U24 (available now); Renamed LED ports to newly available mBuino LED constants; Earlier power down after dice roll, showing by flashes slowing down

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Sep 15 16:35:48 2014 +0000
+++ b/main.cpp	Tue Sep 16 08:19:55 2014 +0000
@@ -5,6 +5,10 @@
 ** Setup requirements: connect any type of switch between P0.4 and GND.
 ** On mBuino P0.4 is close to GND and the two pitch distance is exactly the same as a mini-switch! 
 **
+** 0.1.140916 Using the Outrageous Circuits mBuino platform instead of LPC11U24 (available now)
+**            Renamed LED ports to newly available mBuino LED constants
+**            Earlier power down after dice roll, showing by flashes slowing down
+** 0.1.140915 Energy use in power down mode down to 3 uA, credits: Andy A
 ** 0.1.140910 Power down after one iteration of demo or ten seconds of wating, credits: Andy A
 ** 0.1.140908 Added deep sleep mode after one iteration of demo or ten seconds of wating, credits: Andy A and Erik Olieman
 **            Added explanatory comments and incorporated suggestion by Erik Olieman
@@ -18,7 +22,7 @@
 
 #include "mbed.h"
 
-DigitalOut LED[] = {(P0_7), (P0_8), (P0_2), (P0_20), (P1_19), (P0_17), (P0_23)};// declare 7 LEDs
+DigitalOut LED[] = {(LED1), (LED2), (LED3), (LED4), (LED5), (LED6), (LED7)};// declare 7 LEDs
 
 InterruptIn ActionButton(P0_4);  // declare the input for the button (or for other single switch, such as movement switch). On mBuino P0.4 is close to GND
 AnalogIn RandomIn(P0_14); // use the random noise on this analog input to seed the random generator
@@ -231,13 +235,16 @@
         fButtonPressed=false;
         
         unsigned uTickStop=tWait.read_ms()+10000;
+        float ftDelay=0.01;
         while(!fButtonPressed)
         {   // flash the LEDS to show we wait for a roll call
-            SweepAllLeds(true, 0.01);
-            SweepAllLeds(false, 0.01);
+            SweepAllLeds(true, ftDelay);
+            SweepAllLeds(false, ftDelay);
 
             if(!fButtonPressed && tWait.read_ms()>uTickStop)
                 myPowerDown();   // enter power-down mode when waited for more than 10 seconds without button pressed
+            else
+                ftDelay=(10-((float)uTickStop-tWait.read_ms())/1000)/100;  // make the fast flashes slow down while closer to power down mode
         }
         fButtonPressed=false;
         
@@ -247,10 +254,16 @@
         fButtonPressed=false;
         
         uTickStop=tWait.read_ms()+10000;
+        ftDelay=0.01;
         while(!fButtonPressed && tWait.read_ms()<uTickStop)
-            //wait(0.1);
-            BlinkDiceLed(nDiceValue, 0.2, 0.01);  // to indicate waiting for a new roll, blink the thrown dice value...
+        {
+            BlinkDiceLed(nDiceValue, 0.2, ftDelay);  // to indicate waiting for a new roll, flash the thrown dice value...
+            ftDelay=(10-((float)uTickStop-tWait.read_ms())/1000)/100;  // make the fast flashes slow down while closer to power down mode
+        }
         SwitchAllLeds(false);
+
+        if(!fButtonPressed)
+            myPowerDown();   // enter power-down mode when waited for more than 10 seconds without button pressed
     }
 }
 
--- a/mbed.bld	Mon Sep 15 16:35:48 2014 +0000
+++ b/mbed.bld	Tue Sep 16 08:19:55 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/04dd9b1680ae
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file