summaryrefslogtreecommitdiffstats
path: root/pingid.c
diff options
context:
space:
mode:
Diffstat (limited to 'pingid.c')
-rw-r--r--pingid.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/pingid.c b/pingid.c
index 6e33510..0dc182a 100644
--- a/pingid.c
+++ b/pingid.c
@@ -6,6 +6,14 @@
#include <sys/types.h>
#include <linux/input.h>
+#ifndef GPIO
+#define GPIO 4
+#endif
+
+#define STRINGIFY(a) #a
+#define STRINGIFY_HARDER(a) STRINGIFY(a)
+#define GPIO_STR STRINGIFY_HARDER(GPIO)
+
char *names[KEY_MAX + 1] =
{ "", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "",
@@ -132,16 +140,17 @@ main (int argc, char *argv[])
struct timeval tv;
char ret[128];
- squirt ("/sys/class/gpio/export", "4");
- squirt ("/sys/class/gpio/gpio4/direction", "out");
- squirt ("/sys/class/gpio/gpio4/value", "0");
+
+ squirt ("/sys/class/gpio/export", GPIO_STR);
+ squirt ("/sys/class/gpio/gpio" GPIO_STR "/direction", "out");
+ squirt ("/sys/class/gpio/gpio" GPIO_STR "/value", "0");
tv.tv_sec = 0;
tv.tv_usec = 100;
get_string_with_timeout (fd, &tv, NULL, 0);
- squirt ("/sys/class/gpio/gpio4/value", "1");
+ squirt ("/sys/class/gpio/gpio" GPIO_STR "/value", "1");
tv.tv_sec = 2;
@@ -149,7 +158,7 @@ main (int argc, char *argv[])
get_string_with_timeout (fd, &tv, ret, sizeof (ret));
- squirt ("/sys/class/gpio/gpio4/value", "0");
+ squirt ("/sys/class/gpio/gpio" GPIO_STR "/value", "0");
printf ("Access-Control-Allow-Origin: *\n");
printf ("Content-Type: text/plain\n\n%s\n", ret);