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
main.cpp@42:ee13e1d103d8, 2019-05-08 (annotated)
- Committer:
- ikenna1
- Date:
- Wed May 08 11:18:40 2019 +0000
- Revision:
- 42:ee13e1d103d8
- Parent:
- 41:e1fa36c0492e
Change the way Lcd and Gamepad libraries are accessed for ease of documentation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ikenna1 | 0:0d446aab48a6 | 1 | /* |
ikenna1 | 0:0d446aab48a6 | 2 | ELEC2645 Embedded Systems Project |
ikenna1 | 0:0d446aab48a6 | 3 | School of Electronic & Electrical Engineering |
ikenna1 | 0:0d446aab48a6 | 4 | University of Leeds |
ikenna1 | 0:0d446aab48a6 | 5 | Name: Ikenna Adrian Ozoemena |
ikenna1 | 0:0d446aab48a6 | 6 | Username: el17aio |
ikenna1 | 0:0d446aab48a6 | 7 | Student ID Number: 201157039 |
ikenna1 | 0:0d446aab48a6 | 8 | Date: 20/02/2019 |
ikenna1 | 1:9835d6304284 | 9 | */ |
ikenna1 | 1:9835d6304284 | 10 | |
ikenna1 | 42:ee13e1d103d8 | 11 | #include "main.h" |
ikenna1 | 3:f9cd1a38d5c6 | 12 | |
ikenna1 | 3:f9cd1a38d5c6 | 13 | //_______________functions______________________________________________________ |
ikenna1 | 3:f9cd1a38d5c6 | 14 | int main() |
ikenna1 | 3:f9cd1a38d5c6 | 15 | { |
ikenna1 | 10:c33d7593a275 | 16 | int fps = 12; |
ikenna1 | 10:c33d7593a275 | 17 | init(); |
ikenna1 | 9:241a1a7d8527 | 18 | printf("Init function completed...\n"); |
ikenna1 | 3:f9cd1a38d5c6 | 19 | |
ikenna1 | 10:c33d7593a275 | 20 | while(1) { |
ikenna1 | 10:c33d7593a275 | 21 | welcome(); |
ikenna1 | 35:3341f2bd0408 | 22 | printf("welcome()\n"); |
ikenna1 | 27:f99249e727fd | 23 | rosen.reset(); |
ikenna1 | 35:3341f2bd0408 | 24 | printf("reset()\n"); |
ikenna1 | 13:e114d362186d | 25 | //printf("ycursor = %d",rosen.get_ycursor()); |
ikenna1 | 10:c33d7593a275 | 26 | |
ikenna1 | 13:e114d362186d | 27 | if(rosen.get_ycursor() == 16) { |
ikenna1 | 36:c25417f0d150 | 28 | // printf("get_ycursor() == 16()\n"); |
ikenna1 | 38:4571537238ed | 29 | while ( pad.check_event(Gamepad::BACK_PRESSED) == false && rosen.dead() == false) { |
ikenna1 | 10:c33d7593a275 | 30 | // printf("play...\n"); |
ikenna1 | 42:ee13e1d103d8 | 31 | rosen.read_input(); |
ikenna1 | 35:3341f2bd0408 | 32 | // printf("read_input\n"); |
ikenna1 | 42:ee13e1d103d8 | 33 | rosen.update(); |
ikenna1 | 35:3341f2bd0408 | 34 | // printf("update\n"); |
ikenna1 | 10:c33d7593a275 | 35 | render(); |
ikenna1 | 35:3341f2bd0408 | 36 | // printf("render()\n"); |
ikenna1 | 10:c33d7593a275 | 37 | wait(1.0f/fps); |
ikenna1 | 38:4571537238ed | 38 | rosen.timer(fps); |
ikenna1 | 10:c33d7593a275 | 39 | } |
ikenna1 | 10:c33d7593a275 | 40 | } |
ikenna1 | 13:e114d362186d | 41 | if(rosen.get_ycursor() == 24) { |
ikenna1 | 10:c33d7593a275 | 42 | while ( pad.check_event(Gamepad::BACK_PRESSED) == false) { |
ikenna1 | 42:ee13e1d103d8 | 43 | rosen.read_input(); |
ikenna1 | 42:ee13e1d103d8 | 44 | rosen.update(); |
ikenna1 | 12:47578eb9ea73 | 45 | ship_select(); |
ikenna1 | 12:47578eb9ea73 | 46 | wait(1.0f/fps); |
ikenna1 | 21:628fb703188f | 47 | printf("ship = %d\n",rosen.get_shipno()); |
ikenna1 | 10:c33d7593a275 | 48 | // printf("menu...\n"); |
ikenna1 | 10:c33d7593a275 | 49 | } |
ikenna1 | 9:241a1a7d8527 | 50 | } |
ikenna1 | 3:f9cd1a38d5c6 | 51 | } |
ikenna1 | 3:f9cd1a38d5c6 | 52 | } |
ikenna1 | 1:9835d6304284 | 53 | |
ikenna1 | 3:f9cd1a38d5c6 | 54 | void init() |
ikenna1 | 3:f9cd1a38d5c6 | 55 | { |
ikenna1 | 3:f9cd1a38d5c6 | 56 | // need to initialise LCD and Gamepad |
ikenna1 | 3:f9cd1a38d5c6 | 57 | lcd.init(); |
ikenna1 | 3:f9cd1a38d5c6 | 58 | pad.init(); |
ikenna1 | 42:ee13e1d103d8 | 59 | rosen.init(9,6,3,42,41,&lcd,&pad); |
ikenna1 | 35:3341f2bd0408 | 60 | printf("Initializing...\n"); |
ikenna1 | 3:f9cd1a38d5c6 | 61 | |
ikenna1 | 3:f9cd1a38d5c6 | 62 | } |
ikenna1 | 9:241a1a7d8527 | 63 | void render() |
ikenna1 | 9:241a1a7d8527 | 64 | { |
ikenna1 | 9:241a1a7d8527 | 65 | // clear screen, re-draw and refresh |
ikenna1 | 9:241a1a7d8527 | 66 | lcd.clear(); |
ikenna1 | 42:ee13e1d103d8 | 67 | rosen.draw(); |
ikenna1 | 9:241a1a7d8527 | 68 | rosen.get_pos(); |
ikenna1 | 9:241a1a7d8527 | 69 | lcd.refresh(); |
ikenna1 | 35:3341f2bd0408 | 70 | // printf("Rendering...\n"); |
ikenna1 | 9:241a1a7d8527 | 71 | } |
ikenna1 | 12:47578eb9ea73 | 72 | void ship_select() |
ikenna1 | 12:47578eb9ea73 | 73 | { |
ikenna1 | 12:47578eb9ea73 | 74 | lcd.clear(); |
ikenna1 | 42:ee13e1d103d8 | 75 | rosen.ship_select(); |
ikenna1 | 12:47578eb9ea73 | 76 | rosen.get_pos(); |
ikenna1 | 12:47578eb9ea73 | 77 | lcd.refresh(); |
ikenna1 | 35:3341f2bd0408 | 78 | printf("Ship Select...\n"); |
ikenna1 | 12:47578eb9ea73 | 79 | } |
ikenna1 | 3:f9cd1a38d5c6 | 80 | |
ikenna1 | 3:f9cd1a38d5c6 | 81 | // simple splash screen displayed on start-up |
ikenna1 | 3:f9cd1a38d5c6 | 82 | void welcome() |
ikenna1 | 3:f9cd1a38d5c6 | 83 | { |
ikenna1 | 42:ee13e1d103d8 | 84 | printf("welcome...\n"); |
ikenna1 | 18:2cc6898de6b2 | 85 | while( pad.check_event(Gamepad::START_PRESSED) == false) { |
ikenna1 | 42:ee13e1d103d8 | 86 | printf("while lopp...\n"); |
ikenna1 | 30:711d722f3cef | 87 | lcd.clear(); |
ikenna1 | 42:ee13e1d103d8 | 88 | lcd.refresh(); |
ikenna1 | 42:ee13e1d103d8 | 89 | printf("lcd.clear...\n"); |
ikenna1 | 42:ee13e1d103d8 | 90 | rosen.title(); |
ikenna1 | 42:ee13e1d103d8 | 91 | printf("rosen.tittle.\n"); |
ikenna1 | 42:ee13e1d103d8 | 92 | rosen.read_input(); |
ikenna1 | 9:241a1a7d8527 | 93 | lcd.refresh(); |
ikenna1 | 9:241a1a7d8527 | 94 | } |
ikenna1 | 9:241a1a7d8527 | 95 | printf("Welcome Function completed...\n"); |
ikenna1 | 3:f9cd1a38d5c6 | 96 | } |