![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Early commits of my project
Dependencies: mbed Gamepad N5110
Diff: main.cpp
- Revision:
- 5:f09602591ad3
- Parent:
- 4:e7215819c9bc
- Child:
- 6:6294bf4eafc8
--- a/main.cpp Tue Mar 12 09:45:03 2019 +0000 +++ b/main.cpp Wed Mar 13 15:23:03 2019 +0000 @@ -3,7 +3,7 @@ #include "Gamepad.h" Gamepad pad; -N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); +N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); AnalogIn pot0(PTB2); int x = 0; @@ -15,11 +15,11 @@ init(); while (1) { - + contrast(); minerbitmap(); } - + } void init() @@ -28,17 +28,17 @@ lcd.normalMode(); // normal colour mode lcd.setBrightness(0.5); // put LED backlight on 50% lcd.refresh(); - Gamepad gamepad; - gamepad.leds_off(); + pad.init(); + pad.leds_off(); } void contrast() -{ +{ lcd.refresh(); float con = pot0.read(); lcd.setContrast(con); - - + + } void minerbitmap() @@ -57,33 +57,45 @@ 0,1,0,1,0, 0,1,1,1,1, }; - + lcd.clear(); - - Gamepad gamepad; - Direction d = gamepad.get_direction(); - printf("Direction = %i\n",d); + + + Direction d = pad.get_direction(); + printf("Direction = %i\n",d); + + lcd.drawSprite(WIDTH/2 + x,HEIGHT/2 + y,13,5,(int *)miner); + + + if (d==3) { - - - - if (d==1){ - lcd.clear(); - x = x+1; - lcd.drawSprite(WIDTH/2 + x,HEIGHT/2 + y,13,5,(int *)miner); - lcd.refresh(); - wait(0.25); + x = x+1; + lcd.refresh(); + wait(0.05); + + } + + if (d == 7) { + + x = x-1; + lcd.refresh(); + wait(0.05); + } + //lcd.drawSprite(WIDTH/2 + x,HEIGHT/2 + y,13,5,(int *)miner); + //lcd.refresh(); + + if(pad.check_event(Gamepad::A_PRESSED)) { - } - - if (d == 7){ - lcd.clear(); - x = x-1; - lcd.drawSprite(WIDTH/2 + x,HEIGHT/2 + y,13,5,(int *)miner); - lcd.refresh(); - wait(0.25); - } - lcd.drawSprite(WIDTH/2 + x,HEIGHT/2 + y,13,5,(int *)miner); - lcd.refresh(); - } \ No newline at end of file + printf("A pressed"); + y = y - 6; + lcd.clear(); + lcd.drawSprite(WIDTH/2 + x,HEIGHT/2 + y,13,5,(int *)miner); + lcd.refresh(); + wait(0.2); + y= y + 6; + } + + + +}