Norbert S / Mbed 2 deprecated joykey

Dependencies:   mbed

Committer:
norberts
Date:
Sat Nov 19 18:18:21 2011 +0000
Revision:
2:1a24252c8cb1
Parent:
1:afc3bf972645
Child:
3:13401b125368
changed pins for hard wired version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
norberts 0:207850946233 1 #include "mbed.h"
norberts 0:207850946233 2 #include "usbhid.h"
norberts 0:207850946233 3
norberts 0:207850946233 4 DigitalOut l1(LED1),l2(LED2);
norberts 0:207850946233 5
norberts 0:207850946233 6 Serial pc(USBTX, USBRX); // tx, rx
norberts 2:1a24252c8cb1 7 BusIn bus(p21,p23,p24,p25,p26);
norberts 0:207850946233 8 usbhid usb;
norberts 0:207850946233 9
norberts 2:1a24252c8cb1 10 char k[]={' ','w','s','a','d'}; //fudlr
norberts 2:1a24252c8cb1 11
norberts 2:1a24252c8cb1 12 int main() {
norberts 2:1a24252c8cb1 13 int i,b,lb=0,s;
norberts 2:1a24252c8cb1 14
norberts 0:207850946233 15 pc.printf("I live! Again ...\r");
norberts 2:1a24252c8cb1 16
norberts 2:1a24252c8cb1 17 while (1) {
norberts 0:207850946233 18 wait(.01);
norberts 0:207850946233 19 l1=!l1;
norberts 2:1a24252c8cb1 20 b=bus.read();
norberts 2:1a24252c8cb1 21
norberts 2:1a24252c8cb1 22 if (b!=lb) {
norberts 1:afc3bf972645 23 l2=1;
norberts 2:1a24252c8cb1 24 if (b) {
norberts 2:1a24252c8cb1 25 for (i=0; i<5; i++) {
norberts 2:1a24252c8cb1 26 s=(b&(1<<i))!=0;
norberts 2:1a24252c8cb1 27 if (s)
norberts 2:1a24252c8cb1 28 usb.keyboard2(k[i]);
norberts 2:1a24252c8cb1 29 }
norberts 2:1a24252c8cb1 30 } else
norberts 2:1a24252c8cb1 31 usb.keyboard2(0);
norberts 2:1a24252c8cb1 32
norberts 2:1a24252c8cb1 33 lb=b;
norberts 2:1a24252c8cb1 34 } else
norberts 1:afc3bf972645 35 l2=0;
norberts 0:207850946233 36 }
norberts 2:1a24252c8cb1 37
norberts 0:207850946233 38 }