Dependencies: mbed FATFileSystem
main.cpp@2:81cfa8310f55, 2019-03-20 (annotated)
- Committer:
- ellisbhastroud
- Date:
- Wed Mar 20 18:23:22 2019 +0000
- Revision:
- 2:81cfa8310f55
- Parent:
- 1:6179c2d67d19
- Child:
- 3:a8960004d261
Main menu selection developed.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ellisbhastroud | 0:c6ceddb241df | 1 | /* |
ellisbhastroud | 0:c6ceddb241df | 2 | ELEC2645 Embedded Systems Project |
ellisbhastroud | 0:c6ceddb241df | 3 | School of Electronic & Electrical Engineering |
ellisbhastroud | 0:c6ceddb241df | 4 | University of Leeds |
ellisbhastroud | 0:c6ceddb241df | 5 | Name: Ellis Blackford Stroud |
ellisbhastroud | 0:c6ceddb241df | 6 | Username: el17ebs |
ellisbhastroud | 0:c6ceddb241df | 7 | Student ID Number: 201155309 |
ellisbhastroud | 1:6179c2d67d19 | 8 | Date: 09/05/19 |
ellisbhastroud | 0:c6ceddb241df | 9 | */ |
ellisbhastroud | 0:c6ceddb241df | 10 | #include "mbed.h" |
ellisbhastroud | 1:6179c2d67d19 | 11 | #include "Gamepad.h" |
ellisbhastroud | 1:6179c2d67d19 | 12 | #include "N5110.h" |
ellisbhastroud | 1:6179c2d67d19 | 13 | #include "Menu.h" |
ellisbhastroud | 0:c6ceddb241df | 14 | |
ellisbhastroud | 1:6179c2d67d19 | 15 | // objects |
ellisbhastroud | 1:6179c2d67d19 | 16 | N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); |
ellisbhastroud | 1:6179c2d67d19 | 17 | Gamepad pad; |
ellisbhastroud | 2:81cfa8310f55 | 18 | Menu menu; |
ellisbhastroud | 2:81cfa8310f55 | 19 | |
ellisbhastroud | 2:81cfa8310f55 | 20 | void init(); |
ellisbhastroud | 0:c6ceddb241df | 21 | |
ellisbhastroud | 0:c6ceddb241df | 22 | int main() |
ellisbhastroud | 0:c6ceddb241df | 23 | { |
ellisbhastroud | 1:6179c2d67d19 | 24 | init(); |
ellisbhastroud | 2:81cfa8310f55 | 25 | lcd.clear(); |
ellisbhastroud | 2:81cfa8310f55 | 26 | menu.print_welcome(lcd); |
ellisbhastroud | 2:81cfa8310f55 | 27 | lcd.refresh(); |
ellisbhastroud | 1:6179c2d67d19 | 28 | wait(3); |
ellisbhastroud | 2:81cfa8310f55 | 29 | menu.print_menu(lcd); |
ellisbhastroud | 2:81cfa8310f55 | 30 | lcd.refresh(); |
ellisbhastroud | 2:81cfa8310f55 | 31 | |
ellisbhastroud | 2:81cfa8310f55 | 32 | //cursor begins on start |
ellisbhastroud | 2:81cfa8310f55 | 33 | MenuChoices m = START; |
ellisbhastroud | 2:81cfa8310f55 | 34 | |
ellisbhastroud | 2:81cfa8310f55 | 35 | while(1) { |
ellisbhastroud | 2:81cfa8310f55 | 36 | |
ellisbhastroud | 2:81cfa8310f55 | 37 | m = menu.menu_choice(m, pad, lcd); |
ellisbhastroud | 2:81cfa8310f55 | 38 | int d = pad.get_direction(); |
ellisbhastroud | 2:81cfa8310f55 | 39 | |
ellisbhastroud | 2:81cfa8310f55 | 40 | printf("menu choice = %i direction = %i \n" , m, d); |
ellisbhastroud | 2:81cfa8310f55 | 41 | lcd.refresh(); |
ellisbhastroud | 2:81cfa8310f55 | 42 | wait(0.1); |
ellisbhastroud | 2:81cfa8310f55 | 43 | |
ellisbhastroud | 2:81cfa8310f55 | 44 | } |
ellisbhastroud | 1:6179c2d67d19 | 45 | } |
ellisbhastroud | 1:6179c2d67d19 | 46 | |
ellisbhastroud | 1:6179c2d67d19 | 47 | void init() |
ellisbhastroud | 1:6179c2d67d19 | 48 | { |
ellisbhastroud | 1:6179c2d67d19 | 49 | lcd.init(); |
ellisbhastroud | 2:81cfa8310f55 | 50 | lcd.setContrast(0.5); |
ellisbhastroud | 1:6179c2d67d19 | 51 | pad.init(); |
ellisbhastroud | 1:6179c2d67d19 | 52 | } |