IDD Fall 2015
/
idd_hw2_gtfierro_keypad
Code for proj2
Fork of hw2 by
Revision 3:636bf7891502, committed 2015-09-12
- Comitter:
- gtfierro
- Date:
- Sat Sep 12 21:30:25 2015 +0000
- Parent:
- 2:6d08fd15d699
- Commit message:
- latest
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 6d08fd15d699 -r 636bf7891502 main.cpp --- a/main.cpp Wed Sep 09 19:27:53 2015 -0700 +++ b/main.cpp Sat Sep 12 21:30:25 2015 +0000 @@ -2,6 +2,9 @@ #include "PinDetect.h" #include "USBKeyboard.h" #include <string> +#include <ctype.h> + +USBKeyboard key; Serial pc(USBTX, USBRX); @@ -37,6 +40,7 @@ #define OFF 1 #define ON 0 + void initializePressed() { pressed[0] = 0; pressed[1] = 0; @@ -77,17 +81,18 @@ return; } if (upper) { - pc.putc(::toupper(x[0])); + pc.putc(toupper(x[0])); + key.putc(toupper(x[0])); } else { pc.putc(x[0]); + key.putc(x[0]); + } } void fillButton(int button) { if (pressed[0] != 0 && pressed[1] == 0) { pressed[1] = button; - deliverButton(); - initializePressed(); } else if (pressed[0] == 0) { pressed[0] = button; } else { @@ -105,8 +110,8 @@ void b8Pressed(void) { fillButton(8); } void b9Pressed(void) { fillButton(9); } -void shiftOn(void) { upper = true; } -void shiftOff(void) { upper = false; } +void shiftOn(void) { green = ON; upper = true; } +void shiftOff(void) { green = OFF; upper = false; } int main() { // turn off LED @@ -156,5 +161,10 @@ shift.attach_deasserted(&shiftOff); shift.setSampleFrequency(); - while(1) {} + while(1) { + if (pressed[0] != 0 && pressed[1] != 0) { + deliverButton(); + initializePressed(); + } + } }