diff --git a/bus.c b/bus.c index 613c6f4..322a9f4 100644 --- a/bus.c +++ b/bus.c @@ -53,6 +53,18 @@ void processCmd(char* buffer) printx(INFO, BUS, "Setting HEAT OFF"); setHeatWantedState(false); } + else if(strcmp(buffer, "setheaton5s") == 0) + { + printx(INFO, BUS, "Setting HEAT ON for 5 secs"); + setHeatTimer(5); + setHeatWantedState(true); + } + else if(strcmp(buffer, "setpumpon5s") == 0) + { + printx(INFO, BUS, "Setting PUMP ON for 5 secs"); + setPumpTimer(5); + setPumpWantedState(true); + } //printx(DEBUG, BUS, "STRLEN : %d and strcmp ret %d", strlen(buffer), strcmp(buffer, "quit")); } diff --git a/hvc.c b/hvc.c index 843478c..26edb48 100644 --- a/hvc.c +++ b/hvc.c @@ -8,6 +8,7 @@ #include <fcntl.h> #include <strings.h> #include <inttypes.h> +#include <time.h> #include "ui.h" #include "hvc.h" #include "printx.h" @@ -33,6 +34,12 @@ bool sHeat = false; struct termios hvcSaveterm; bool wHeat = false; bool wPump = false; +time_t tHeatStart; +time_t tHeatStop; +double tHeatTimer; +time_t tPumpStart; +double tPumpTimer; +time_t tPumpStop; void stopHVC() { @@ -41,14 +48,28 @@ void stopHVC() void setPumpWantedState(bool s) { + tPumpStart = clock(); + tPumpStop = clock(); wPump = s; } void setHeatWantedState(bool s) { + tHeatStart = clock(); + tHeatStop = clock(); wHeat = s; } +void setPumpTimer(double t) +{ + tPumpTimer = t; +} + +void setHeatTimer(double t) +{ + tHeatTimer = t; +} + bool initHVC() { unsigned char data; @@ -84,11 +105,34 @@ void* processHVC(void* we) data = getData(&hvc_fd); setTemp(data); + if(tHeatTimer > 0) + { + tHeatStop = clock(); + if(((double)(tHeatStop - tHeatStart) / CLOCKS_PER_SEC) > tHeatTimer) + { + wHeat = false; + tHeatTimer = 0; + } + + } + + if(tPumpTimer > 0) + { + tPumpStop = clock(); + if(((double)(tPumpStop - tPumpStart) / CLOCKS_PER_SEC) > tPumpTimer) + { + wPump = false; + tPumpTimer = 0; + } + } + if(wHeat ^ sHeat) { sendData(&hvc_fd, wHeat ? SET_HEAT_ON : SET_HEAT_OFF); sHeat = wHeat; setHeat(sHeat); + if(sHeat) + tHeatStart = clock(); } if(wPump ^ sPump) @@ -96,6 +140,8 @@ void* processHVC(void* we) sendData(&hvc_fd, wPump ? SET_PUMP_ON : SET_PUMP_OFF); sPump = wPump; setPump(sPump); + if(sPump) + tPumpStart = clock(); } usleep(HVC_POLLING_TIME); diff --git a/hvc.h b/hvc.h index 5003c0f..9ff2339 100644 --- a/hvc.h +++ b/hvc.h @@ -8,5 +8,7 @@ void* processHVC(); void stopHVC(); void setPumpWantedState(bool); void setHeatWantedState(bool); +void setPumpTimer(double); +void setHeatTimer(double); #endif diff --git a/ui.c b/ui.c index e269c47..437423b 100644 --- a/ui.c +++ b/ui.c @@ -195,6 +195,11 @@ void displayUI() sprintf(buffer, "%c", bufferO[0]); strcat(cmd, buffer); } + else if(bufferO[0] >= 48 && bufferO[0] <= 57) + { + sprintf(buffer, "%c", bufferO[0]); + strcat(cmd, buffer); + } else if(bufferO[0] == 32) { sprintf(buffer, "%c", bufferO[0]); -- libgit2 0.21.2