Zeitgeist / Mbed 2 deprecated GutenTaggz

Dependencies:   mbed

Committer:
vhsstar
Date:
Tue Dec 01 02:45:42 2015 +0000
Revision:
5:7d9a463f74ec
Child:
6:f87a568538b4
All the things

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vhsstar 5:7d9a463f74ec 1 #ifndef MENUSTATEMACHINE_H
vhsstar 5:7d9a463f74ec 2 #define MENUSTATEMACHINE_H
vhsstar 5:7d9a463f74ec 3
vhsstar 5:7d9a463f74ec 4 #include "AMC1602.h"
vhsstar 5:7d9a463f74ec 5 #include "Thumbstick.h"
vhsstar 5:7d9a463f74ec 6 #include "State.h"
vhsstar 5:7d9a463f74ec 7 #include "StateMachine.h"
vhsstar 5:7d9a463f74ec 8
vhsstar 5:7d9a463f74ec 9 #include "mbed.h"
vhsstar 5:7d9a463f74ec 10 //Forward declarations of functions so that each function can see other functions(?)
vhsstar 5:7d9a463f74ec 11 void startUp(void);
vhsstar 5:7d9a463f74ec 12
vhsstar 5:7d9a463f74ec 13 void mainMenu(void);
vhsstar 5:7d9a463f74ec 14
vhsstar 5:7d9a463f74ec 15 void readTag(void);
vhsstar 5:7d9a463f74ec 16 void writeTag(void);
vhsstar 5:7d9a463f74ec 17 void options(void);
vhsstar 5:7d9a463f74ec 18
vhsstar 5:7d9a463f74ec 19 //Declaring states with their respective functions
vhsstar 5:7d9a463f74ec 20 State StartUp(startUp);
vhsstar 5:7d9a463f74ec 21
vhsstar 5:7d9a463f74ec 22 State MainMenu(mainMenu);
vhsstar 5:7d9a463f74ec 23
vhsstar 5:7d9a463f74ec 24 State ReadTag(readTag);
vhsstar 5:7d9a463f74ec 25 State WriteTag(writeTag);
vhsstar 5:7d9a463f74ec 26 State Options(options);
vhsstar 5:7d9a463f74ec 27
vhsstar 5:7d9a463f74ec 28 //State machine with starting point
vhsstar 5:7d9a463f74ec 29 StateMachine Menu(&StartUp);
vhsstar 5:7d9a463f74ec 30
vhsstar 5:7d9a463f74ec 31 //Declaration of any globals blah
vhsstar 5:7d9a463f74ec 32 Thumbstick thumby(p20, p19, p17);
vhsstar 5:7d9a463f74ec 33 AMC1602 screen(p28, p27, 0x78);
vhsstar 5:7d9a463f74ec 34
vhsstar 5:7d9a463f74ec 35
vhsstar 5:7d9a463f74ec 36 //Implimentation of functions
vhsstar 5:7d9a463f74ec 37 void startUp(void)
vhsstar 5:7d9a463f74ec 38 {
vhsstar 5:7d9a463f74ec 39 screen.print("Start_Up________________________");
vhsstar 5:7d9a463f74ec 40 wait(1);
vhsstar 5:7d9a463f74ec 41 Menu.nextState = &MainMenu;
vhsstar 5:7d9a463f74ec 42 }
vhsstar 5:7d9a463f74ec 43
vhsstar 5:7d9a463f74ec 44 void mainMenu(void)
vhsstar 5:7d9a463f74ec 45 {
vhsstar 5:7d9a463f74ec 46 static int mainMenuValue = 0;
vhsstar 5:7d9a463f74ec 47 char *mainMenuOptions[3]={"Read_A_Tag_____>","Write_A_Tag____>","Options________>"};
vhsstar 5:7d9a463f74ec 48 State *nextStates[3] ={&ReadTag,&WriteTag,&Options};
vhsstar 5:7d9a463f74ec 49 thumby.update();
vhsstar 5:7d9a463f74ec 50 wait_ms(10);
vhsstar 5:7d9a463f74ec 51 if(thumby.down() == 1)
vhsstar 5:7d9a463f74ec 52 {
vhsstar 5:7d9a463f74ec 53 mainMenuValue = (mainMenuValue+1)%3;
vhsstar 5:7d9a463f74ec 54 }
vhsstar 5:7d9a463f74ec 55 if(thumby.up() == 1)
vhsstar 5:7d9a463f74ec 56 {
vhsstar 5:7d9a463f74ec 57 mainMenuValue = (mainMenuValue+2)%3;
vhsstar 5:7d9a463f74ec 58 }
vhsstar 5:7d9a463f74ec 59 if(thumby.right() == 1 || thumby.button() == 1)
vhsstar 5:7d9a463f74ec 60 {
vhsstar 5:7d9a463f74ec 61 Menu.nextState = nextStates[mainMenuValue];
vhsstar 5:7d9a463f74ec 62 }
vhsstar 5:7d9a463f74ec 63 screen.printTop("Main_Menu^V_____");
vhsstar 5:7d9a463f74ec 64 screen.printBottom(mainMenuOptions[mainMenuValue]);
vhsstar 5:7d9a463f74ec 65 }
vhsstar 5:7d9a463f74ec 66
vhsstar 5:7d9a463f74ec 67 void readTag(void)
vhsstar 5:7d9a463f74ec 68 {
vhsstar 5:7d9a463f74ec 69 screen.print("Read_A_Tag______________________");
vhsstar 5:7d9a463f74ec 70 if(thumby.right() == 1)
vhsstar 5:7d9a463f74ec 71 {
vhsstar 5:7d9a463f74ec 72 Menu.nextState = &MainMenu;
vhsstar 5:7d9a463f74ec 73 }
vhsstar 5:7d9a463f74ec 74 }
vhsstar 5:7d9a463f74ec 75
vhsstar 5:7d9a463f74ec 76 void writeTag(void)
vhsstar 5:7d9a463f74ec 77 {
vhsstar 5:7d9a463f74ec 78 screen.print("Write_A_Tag_____________________");
vhsstar 5:7d9a463f74ec 79 if(thumby.left() == 1)
vhsstar 5:7d9a463f74ec 80 {
vhsstar 5:7d9a463f74ec 81 Menu.nextState = &MainMenu;
vhsstar 5:7d9a463f74ec 82 }
vhsstar 5:7d9a463f74ec 83 }
vhsstar 5:7d9a463f74ec 84
vhsstar 5:7d9a463f74ec 85 void options(void)
vhsstar 5:7d9a463f74ec 86 {
vhsstar 5:7d9a463f74ec 87 screen.print("Options_________________________");
vhsstar 5:7d9a463f74ec 88 if(thumby.left() == 1)
vhsstar 5:7d9a463f74ec 89 {
vhsstar 5:7d9a463f74ec 90 Menu.nextState = &MainMenu;
vhsstar 5:7d9a463f74ec 91 }
vhsstar 5:7d9a463f74ec 92 }
vhsstar 5:7d9a463f74ec 93
vhsstar 5:7d9a463f74ec 94 #endif