From 02b7b0b1a5e6daf8781bc43b8324b429d773a6a4 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Tue, 23 Jul 2019 19:43:05 +0300 Subject: [PATCH] added pin number commandline argument --- pulser.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pulser.c b/pulser.c index 6362d67..3a0bdf1 100644 --- a/pulser.c +++ b/pulser.c @@ -59,6 +59,13 @@ int main(int argc, char **argv) } break; + case 'p': + if(!argv[++i] || (pin = atoi(argv[i])) < 1 || pin >= 28) { + fprintf(stderr, "-p must be followed by a BCM pin number: 1-27\n"); + return 1; + } + break; + case 'h': print_usage(argv[0]); return 0; @@ -128,5 +135,6 @@ void print_usage(const char *argv0) printf(" -n: number of pulses to emit (default: 1)\n"); printf(" -f: frequency of pulses in hz (default: 1)\n"); printf(" -d: duty cycle [1, 255] (default: 128)\n"); + printf(" -p: BCM pin number [1, 27] (default: 24)\n"); printf(" -h: print usage and exit\n"); } -- 1.7.10.4