This is the first version of a Fishing Mini-game. It uses a navigational switch as a button and a joystick, playing wav files from a SD card, and a uLCD screen to show the fishing game

Dependencies:   4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player

Committer:
jd0205
Date:
Thu Mar 17 18:33:52 2016 +0000
Revision:
0:5d811b6879d5
This is the first version of a Fishing Mini-game.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jd0205 0:5d811b6879d5 1 class Nav_Switch
jd0205 0:5d811b6879d5 2 {
jd0205 0:5d811b6879d5 3 public:
jd0205 0:5d811b6879d5 4 Nav_Switch(PinName up,PinName down,PinName left,PinName right,PinName fire);
jd0205 0:5d811b6879d5 5 int read();
jd0205 0:5d811b6879d5 6 //boolean functions to test each switch
jd0205 0:5d811b6879d5 7 bool up();
jd0205 0:5d811b6879d5 8 bool down();
jd0205 0:5d811b6879d5 9 bool left();
jd0205 0:5d811b6879d5 10 bool right();
jd0205 0:5d811b6879d5 11 bool fire();
jd0205 0:5d811b6879d5 12 //automatic read on RHS
jd0205 0:5d811b6879d5 13 operator int ();
jd0205 0:5d811b6879d5 14 //index to any switch array style
jd0205 0:5d811b6879d5 15 bool operator[](int index) {
jd0205 0:5d811b6879d5 16 return _pins[index];
jd0205 0:5d811b6879d5 17 };
jd0205 0:5d811b6879d5 18 private:
jd0205 0:5d811b6879d5 19 BusIn _pins;
jd0205 0:5d811b6879d5 20 };
jd0205 0:5d811b6879d5 21
jd0205 0:5d811b6879d5 22 Nav_Switch::Nav_Switch (PinName up,PinName down,PinName left,PinName right,PinName fire):
jd0205 0:5d811b6879d5 23 _pins(up, down, left, right, fire)
jd0205 0:5d811b6879d5 24 {
jd0205 0:5d811b6879d5 25 _pins.mode(PullUp); //needed if pullups not on board or a bare nav switch is used - delete otherwise
jd0205 0:5d811b6879d5 26 wait(0.001); //delays just a bit for pullups to pull inputs high
jd0205 0:5d811b6879d5 27 }
jd0205 0:5d811b6879d5 28
jd0205 0:5d811b6879d5 29 inline bool Nav_Switch::up()
jd0205 0:5d811b6879d5 30 {
jd0205 0:5d811b6879d5 31 return !(_pins[0]);
jd0205 0:5d811b6879d5 32 }
jd0205 0:5d811b6879d5 33
jd0205 0:5d811b6879d5 34 inline bool Nav_Switch::down()
jd0205 0:5d811b6879d5 35 {
jd0205 0:5d811b6879d5 36 return !(_pins[1]);
jd0205 0:5d811b6879d5 37 }
jd0205 0:5d811b6879d5 38
jd0205 0:5d811b6879d5 39 inline bool Nav_Switch::left()
jd0205 0:5d811b6879d5 40 {
jd0205 0:5d811b6879d5 41 return !(_pins[2]);
jd0205 0:5d811b6879d5 42 }
jd0205 0:5d811b6879d5 43
jd0205 0:5d811b6879d5 44 inline bool Nav_Switch::right()
jd0205 0:5d811b6879d5 45 {
jd0205 0:5d811b6879d5 46 return !(_pins[3]);
jd0205 0:5d811b6879d5 47 }
jd0205 0:5d811b6879d5 48
jd0205 0:5d811b6879d5 49 inline bool Nav_Switch::fire()
jd0205 0:5d811b6879d5 50 {
jd0205 0:5d811b6879d5 51 return !(_pins[4]);
jd0205 0:5d811b6879d5 52 }
jd0205 0:5d811b6879d5 53
jd0205 0:5d811b6879d5 54 inline int Nav_Switch::read()
jd0205 0:5d811b6879d5 55 {
jd0205 0:5d811b6879d5 56 return _pins.read();
jd0205 0:5d811b6879d5 57 }
jd0205 0:5d811b6879d5 58
jd0205 0:5d811b6879d5 59 inline Nav_Switch::operator int ()
jd0205 0:5d811b6879d5 60 {
jd0205 0:5d811b6879d5 61 return _pins.read();
jd0205 0:5d811b6879d5 62 }