Early commits of my project
Dependencies: mbed Gamepad N5110
Diff: main.cpp
- Revision:
- 3:140cad440684
- Parent:
- 2:ba653520a140
- Child:
- 4:e7215819c9bc
diff -r ba653520a140 -r 140cad440684 main.cpp --- a/main.cpp Mon Mar 11 22:46:54 2019 +0000 +++ b/main.cpp Tue Mar 12 00:21:58 2019 +0000 @@ -1,14 +1,11 @@ #include "main.h" #include "N5110.h" -#include "Joystick.h" +#include "Gamepad.h" +Gamepad pad; N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); -Joystick joystick(PTB10,PTB11,PTC16); AnalogIn pot0(PTB2); -DigitalIn joy_button(PTC16); BusOut front_leds(PTA1,PTA2,PTC2,PTC3,PTC4, PTD3); -DigitalIn jump(PTC16); -DigitalIn jumpa(PTB9); int x = 0; int y = 0; @@ -17,15 +14,12 @@ int main() { init(); - minerbitmap(); - - - - + while (1) { contrast(); minerbitmap(); + } } @@ -37,7 +31,6 @@ lcd.setBrightness(0.5); // put LED backlight on 50% lcd.refresh(); - joystick.init(); front_leds = 0b111111; } @@ -68,11 +61,14 @@ lcd.clear(); + Gamepad gamepad; + Direction d = gamepad.get_direction(); + printf("Direction = %i\n",d); + - Direction d = joystick.get_direction(); - printf("Direction = %i\n",d); + - if (d==3){ + if (d==1){ lcd.clear(); x = x+1; lcd.drawSprite(WIDTH/2 + x,HEIGHT/2 + y,13,5,(int *)miner); @@ -89,18 +85,6 @@ lcd.refresh(); wait(0.25); } - if (jump == 1) - { - lcd.clear(); - - printf("Button Pressed\n"); - y = y -5; - wait(0.1); - lcd.refresh(); - } - else { - y = 0; - } lcd.drawSprite(WIDTH/2 + x,HEIGHT/2 + y,13,5,(int *)miner); lcd.refresh(); } \ No newline at end of file