Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: N5110 PowerControl mbed
Diff: main.cpp
- Revision:
- 12:3f4d9cb7dd8a
- Parent:
- 11:2fd81f59d7a7
- Child:
- 13:098319060433
--- a/main.cpp Thu Apr 23 14:01:36 2015 +0000 +++ b/main.cpp Mon Apr 27 12:17:32 2015 +0000 @@ -5,14 +5,15 @@ BusOut myleds(p24,p23,p22); //External LEDS InterruptIn StartButton(p18);//Start button N5110 lcd(p7,p8,p9,p10,p11,p13,p26); //PWR, SCE, RST, DC, MOSI, SCLK, LED -AnalogIn Bright(p20);//Pot to adjust brightness +AnalogIn bright(p20);//Pot to adjust brightness Ticker timer; //Create ticker object -DigitalIn button(p17);// Joystick Button +DigitalIn Jbutton(p17);// Joystick Button AnalogIn xPot(p15);// Joystick x-direction AnalogIn yPot(p16);// Joystick y-direction int i=3; // Pacman's starting position int j = 3; - +int buttonflag=0; // flag for pause button +InterruptIn button(p18);//Pause button Ticker pollJoystick; // timer to regularly read the joystick int coinflag = 1; @@ -85,15 +86,41 @@ } else if ( joystick.y < DIRECTION_TOLERANCE && fabs(joystick.x) < DIRECTION_TOLERANCE) { joystick.direction = DOWN; } else if ( joystick.x > DIRECTION_TOLERANCE && fabs(joystick.y) < DIRECTION_TOLERANCE) { - joystick.direction = RIGHT; + joystick.direction = LEFT; } else if ( joystick.x < DIRECTION_TOLERANCE && fabs(joystick.y) < DIRECTION_TOLERANCE) { - joystick.direction = LEFT; + joystick.direction = RIGHT; } else { joystick.direction = UNKNOWN; } } + +void pressPause() +{ + buttonflag=!buttonflag;// set button flag +} + +void pause() +{ + button.rise(&pressPause); // event generated on rising edge + while (buttonflag){ + lcd.clear(); + lcd.printString("Pause", 25,21); + + + + + + + } + + + + + +} + void drawMap() { @@ -537,9 +564,11 @@ lcd.init(); calibrateJoystick(); // get centred values of joystick pollJoystick.attach(&updateJoystick,1.0/10.0); // read joystick 10 times per second - + while(1) { + lcd.setBrightness(bright); lcd.clear(); + pause(); drawPacman(); drawMap(); drawCoin();