Joe Roop
/
Bootcamp-Interrupt_Polling_Joystick_interesting
interesting
Fork of Bootcamp-Interrupt_Polling_Joystick by
Diff: main.cpp
- Revision:
- 4:9b1a6ddf5fee
- Parent:
- 3:27ec45bc9078
--- a/main.cpp Fri Oct 11 14:00:04 2013 +0000 +++ b/main.cpp Wed Apr 16 04:31:33 2014 +0000 @@ -28,19 +28,48 @@ #endif #include "mbed.h" +#include "C12832_lcd.h" //LCD interface BusIn joy(p15,p12,p13,p16); DigitalIn fire(p14); + BusOut leds(LED1,LED2,LED3,LED4); +C12832_LCD lcd; + +int btns[] = {0, 0, 0, 0}; +char* btns_names[]= {"TOP", "BOT", "LFT", "RGT"}; int main() { + int t; + lcd.locate(0,0); while(1) { if (fire) { leds=0xf; } else { leds=joy; + t = joy; + //add the switch settings + /* + btns[0] += (t&0x1 > 0) ? 1 : 0; + btns[1] += (t&0x2 > 0) ? 1 : 0; + btns[2] += (t&0x4 > 0) ? 1 : 0; + btns[3] += (t&0x8 > 0) ? 1 : 0; + */ + if(t&0x1 > 0) btns[0]+=1; + if(t&0x2 > 0) btns[1]+=1; + if(t&0x4 > 0) btns[2]+=1; + if(t&0x8 > 0) btns[3]+=1; + lcd.locate(0,0); //{"TOP", "BOT", "LFT", "RGT"}; + lcd.printf("%s: %2d %2d ", btns_names[0],t&0x1, btns[0]); + lcd.locate(70,0); + lcd.printf("%s: %2d %2d ", btns_names[1],t&0x2, btns[1]); + lcd.locate(0,10); + lcd.printf("%s: %2d %2d ", btns_names[2],t&0x4, btns[2]); + lcd.locate(70,10); + lcd.printf("%s: %2d %2d ", btns_names[3],t&0x8, btns[3]); + } wait(0.1); }