![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Code for proj2
Fork of hw2 by
Diff: main.cpp
- Revision:
- 3:636bf7891502
- Parent:
- 1:33d22b2c88ad
--- 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(); + } + } }