summaryrefslogtreecommitdiffstats
path: root/pingid.c
diff options
context:
space:
mode:
authorfishsoupisgood <github@madingley.org>2020-07-10 11:08:51 +0100
committerfishsoupisgood <github@madingley.org>2020-07-10 11:08:51 +0100
commit623a7e73cf79ecdda28fe5d3ff429090dbae359d (patch)
treebd35f492e210fe788500b98e41a8f4e733c2f563 /pingid.c
parent93dbd25f15d4fb7e8b43411471c1e50f7ea77f6b (diff)
downloadpingid-master.zip
pingid-master.tar.gz
pingid-master.tar.bz2
make GPIO a parameterHEADmaster
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);