Charles Tritt
/
21_SerialPass_v5
New example. Initial version.
main.cpp@115:6ba84689e2c9, 2021-10-13 (annotated)
- Committer:
- CSTritt
- Date:
- Wed Oct 13 13:08:42 2021 +0000
- Revision:
- 115:6ba84689e2c9
- Parent:
- 114:1cfad1babb55
- Child:
- 116:8990686eedf5
Not working. Causes runtime error.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
CSTritt | 107:61b9c99a4e27 | 1 | /* |
CSTritt | 115:6ba84689e2c9 | 2 | Project: 21_TimeSense_v5 |
CSTritt | 109:b061f9830736 | 3 | File: main.cpp |
CSTritt | 111:956b1c606b66 | 4 | |
CSTritt | 115:6ba84689e2c9 | 5 | A simple time sense game. |
CSTritt | 114:1cfad1babb55 | 6 | |
CSTritt | 114:1cfad1babb55 | 7 | Uses VT-100 escape sequences to prevent scrolling. See |
CSTritt | 114:1cfad1babb55 | 8 | http://www.csie.ntu.edu.tw/~r92094/c++/VT100.html and/or |
CSTritt | 113:cc5beacdad5a | 9 | https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797. |
CSTritt | 114:1cfad1babb55 | 10 | |
CSTritt | 115:6ba84689e2c9 | 11 | Written by: Dr. C. S. Tritt; Last revised 10/13/21 (v. 1.1) |
CSTritt | 107:61b9c99a4e27 | 12 | */ |
Jonathan Austin |
0:2757d7abb7d9 | 13 | #include "mbed.h" |
CSTritt | 115:6ba84689e2c9 | 14 | #include "myFuncs.h" |
CSTritt | 115:6ba84689e2c9 | 15 | // Construct a USER_BUTTON digital input. |
CSTritt | 115:6ba84689e2c9 | 16 | DigitalIn myButton(USER_BUTTON); |
CSTritt | 115:6ba84689e2c9 | 17 | // Construct a timer object. |
CSTritt | 115:6ba84689e2c9 | 18 | Timer myTimer; |
CSTritt | 115:6ba84689e2c9 | 19 | // Construct a transmit only serial connection over our USB. |
CSTritt | 115:6ba84689e2c9 | 20 | Serial pc(USBTX, NC, 9600); |
CSTritt | 108:eee3167b25b4 | 21 | |
CSTritt | 114:1cfad1babb55 | 22 | int main() |
CSTritt | 114:1cfad1babb55 | 23 | { |
CSTritt | 115:6ba84689e2c9 | 24 | const int TARGET = 5000; // Target time in mS. |
CSTritt | 115:6ba84689e2c9 | 25 | const int TRIALS = 3; // Number of trials (cycles). |
CSTritt | 115:6ba84689e2c9 | 26 | int rSum = 0; // Running sum for average in mS. |
CSTritt | 111:956b1c606b66 | 27 | |
CSTritt | 115:6ba84689e2c9 | 28 | clrTerm(&pc); // Clear the terminal. |
CSTritt | 115:6ba84689e2c9 | 29 | pc.printf("Hold button down for %f seconds.\n", |
CSTritt | 115:6ba84689e2c9 | 30 | static_cast<float>(TARGET)/1000.f); |
CSTritt | 114:1cfad1babb55 | 31 | |
CSTritt | 114:1cfad1babb55 | 32 | |
CSTritt | 114:1cfad1babb55 | 33 | while(true) { // Main forever loop. |
CSTritt | 115:6ba84689e2c9 | 34 | ThisThread::sleep_for(300000); // Sleep for 5 minutes, repeatedly. |
CSTritt | 108:eee3167b25b4 | 35 | } |
CSTritt | 113:cc5beacdad5a | 36 | } |