Classic multi-tap touch device with enter key. Allows for multiple keys to be entered at once.
Dependencies: DebouncedEdgeIn USBDevice mbed
Fork of idd_hw2_martincowell_bicyclehid by
main.cpp
- Committer:
- JMarquis
- Date:
- 2015-09-14
- Revision:
- 1:6b9c38f0638d
- Parent:
- 0:913f85486ace
File content as of revision 1:6b9c38f0638d:
#include "mbed.h" #include "DebouncedEdgeIn.h" #include "USBMouseKeyboard.h" #include <iostream> #include <stdlib.h> #include <iostream> #include <time.h> int x = 0; int y = 0; int z = 0; int q = 0; int s = 0; int e = 0; int r = 0; int u = 0; DebouncedEdgeIn b0(D12); DebouncedEdgeIn b1(D11); DebouncedEdgeIn b2(D10); DebouncedEdgeIn b3(D9); DebouncedEdgeIn b4(D8); DebouncedEdgeIn b5(D7); DebouncedEdgeIn b6(D6); DebouncedEdgeIn b7(D5); DebouncedEdgeIn b8(D4); DebouncedEdgeIn b9(D3); // SPST Pushbutton demo using internal PullUp function // no external PullUp resistor needed // Pushbutton from D2 to GND. Serial pc(USBTX, USBRX); //To output in terminal: //ls /dev/tty.usbmodem* //determine port number XXXX for input below //screen /dev/tty.usbmodemXXXX 9600 //USBMouseKeyboard //USBMouseKeyboard key_mouse; //if(b0.read()&&b1.read()){ // pc.printf("a"); //key_mouse.printf("a"); //} void a(){ x = x+1; } void d(){ y = y+1; } void g(){ z = z+1; } void j(){ q = q+1; } void m(){ s= s+1; } void p(){ e = e+1; } void t(){ r = r+1; } void w(){ u = u+1; } void space(){ pc.printf(" "); } void del(){ if (x == 1) { pc.printf("a"); } if (x == 2) { pc.printf("b"); } if (x == 3) { pc.printf("c"); } x = 0; if (y == 1) { pc.printf("d"); } if (y == 2) { pc.printf("e"); } if (y == 3) { pc.printf("f"); } y = 0; if (z == 1) { pc.printf("g"); } if (z == 2) { pc.printf("h"); } if (z == 3) { pc.printf("i"); } z = 0; if (q == 1) { pc.printf("j"); } if (q == 2) { pc.printf("k"); } if (q == 3) { pc.printf("l"); } q = 0; if (s == 1) { pc.printf("m"); } if (s == 2) { pc.printf("n"); } if (s == 3) { pc.printf("o"); } s = 0; if (e == 1) { pc.printf("p"); } if (e == 2) { pc.printf("q"); } if (e == 3) { pc.printf("r"); } if (e == 4) { pc.printf("s"); } e = 0; if (r == 1) { pc.printf("t"); } if (r == 2) { pc.printf("u"); } if (r == 3) { pc.printf("v"); } r = 0; if (u == 1) { pc.printf("w"); } if (u == 2) { pc.printf("x"); } if (u == 3) { pc.printf("y"); } if (u == 4) { pc.printf("z"); } u = 0; } int main() { b0.mode(PullUp); b1.mode(PullUp); b2.mode(PullUp); b3.mode(PullUp); b4.mode(PullUp); b5.mode(PullUp); b6.mode(PullUp); b7.mode(PullUp); b8.mode(PullUp); b9.mode(PullUp); b1.fall(&a); b2.fall(&d); b3.fall(&g); b4.fall(&j); b5.fall(&m); b6.fall(&p); b7.fall(&t); b8.fall(&w); b9.fall(&space); b0.fall(&del); // cout<<x<<endl; pc.printf("Initialized\r\n"); //key_mouse.printf("Initialized\r\n"); while(1) { // } } } // std::chrono::seconds interval( 10 ) ; // 10 seconds // for( int i = 0 ; i < 10 ; ++i ) // { // std::cout << "tick!\n" << std::flush ; // std::this_thread::sleep_for( interval ) ; // }