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: mbed
Diff: main.cpp
- Revision:
- 2:421fb0670c5c
- Parent:
- 0:4d3c9411e8f2
- Child:
- 3:1a134243e2f0
--- a/main.cpp Mon Mar 05 09:39:56 2018 +0000 +++ b/main.cpp Thu Apr 12 22:46:30 2018 +0000 @@ -1,13 +1,77 @@ #include "mbed.h" +#include "stdio.h" +#include "stdlib.h" +#include "Gamepad.h" +#include "N5110.h" +#include "rect.h" +#include "engine.h" DigitalOut gpo(D0); DigitalOut led(LED_RED); + +N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); +Gamepad pad; +engine rect; + +void init(); +void welcome(); +void render(); + + + int main() { - while (true) { - gpo = !gpo; // toggle pin - led = !led; // toggle led - wait(0.2f); + + int fps = 10; + + init(); + welcome(); + + //lcd.clear(); + //lcd.refresh(); + + render(); + wait(1.0f/fps); + +while(1){ + + rect.read_input(pad); + rect.update(pad); + render(); + + wait(1.0f/fps); + } + +} + +void init() +{ + // need to initialise LCD and Gamepad + lcd.init(); + pad.init(); + + +} +void welcome() { + + lcd.printString(" TXZ ",0,1); + lcd.printString(" Press Start ",0,4); + lcd.refresh(); + + // wait flashing LEDs until start button is pressed + while ( pad.check_event(Gamepad::START_PRESSED) == false) { + pad.leds_on(); + wait(0.1); + pad.leds_off(); + wait(0.1); } -} \ No newline at end of file + } + +void render() +{ + // clear screen, re-draw and refresh + lcd.clear(); + rect.draw(lcd); + lcd.refresh(); +}