Example program for LPC General Purpose Shield using the 5-way JoyStick

Dependencies:   PCAL955x mbed

Files at this revision

API Documentation at this revision

Comitter:
MACRUM
Date:
Mon Jul 27 08:32:19 2015 +0000
Commit message:
Initial commit

Changed in this revision

PCAL955x.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r ae58e0a9d79e PCAL955x.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PCAL955x.lib	Mon Jul 27 08:32:19 2015 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/nxp_ip/code/PCAL955x/#fd7cfa821b6a
diff -r 000000000000 -r ae58e0a9d79e main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jul 27 08:32:19 2015 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+#include "PCAL9555.h"
+
+PCAL9555    gpio_exp(SDA, SCL);
+GpioBusIn   joystick(gpio_exp, X0_0, X0_1, X0_2, X0_3, X0_4);
+Serial      pc(USBTX, USBRX);
+
+enum key_num {
+    Key_Up     = (1 << X0_4),
+    Key_Down   = (1 << X0_0),
+    Key_Right  = (1 << X0_3),
+    Key_Left   = (1 << X0_2),
+    Key_Center = (1 << X0_1),
+};
+
+int main()
+{
+    while(1) {
+        int keys = joystick.read();
+        if ((keys & Key_Up) == 0)
+            pc.printf("Up\n");
+        if ((keys & Key_Down) == 0)
+            pc.printf("Down\n");
+        if ((keys & Key_Right) == 0)
+            pc.printf("Right\n");
+        if ((keys & Key_Left) == 0)
+            pc.printf("Left\n");
+        if ((keys & Key_Center) == 0)
+            pc.printf("Center\n");
+        wait(0.3);
+    }
+}
diff -r 000000000000 -r ae58e0a9d79e mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Jul 27 08:32:19 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/bad568076d81
\ No newline at end of file