Update
parent
dad3541113
commit
1f46cf2b1d
2
Makefile
2
Makefile
|
@ -19,7 +19,7 @@ LIBS := $(WPI_LIB) -lm -lpthread
|
|||
$DBG =
|
||||
|
||||
# define any compile-time flags
|
||||
GCCFLAGS = -Wall
|
||||
GCCFLAGS = -Wall -O3
|
||||
#CFLAGS = -Wall -lpthread -lwiringPi -lwiringPiDev -lm -I. -I./minIni
|
||||
CFLAGS = $(GCCFLAGS) -I. -I./minIni $(DBG) $(LIBS) -D MG_DISABLE_MD5 -D MG_DISABLE_HTTP_DIGEST_AUTH -D MG_DISABLE_MD5 -D MG_DISABLE_JSON_RPC
|
||||
#CFLAGS = -Wextra -Wall -g -I./wiringPI
|
||||
|
|
|
@ -200,6 +200,8 @@ http://sprinklerd.ip.address:port?type=option&option=24hdelay&state=off
|
|||
* // Run options
|
||||
<host>?type=option&option=allz&state=on // Run all zones default times (ignore 24h delay & calendar settings)
|
||||
<host>?type=zone&zone=2&state=on&runtime=3 // Run zone 2 for 3 mins (ignore 24h delay & calendar settings)
|
||||
<host>?type=zone&zone=2&state=off // Turn off zone 2
|
||||
<host>?type=zone&zone=2&state=flip // Flip state of zone 2, Turn off if on, Turn on if off
|
||||
<host>?type=zrtcfg&zone=2&time=10 // change zone 2 default runtime to 10
|
||||
<host>?type=cron&zone=1&runtime=12&state=on' // Run zone 1 for 12 mins (calendar & 24hdelay settings overide this request)
|
||||
|
||||
|
|
9
config.c
9
config.c
|
@ -307,7 +307,14 @@ void readCfg(char *inifile)
|
|||
//_sdconfig_.zonecfg[i].master_valve = ini_getl(str, "MASTER_VALVE", NO, inifile);
|
||||
_sdconfig_.zonecfg[i].default_runtime = ini_getl(str, "DEFAULT_RUNTIME", 10, inifile);
|
||||
//ini_gets(str, "NAME", NULL, _sdconfig_.zonecfg[idx].name, sizearray(_sdconfig_.zonecfg[idx].name), inifile);
|
||||
ini_gets(str, "NAME", NULL, _sdconfig_.zonecfg[i].name, sizearray(_sdconfig_.zonecfg[i].name), inifile);
|
||||
ini_gets(str, "NAME", NULL, _sdconfig_.zonecfg[i].name, sizearray(_sdconfig_.zonecfg[i].name), inifile);
|
||||
#ifndef USE_WIRINGPI
|
||||
if ( ! validGPIO(pin) ) {
|
||||
logMessage (LOG_ERR, "GPIO %d is not valid, found in ZONE:%d of configuration file %s \n",pin, i, inifile);
|
||||
pin = GPIO_MAX; // Set pin to MAX so we can continue to run if error is not fixed.
|
||||
sprintf(_sdconfig_.zonecfg[i].name, "ERROR in cfg");
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
logMessage (LOG_DEBUG,"Zone Config : %s\n%25s : %d\n%25s : %d\n%25s : %d\n%25s : %d\n%25s : %d\n",
|
||||
_sdconfig_.zonecfg[i].name,
|
||||
|
|
|
@ -381,6 +381,13 @@ int is_value_ON(char *buf) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
bool is_value_flip(char *buf) {
|
||||
if (strncasecmp(buf, "flip", 4) == 0 || strncasecmp(buf, "toggle", 6) == 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
int serve_web_request(struct mg_connection *nc, struct http_message *http_msg, char *buffer, int size, bool *changedOption) {
|
||||
static int buflen = 50;
|
||||
char buf[buflen];
|
||||
|
@ -504,6 +511,8 @@ int serve_web_request(struct mg_connection *nc, struct http_message *http_msg, c
|
|||
} else if ( is_value_ON(buf) == false && zone <= _sdconfig_.zones) {
|
||||
zc_zone(type, zone, zcOFF, runtime);
|
||||
length = build_sprinkler_JSON(buffer, size);
|
||||
} else if ( is_value_flip(buf) == true && zone <= _sdconfig_.zones) {
|
||||
zc_zone(type, zone, !zc_state(zone), runtime);
|
||||
} else {
|
||||
if (zone > _sdconfig_.zones) {
|
||||
logMessage(LOG_WARNING, "Bad request unknown zone %d\n",zone);
|
||||
|
@ -519,10 +528,11 @@ int serve_web_request(struct mg_connection *nc, struct http_message *http_msg, c
|
|||
zone = atoi(buf);
|
||||
mg_get_http_var(&http_msg->query_string, "time", buf, buflen);
|
||||
runtime = atoi(buf);
|
||||
if (zone > 0 && zone <= _sdconfig_.zones && runtime > 0) {
|
||||
if (zone > 0 && zone <= _sdconfig_.zones && runtime > -1) {
|
||||
_sdconfig_.zonecfg[zone].default_runtime = runtime;
|
||||
logMessage(LOG_DEBUG, "changed default runtime on zone %d, to %d\n",zone, runtime);
|
||||
length = build_sprinkler_JSON(buffer, size);
|
||||
zc_update_runtime(zone);
|
||||
*changedOption = true;
|
||||
} else
|
||||
length += sprintf(buffer, "{ \"error\": \"bad request zone %d runtime %d\"}",zone,runtime);
|
||||
|
@ -707,6 +717,7 @@ void action_mqtt_message(struct mg_connection *nc, struct mg_mqtt_message *msg){
|
|||
int v = str2int(msg->payload.p, msg->payload.len);
|
||||
_sdconfig_.zonecfg[zone].default_runtime = v / 60;
|
||||
_sdconfig_.eventToUpdateHappened = true;
|
||||
zc_update_runtime(zone);
|
||||
logMessage(LOG_DEBUG, "MQTT: Default runtime zone %d is %d\n",zone,_sdconfig_.zonecfg[zone].default_runtime);
|
||||
} else {
|
||||
logMessage(LOG_DEBUG, "MQTT: BAD Default runtime zone %d is %d\n",zone,_sdconfig_.zonecfg[zone].default_runtime);
|
||||
|
|
Binary file not shown.
|
@ -32,7 +32,7 @@ LOG_LEVEL = NOTICE
|
|||
# PUD_UP 2
|
||||
|
||||
#NAME = name of zone
|
||||
#GPIO_PIN = GPIO Pin # This is the GPIO# not the pin#, so (17 = GPIO17 = Pin 11) or another example (5 = GPIO5 = Pin 29)
|
||||
#GPIO_PIN = GPIO # This is the GPIO# not the pin#, so (17 = GPIO17 = Pin 11) or another example (5 = GPIO5 = Pin 29)
|
||||
#WPI_PIN = use instead of GPIO_PIN if compiled with USE_WIRINGPI flag, This is WiringPi Pin#, not Raspberry Pi board pin#
|
||||
#GPIO_PULL_UPDN = setup pull up pull down resistor PUD_OFF|PUD_DOWN|PUD_UP
|
||||
#GPIO_ON_STATE = State GPIO reads when relay for zone is on. HIGH or LOW 1 or 0
|
||||
|
|
|
@ -4,8 +4,8 @@ NAME=My Sprinklers
|
|||
DOCUMENTROOT = /nas/data/Development/Raspberry/SprinklerD/web/
|
||||
CACHE = /var/cache/sprinklerd.cache
|
||||
# The log level. [DEBUG, INFO, NOTICE, WARNING, ERROR]
|
||||
#LOG_LEVEL = DEBUG
|
||||
LOG_LEVEL = NOTICE
|
||||
LOG_LEVEL = DEBUG
|
||||
#LOG_LEVEL = NOTICE
|
||||
|
||||
# mqtt stuff
|
||||
MQTT_ADDRESS = trident:1883
|
||||
|
@ -75,49 +75,58 @@ GPIO_ON_STATE=0
|
|||
DOMOTICZ_IDX=202
|
||||
|
||||
[ZONE:4]
|
||||
NAME=Front Flowerbeds
|
||||
NAME=Diningroom error
|
||||
DEFAULT_RUNTIME=10
|
||||
GPIO_PIN=23
|
||||
WPI_PIN=4
|
||||
GPIO_PIN=28
|
||||
WPI_PIN=3
|
||||
GPIO_PULL_UPDN=1
|
||||
GPIO_ON_STATE=0
|
||||
DOMOTICZ_IDX=203
|
||||
DOMOTICZ_IDX=202
|
||||
|
||||
[ZONE:5]
|
||||
NAME=Backgarden Left
|
||||
DEFAULT_RUNTIME=10
|
||||
GPIO_PIN=24
|
||||
WPI_PIN=5
|
||||
GPIO_PULL_UPDN=1
|
||||
GPIO_ON_STATE=0
|
||||
DOMOTICZ_IDX=204
|
||||
#[ZONE:4]
|
||||
#NAME=Front Flowerbeds
|
||||
#DEFAULT_RUNTIME=10
|
||||
#GPIO_PIN=23
|
||||
#WPI_PIN=4
|
||||
#GPIO_PULL_UPDN=1
|
||||
#GPIO_ON_STATE=0
|
||||
#DOMOTICZ_IDX=203
|
||||
|
||||
[ZONE:6]
|
||||
NAME=Backgarden Right
|
||||
DEFAULT_RUNTIME=10
|
||||
GPIO_PIN=25
|
||||
WPI_PIN=6
|
||||
GPIO_PULL_UPDN=1
|
||||
GPIO_ON_STATE=0
|
||||
DOMOTICZ_IDX=205
|
||||
#[ZONE:5]
|
||||
#NAME=Backgarden Left
|
||||
#DEFAULT_RUNTIME=10
|
||||
#GPIO_PIN=24
|
||||
#WPI_PIN=5
|
||||
#GPIO_PULL_UPDN=1
|
||||
#GPIO_ON_STATE=0
|
||||
#DOMOTICZ_IDX=204
|
||||
|
||||
[ZONE:7]
|
||||
NAME=Garage Flowerbeds
|
||||
DEFAULT_RUNTIME=10
|
||||
GPIO_PIN=5
|
||||
WPI_PIN=21
|
||||
GPIO_PULL_UPDN=1
|
||||
GPIO_ON_STATE=0
|
||||
DOMOTICZ_IDX=206
|
||||
#[ZONE:6]
|
||||
#NAME=Backgarden Right
|
||||
#DEFAULT_RUNTIME=10
|
||||
#GPIO_PIN=25
|
||||
#WPI_PIN=6
|
||||
#GPIO_PULL_UPDN=1
|
||||
#GPIO_ON_STATE=0
|
||||
#DOMOTICZ_IDX=205
|
||||
|
||||
[ZONE:8]
|
||||
NAME=Golfcart path
|
||||
DEFAULT_RUNTIME=10
|
||||
GPIO_PIN=6
|
||||
WPI_PIN=22
|
||||
GPIO_PULL_UPDN=1
|
||||
GPIO_ON_STATE=0
|
||||
DOMOTICZ_IDX=207
|
||||
#[ZONE:7]
|
||||
#NAME=Garage Flowerbeds
|
||||
#DEFAULT_RUNTIME=10
|
||||
#GPIO_PIN=5
|
||||
#WPI_PIN=21
|
||||
#GPIO_PULL_UPDN=1
|
||||
#GPIO_ON_STATE=0
|
||||
#DOMOTICZ_IDX=206
|
||||
|
||||
#[ZONE:8]
|
||||
#NAME=Golfcart path
|
||||
#DEFAULT_RUNTIME=10
|
||||
#GPIO_PIN=6
|
||||
#WPI_PIN=22
|
||||
#GPIO_PULL_UPDN=1
|
||||
#GPIO_ON_STATE=0
|
||||
#DOMOTICZ_IDX=207
|
||||
|
||||
#
|
||||
# This is for future support of sensors, not implimented yet
|
||||
|
|
47
sd_GPIO.c
47
sd_GPIO.c
|
@ -15,6 +15,26 @@
|
|||
#include "utils.h"
|
||||
#include "sd_GPIO.h"
|
||||
|
||||
const char *_piModelNames [16] =
|
||||
{
|
||||
"Model A", // 0
|
||||
"Model B", // 1
|
||||
"Model A+", // 2
|
||||
"Model B+", // 3
|
||||
"Pi 2", // 4
|
||||
"Alpha", // 5
|
||||
"CM", // 6
|
||||
"Unknown07", // 07
|
||||
"Pi 3", // 08
|
||||
"Pi Zero", // 09
|
||||
"CM3", // 10
|
||||
"Unknown11", // 11
|
||||
"Pi Zero-W", // 12
|
||||
"Pi 3+", // 13
|
||||
"Unknown New 14", // 14
|
||||
"Unknown New 15", // 15
|
||||
} ;
|
||||
|
||||
static bool _ever = false;
|
||||
void gpioDelay (unsigned int howLong);
|
||||
|
||||
|
@ -68,22 +88,26 @@ int piBoardId ()
|
|||
logMessage (LOG_ERR, "piBoardId: Unknown \"Revision\" line (no hex digit at start of revision)") ;
|
||||
|
||||
revision = (unsigned int)strtol (c, NULL, 16) ; // Hex number with no leading 0x
|
||||
|
||||
|
||||
// Check for new way:
|
||||
|
||||
if ((revision & (1 << 23)) != 0) // New way
|
||||
{/*
|
||||
bRev = (revision & (0x0F << 0)) >> 0 ;*/
|
||||
bType = (revision & (0xFF << 4)) >> 4 ;
|
||||
return bType;
|
||||
/*
|
||||
bProc = (revision & (0x0F << 12)) >> 12 ; // Not used for now.
|
||||
bMfg = (revision & (0x0F << 16)) >> 16 ;
|
||||
bMem = (revision & (0x07 << 20)) >> 20 ;
|
||||
bWarranty = (revision & (0x03 << 24)) != 0 ;
|
||||
*/
|
||||
|
||||
logMessage (LOG_DEBUG, "piBoard Model: %s\n", _piModelNames[bType]) ;
|
||||
|
||||
return bType;
|
||||
}
|
||||
|
||||
logMessage (LOG_ERR, "piBoard Model: UNKNOWN\n");
|
||||
return PI_MODEL_UNKNOWN;
|
||||
}
|
||||
|
||||
|
@ -93,11 +117,15 @@ bool gpioSetup() {
|
|||
|
||||
switch ( piBoardId() )
|
||||
{
|
||||
case PI_MODEL_A: case PI_MODEL_B:
|
||||
case PI_MODEL_AP: case PI_MODEL_BP:
|
||||
case PI_ALPHA: case PI_MODEL_CM:
|
||||
case PI_MODEL_ZERO: case PI_MODEL_ZERO_W:
|
||||
case PI_MODEL_UNKNOWN:
|
||||
case PI_MODEL_A:
|
||||
case PI_MODEL_B:
|
||||
case PI_MODEL_AP:
|
||||
case PI_MODEL_BP:
|
||||
case PI_ALPHA:
|
||||
case PI_MODEL_CM:
|
||||
case PI_MODEL_ZERO:
|
||||
case PI_MODEL_ZERO_W:
|
||||
//case PI_MODEL_UNKNOWN:
|
||||
piGPIObase = (GPIO_BASE_P1 + GPIO_OFFSET);
|
||||
break ;
|
||||
|
||||
|
@ -572,6 +600,8 @@ bool registerGPIOinterrupt(int pin, int mode, void (*function)(void *args), void
|
|||
|
||||
//#define TEST_HARNESS
|
||||
|
||||
#ifdef TEST_HARNESS
|
||||
|
||||
#define GPIO_OFF 0x00005000 /* Offset from IO_START to the GPIO reg's. */
|
||||
|
||||
/* IO_START and IO_BASE are defined in hardware.h */
|
||||
|
@ -579,9 +609,6 @@ bool registerGPIOinterrupt(int pin, int mode, void (*function)(void *args), void
|
|||
#define GPIO_START (IO_START_2 + GPIO_OFF) /* Physical addr of the GPIO reg. */
|
||||
#define GPIO_BASE_NEW (IO_BASE_2 + GPIO_OFF) /* Virtual addr of the GPIO reg. */
|
||||
|
||||
|
||||
#ifdef TEST_HARNESS
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -65,8 +65,15 @@
|
|||
#define PI_MODEL_ZERO 9
|
||||
#define PI_MODEL_CM3 10
|
||||
#define PI_MODEL_ZERO_W 12
|
||||
#define PI_MODEL_3P 13
|
||||
|
||||
#endif
|
||||
|
||||
// check number is between 2 and 27
|
||||
#define GPIO_MIN 2
|
||||
#define GPIO_MAX 27
|
||||
|
||||
#define validGPIO(X) ((X) <= (GPIO_MAX) ? ( ((X) >= (GPIO_MIN) ? (1) : (0)) ) : (0))
|
||||
|
||||
|
||||
//#ifndef SYSFS_MODE
|
||||
|
|
2
utils.c
2
utils.c
|
@ -114,7 +114,7 @@ void logMessage(int level, char *format, ...)
|
|||
//if (_debuglog_ == false && level == LOG_DEBUG)
|
||||
// return;
|
||||
|
||||
char buffer[MXPRNT];
|
||||
char buffer[MXPRNT+1];
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
strncpy(buffer, " ", 8);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef SD_VERSION_H
|
||||
#define SD_VERSION_H
|
||||
|
||||
#define SD_VERSION "1.0d"
|
||||
#define SD_VERSION "1.0e"
|
||||
|
||||
#endif
|
||||
|
|
105
zone_ctrl.c
105
zone_ctrl.c
|
@ -1,4 +1,3 @@
|
|||
|
||||
#ifdef USE_WIRINGPI
|
||||
#include <wiringPi.h>
|
||||
#else
|
||||
|
@ -16,8 +15,8 @@ void zc_master(zcState state);
|
|||
int calc_timeleft() {
|
||||
if (_sdconfig_.currentZone.zone != -1) {
|
||||
// See if the duration time changed since we started, on was not a cron request.
|
||||
if ( _sdconfig_.currentZone.type != zcCRON && _sdconfig_.currentZone.duration != _sdconfig_.zonecfg[_sdconfig_.currentZone.zone].default_runtime)
|
||||
_sdconfig_.currentZone.duration=_sdconfig_.zonecfg[_sdconfig_.currentZone.zone].default_runtime;
|
||||
//if ( _sdconfig_.currentZone.type != zcCRON && _sdconfig_.currentZone.duration != _sdconfig_.zonecfg[_sdconfig_.currentZone.zone].default_runtime)
|
||||
// _sdconfig_.currentZone.duration=_sdconfig_.zonecfg[_sdconfig_.currentZone.zone].default_runtime;
|
||||
|
||||
time_t now;
|
||||
time(&now);
|
||||
|
@ -31,6 +30,46 @@ int calc_timeleft() {
|
|||
return _sdconfig_.currentZone.timeleft;
|
||||
}
|
||||
|
||||
zcState zc_state(int zone) {
|
||||
if (zone > 0 && zone <= _sdconfig_.zones) {
|
||||
return (digitalRead(_sdconfig_.zonecfg[zone].pin) == _sdconfig_.zonecfg[zone].on_state ? zcON : zcOFF);
|
||||
} else {
|
||||
return zcOFF; // If invalid zone just return off, maybe change to NULL
|
||||
}
|
||||
}
|
||||
|
||||
int start_next_zone(int startz) {
|
||||
|
||||
int zone = startz+1;
|
||||
|
||||
while( _sdconfig_.zonecfg[zone].default_runtime <= 0 ) {
|
||||
logMessage (LOG_INFO, "Run Zone, skipping zone %d due to runtime of %d\n",zone,_sdconfig_.zonecfg[zone].default_runtime);
|
||||
zone++;
|
||||
if (zone > _sdconfig_.zones) { // No more zones left to run, turn everything off
|
||||
_sdconfig_.currentZone.type=zcNONE;
|
||||
_sdconfig_.currentZone.zone=-1;
|
||||
_sdconfig_.currentZone.timeleft = 0;
|
||||
zc_master(zcOFF);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
_sdconfig_.currentZone.zone=zone;
|
||||
zc_start(_sdconfig_.currentZone.zone);
|
||||
zc_master(zcON);
|
||||
time(&_sdconfig_.currentZone.started_time);
|
||||
_sdconfig_.currentZone.duration=_sdconfig_.zonecfg[_sdconfig_.currentZone.zone].default_runtime;
|
||||
calc_timeleft();
|
||||
|
||||
return zone;
|
||||
}
|
||||
|
||||
void zc_update_runtime(int zone) {
|
||||
if (zone > 0 && zone < _sdconfig_.zones && zone == _sdconfig_.currentZone.zone) {
|
||||
_sdconfig_.currentZone.duration=_sdconfig_.zonecfg[zone].default_runtime;
|
||||
}
|
||||
}
|
||||
|
||||
bool zc_check() {
|
||||
// check what's running, and if time now is greater than duration Stop if grater
|
||||
// Move onto next zone if (all) runtype
|
||||
|
@ -47,11 +86,7 @@ bool zc_check() {
|
|||
if (calc_timeleft() <= 0){
|
||||
if (_sdconfig_.currentZone.type==zcALL && _sdconfig_.currentZone.zone < _sdconfig_.zones) {
|
||||
zc_stop(_sdconfig_.currentZone.zone);
|
||||
_sdconfig_.currentZone.zone++;
|
||||
zc_start(_sdconfig_.currentZone.zone);
|
||||
time(&_sdconfig_.currentZone.started_time);
|
||||
_sdconfig_.currentZone.duration=_sdconfig_.zonecfg[_sdconfig_.currentZone.zone].default_runtime;
|
||||
calc_timeleft();
|
||||
start_next_zone(_sdconfig_.currentZone.zone);
|
||||
} else {
|
||||
zc_master(zcOFF);
|
||||
zc_stop(_sdconfig_.currentZone.zone);
|
||||
|
@ -118,13 +153,9 @@ bool zc_zone(zcRunType type, int zone, zcState state, int length) {
|
|||
}
|
||||
_sdconfig_.currentZone.type=zcNONE;
|
||||
if (state == zcON) {
|
||||
zc_start(1);
|
||||
zc_master(zcON);
|
||||
_sdconfig_.currentZone.zone=1;
|
||||
time(&_sdconfig_.currentZone.started_time);
|
||||
_sdconfig_.currentZone.duration=_sdconfig_.zonecfg[1].default_runtime;
|
||||
_sdconfig_.currentZone.type=zcALL;
|
||||
calc_timeleft();
|
||||
if ( start_next_zone(0) != -1 ) { // Pass 0 as start_next_zone will incrument zone
|
||||
_sdconfig_.currentZone.type=zcALL;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -135,31 +166,31 @@ bool zc_zone(zcRunType type, int zone, zcState state, int length) {
|
|||
logMessage (LOG_DEBUG, "Use default time of %d\n",length);
|
||||
}
|
||||
|
||||
// NSF need to Check the array is valid
|
||||
//if ( _sdconfig_.zonecfg[zone] == NULL) {
|
||||
// return false;
|
||||
//}
|
||||
|
||||
if (state == zcON) {
|
||||
for (i=1; i <= _sdconfig_.zones ; i++)
|
||||
{
|
||||
if ( _sdconfig_.zonecfg[i].on_state == digitalRead (_sdconfig_.zonecfg[i].pin)) {
|
||||
if (zone == i) {
|
||||
logMessage (LOG_DEBUG, "Request to turn zone %d on. Zone %d is already on, ignoring!\n",zone,zone);
|
||||
return false;
|
||||
if ( length > 0) {
|
||||
for (i=1; i <= _sdconfig_.zones ; i++)
|
||||
{
|
||||
if ( _sdconfig_.zonecfg[i].on_state == digitalRead (_sdconfig_.zonecfg[i].pin)) {
|
||||
if (zone == i) {
|
||||
logMessage (LOG_DEBUG, "Request to turn zone %d on. Zone %d is already on, ignoring!\n",zone,zone);
|
||||
return false;
|
||||
}
|
||||
zc_stop(i);
|
||||
}
|
||||
zc_stop(i);
|
||||
}
|
||||
}
|
||||
zc_start(zone);
|
||||
zc_master(zcON);
|
||||
_sdconfig_.currentZone.type=type;
|
||||
_sdconfig_.currentZone.zone=zone;
|
||||
_sdconfig_.currentZone.duration=length;
|
||||
logMessage (LOG_DEBUG, "set runtime to %d and %d\n",length,_sdconfig_.currentZone.duration);
|
||||
time(&_sdconfig_.currentZone.started_time);
|
||||
calc_timeleft();
|
||||
return true;
|
||||
zc_start(zone);
|
||||
zc_master(zcON);
|
||||
_sdconfig_.currentZone.type=type;
|
||||
_sdconfig_.currentZone.zone=zone;
|
||||
_sdconfig_.currentZone.duration=length;
|
||||
logMessage (LOG_DEBUG, "set runtime to %d and %d\n",length,_sdconfig_.currentZone.duration);
|
||||
time(&_sdconfig_.currentZone.started_time);
|
||||
calc_timeleft();
|
||||
return true;
|
||||
} else {
|
||||
logMessage (LOG_WARNING, "Request to turn zone %d on. Ignored due to runtime being %d\n",zone,length);
|
||||
return false;
|
||||
}
|
||||
} else if (state == zcOFF) {
|
||||
if (_sdconfig_.currentZone.type == zcALL) { // If all zones, and told to turn off current, run next zone
|
||||
_sdconfig_.currentZone.started_time = _sdconfig_.currentZone.started_time - (_sdconfig_.currentZone.duration * SEC2MIN) - 1;
|
||||
|
|
|
@ -22,5 +22,6 @@ struct szRunning {
|
|||
bool zc_check();
|
||||
bool zc_zone(zcRunType type, int zone, zcState state, int length);
|
||||
void zc_rain_delay_enabeled();
|
||||
|
||||
zcState zc_state(int zone);
|
||||
void zc_update_runtime(int zone);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue