Serpentine
/
serpentine_timer
Timer 1.0
Revision 0:c3f34a51692c, committed 2016-06-07
- Comitter:
- danlock10y
- Date:
- Tue Jun 07 13:26:54 2016 +0000
- Commit message:
- Timer Version 1
Changed in this revision
diff -r 000000000000 -r c3f34a51692c TextLCD.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Tue Jun 07 13:26:54 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
diff -r 000000000000 -r c3f34a51692c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jun 07 13:26:54 2016 +0000 @@ -0,0 +1,46 @@ +//Timer for 2 player snake game +//2 line LCD implemented using TextLCD library + +#include "mbed.h" +#include "TextLCD.h" + +int GameRunning; //True if game is running +int c; //count variable +Timer timer; //Use mbed's built in timer function +float StartTime, NowTime; //Floats for the timer reading at gamestart and currently + +InterruptIn btnStart(PTA4); //Temporarily use switch to start - will be WiFi command +InterruptIn btnStop(PTA5); //Temporarily use switch to stop - will be WiFi command + + +void timerStart() { + timer.start(); + StartTime = timer.read_us(); + GameRunning = 1; +} + +void timerStop() { + timer.stop(); + NowTime = timer.read_us(); + GameRunning = 0; +} + + +TextLCD lcd(PTE30, PTE29, PTE23, PTE22, PTE21, PTE20); // rs, e, d4-d7 + +int main() +{ + btnStart.rise(&timerStart); + btnStop.rise(&timerStop); + //timer.start(); + //StartTime = timer.read_us(); + + while(1) + { + + NowTime = timer.read_us(); + lcd.printf("Time: %4.3f \n\n", (NowTime-StartTime)/1000000); + wait(0.05); + + } +}
diff -r 000000000000 -r c3f34a51692c mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Jun 07 13:26:54 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34 \ No newline at end of file