ChordJoy is a keyboard application that accepts chordal input from a set of digital ports, outputting letters and the chords that correspond to the piano keyboard keys the user has pressed.
Dependencies: PinDetect_KL25Z mbed-rtos mbed
Revision 2:49e2b1273f16, committed 2014-09-20
- Comitter:
- andrewhead
- Date:
- Sat Sep 20 21:19:25 2014 +0000
- Parent:
- 1:b6b866a58a87
- Child:
- 3:ed89297af2ce
- Commit message:
- Measure time on seconds resolution
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Sep 20 19:57:18 2014 +0000 +++ b/main.cpp Sat Sep 20 21:19:25 2014 +0000 @@ -9,15 +9,16 @@ // Flag that says whether we're waiting to collect input from other buttons // following one upward edge. bool flag = false; +time_t startSeconds = time(NULL); InterruptIn buttons [BUTTONS] = { + InterruptIn(D2), InterruptIn(D4), InterruptIn(D5), InterruptIn(D8), InterruptIn(D9), InterruptIn(D10), - InterruptIn(D11), - InterruptIn(D2) + InterruptIn(D11) }; Serial pc(USBTX, USBRX); @@ -110,6 +111,8 @@ void waitForChord(void) { /* Should be run in the main loop so that it can print */ while (true) { + time_t currentSeconds = time(NULL); + time_t secondsPast = currentSeconds - startSeconds; if (flag == true) { pc.printf("Pressed\n"); flag = false; @@ -117,6 +120,7 @@ else { pc.printf("Not pressed\n"); } + pc.printf("Seconds: %d\n", secondsPast); wait_ms(500); } }