Skip to content

Commit

Permalink
Add external script support
Browse files Browse the repository at this point in the history
Fix #54
  • Loading branch information
nhorvath committed May 8, 2019
1 parent 322a4c2 commit 68efd39
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@
// Number of on/off cycles to execute per button press
#define CHATTERBOX_CYCLES 10

// External script to use when "None" Output Type is selected.
// If this script does not exist or is not executable, nothing will happen.
// Has no effect if ARDUINO is defined.
#define EXTERNAL_SCRIPT "/usr/local/bin/sprinklers_pi_zone"

#endif //SPRINKLERS_PI_CONFIG_H
14 changes: 14 additions & 0 deletions core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static tftp tftpServer;
#else
#include <wiringPi.h>
#include <unistd.h>
#include <sys/stat.h>
#endif

#ifdef LOGGING
Expand Down Expand Up @@ -108,6 +109,19 @@ static void io_latch()
switch (eot)
{
case OT_NONE:
#ifndef ARDUINO
#ifdef EXTERNAL_SCRIPT
struct stat buffer;
char cmd[50];
if (stat(EXTERNAL_SCRIPT, &buffer) == 0) {
for (int i = 0; i <= NUM_ZONES; i++)
{
sprintf(cmd, "%s %i %i", EXTERNAL_SCRIPT, i, (outState&(0x01<<i))?1:0);
system(cmd);
}
}
#endif
#endif
break;
case OT_DIRECT_POS:
case OT_DIRECT_NEG:
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.1
1.5.0

0 comments on commit 68efd39

Please sign in to comment.