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
Revision 1:6b9c38f0638d, committed 2015-09-14
- Comitter:
- JMarquis
- Date:
- Mon Sep 14 16:32:56 2015 +0000
- Parent:
- 0:913f85486ace
- Commit message:
- Classic multi-tap touch device with enter key. Allows for multiple keys to be entered at once.
Changed in this revision
USBDevice.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 913f85486ace -r 6b9c38f0638d USBDevice.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice.lib Mon Sep 14 16:32:56 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/USBDevice/#2af474687369
diff -r 913f85486ace -r 6b9c38f0638d main.cpp --- a/main.cpp Mon Sep 22 15:59:43 2014 +0000 +++ b/main.cpp Mon Sep 14 16:32:56 2015 +0000 @@ -1,21 +1,32 @@ #include "mbed.h" #include "DebouncedEdgeIn.h" #include "USBMouseKeyboard.h" - -DigitalOut myled1(LED_RED,1); -DigitalOut myled2(LED_GREEN,1); -DigitalOut myled3(LED_BLUE,1); +#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; -DigitalIn b0(D13); -DigitalIn b1(D7); -DebouncedEdgeIn b2(D9); -DebouncedEdgeIn b3(D10); -DebouncedEdgeIn b4(D11); -DebouncedEdgeIn b5(D12); -DebouncedEdgeIn b6(D3); -DebouncedEdgeIn b7(D4); -DebouncedEdgeIn b8(D5); -DebouncedEdgeIn b9(D6); + + + +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 @@ -28,145 +39,136 @@ //USBMouseKeyboard //USBMouseKeyboard key_mouse; - -void a(){ - if(b0.read()&&b1.read()){ - pc.printf("a"); +//if(b0.read()&&b1.read()){ + // pc.printf("a"); //key_mouse.printf("a"); - } - if(!b0.read()&&b1.read()){ - pc.printf("h"); - //key_mouse.printf("h"); - } - if(b0.read()&&!b1.read()){ - pc.printf("o"); - //key_mouse.printf("o"); - } - if(!b0.read()&&!b1.read()){ - pc.printf("v"); - //key_mouse.printf("v"); - } -} + //} + + -void b(){ - if(b0.read()&&b1.read()){ - pc.printf("b"); - //key_mouse.printf("b"); - } - if(!b0.read()&&b1.read()){ - pc.printf("i"); - //key_mouse.printf("i"); - } - if(b0.read()&&!b1.read()){ - pc.printf("p"); - //key_mouse.printf("p"); - } - if(!b0.read()&&!b1.read()){ - pc.printf("w"); - //key_mouse.printf("w"); - } -} + -void c(){ - if(b0.read()&&b1.read()){ - pc.printf("c"); - //key_mouse.printf("cat"); - } - if(!b0.read()&&b1.read()){ - pc.printf("j"); - //key_mouse.printf("j"); - } - if(b0.read()&&!b1.read()){ - pc.printf("q"); - //key_mouse.printf("q"); - } - if(!b0.read()&&!b1.read()){ - pc.printf("x"); - //key_mouse.printf("x"); - } + + +void a(){ + x = x+1; } - void d(){ - if(b0.read()&&b1.read()){ - pc.printf("d"); - //key_mouse.printf("d"); - } - if(!b0.read()&&b1.read()){ - pc.printf("k"); - //key_mouse.printf("k"); - } - if(b0.read()&&!b1.read()){ - pc.printf("r"); - //key_mouse.printf("r"); - } - if(!b0.read()&&!b1.read()){ - pc.printf("y"); - //key_mouse.printf("y"); - } + y = y+1; + } +void g(){ + z = z+1; } - -void e(){ - if(b0.read()&&b1.read()){ - pc.printf("e"); - //key_mouse.printf("e"); - } - if(!b0.read()&&b1.read()){ - pc.printf("l"); - //key_mouse.printf("l"); - } - if(b0.read()&&!b1.read()){ - pc.printf("s"); - //key_mouse.printf("s"); - } - if(!b0.read()&&!b1.read()){ - pc.printf("z"); - //key_mouse.printf("z"); - } +void j(){ + q = q+1; } - -void f(){ - if(b0.read()&&b1.read()){ - pc.printf("f"); - //key_mouse.printf("f"); - } - if(!b0.read()&&b1.read()){ - pc.printf("m"); - //key_mouse.printf("m"); - } - if(b0.read()&&!b1.read()){ - pc.printf("t"); - //key_mouse.printf("t"); - } - if(!b0.read()&&!b1.read()){ - pc.printf("!"); - //key_mouse.printf("!"); - } +void m(){ + s= s+1; +} +void p(){ + e = e+1; } - -void g(){ - if(b0.read()&&b1.read()){ - pc.printf("g"); - //key_mouse.printf("g"); - } - if(!b0.read()&&b1.read()){ - pc.printf("n"); - //key_mouse.printf("n"); - } - if(b0.read()&&!b1.read()){ - pc.printf("u"); - //key_mouse.printf("u"); - } - if(!b0.read()&&!b1.read()){ - pc.printf("?"); - //key_mouse.printf("?"); - } +void t(){ + r = r+1; +} +void w(){ + u = u+1; } void space(){ - pc.printf(" "); - //key_mouse.printf(" "); + 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); @@ -178,24 +180,32 @@ b8.mode(PullUp); b9.mode(PullUp); - b2.fall(&a); - b3.fall(&b); - b4.fall(&c); - b5.fall(&d); - b6.fall(&e); - b7.fall(&f); - b8.fall(&g); + 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) { - myled1 = b2; - myled2 = b3; - myled3 = b4; - //if(!b0){ -// key_mouse.printf("zz"); + while(1) { + + // } } -} \ No newline at end of file +} + + + + // 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 ) ; + // } \ No newline at end of file