#include "cpidjinn.hpp"
+void blink(PinNumber pin, int count, int duration, Logger* logger){
+ GPIOProcessor proc(logger);
+ for (int ix = 0; ix < count; ix++){
+ proc.writeToGPIO(pin, psHigh);
+ usleep(duration * 1000);
+ proc.writeToGPIO(pin, psLow);
+ usleep(duration * 1000);
+ }
+}
+void test(int argc, char** argv, Logger* logger){
+ if (argc == 0 || strcmp(argv[0], "blink") == 0){
+ int count = 20;
+ int duration = 1000;
+ PinNumber pin = pinRPi2_11;
+
+ if (argc > 1)
+ count = pinNameToNumber(argv[1]);
+ if (argc > 2)
+ count = atol(argv[2]);
+ if (argc > 3)
+ duration = atol(argv[3]);;
+ blink(pin, count, duration, logger);
+ }
+ exit(0);
+}
/**
* Main function.
*
char* arg = argv[1];
if (strcmp(arg, "-s") == 0 || strcmp(arg, "--simulation")){
simulation = true;
+ } else if (strcmp(arg, "-t") == 0 || strcmp(arg, "--test")){
+ test(argc - 2, argv + 2, &logger);
} else {
logger.sayf(LOG_ERROR, "unknown option: %s", arg);
}