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

Revision:
0:5d811b6879d5
diff -r 000000000000 -r 5d811b6879d5 Nav_Switch.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Nav_Switch.h	Thu Mar 17 18:33:52 2016 +0000
@@ -0,0 +1,62 @@
+class Nav_Switch
+{
+    public:
+        Nav_Switch(PinName up,PinName down,PinName left,PinName right,PinName fire);
+        int read();
+    //boolean functions to test each switch
+        bool up();
+        bool down();
+        bool left();
+        bool right();
+        bool fire();
+    //automatic read on RHS
+        operator int ();
+    //index to any switch array style
+        bool operator[](int index) {
+            return _pins[index];
+        };
+    private:
+        BusIn _pins; 
+};
+
+Nav_Switch::Nav_Switch (PinName up,PinName down,PinName left,PinName right,PinName fire):
+    _pins(up, down, left, right, fire)
+    {
+        _pins.mode(PullUp); //needed if pullups not on board or a bare nav switch is used - delete otherwise
+        wait(0.001); //delays just a bit for pullups to pull inputs high
+    }
+
+inline bool Nav_Switch::up()
+{
+    return !(_pins[0]);
+}
+
+inline bool Nav_Switch::down()
+{
+    return !(_pins[1]);
+}
+
+inline bool Nav_Switch::left()
+{
+    return !(_pins[2]);
+}
+
+inline bool Nav_Switch::right()
+{
+    return !(_pins[3]);
+}
+
+inline bool Nav_Switch::fire()
+{
+    return !(_pins[4]);
+}
+
+inline int Nav_Switch::read()
+{
+    return _pins.read();
+}
+
+inline Nav_Switch::operator int ()
+{
+    return _pins.read();
+}
\ No newline at end of file