From 8079463de7b9159092d7d12c57168dbeff61727d Mon Sep 17 00:00:00 2001 From: Jake Hosen Date: Tue, 18 Jun 2024 00:53:08 -0400 Subject: [PATCH] moving motor code to correct place --- src/datalogger.cpp | 50 +++++++++++++++++++--------------------------- src/datalogger.h | 4 ++++ 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/datalogger.cpp b/src/datalogger.cpp index 9d94159..f6a6735 100644 --- a/src/datalogger.cpp +++ b/src/datalogger.cpp @@ -151,14 +151,6 @@ void Datalogger::setup() clearAllAlarms(); // don't respond to alarms during setup - // actuator timestamp setup - // actuator variables - unsigned long pumpStopTime = timestamp() + 10800; - unsigned long pumpResetTime = timestamp() + 21600; - unsigned int powermode = 2; - debug(pumpStopTime); - debug(pumpResetTime); - //initBLE(); unsigned char uuid[UUID_LENGTH]; @@ -244,40 +236,38 @@ void Datalogger::testMeasurementCycle() void Datalogger::loop() { - // actuator timestamp setup - // actuator variables - unsigned long pumpStopTime = timestamp() + 10800; - unsigned long pumpResetTime = timestamp() + 21600; - unsigned int powermode = 2; - debug(pumpStopTime); - debug(pumpResetTime); - unsigned long timeCheck = timestamp(); - if(powermode==2) { + + if (inMode(deploy_on_trigger)) + { + deploy(); // if deploy returns false here, the trigger setup has a fatal coding defect not detecting invalid conditions for deployment + goto SLEEP; + return; + } + + if (inMode(logging)) + { + //AE actuate hook before measurement could go here + + debug(pumpStopTime); + debug(pumpResetTime); + unsigned long timeCheck = timestamp(); + if(powermode==2) { digitalWrite(GPIO_PIN_6, HIGH); + powermode=1; } if(timeCheck>=pumpStopTime&&powermode==1) { - powermode=1; + powermode=0; digitalWrite(GPIO_PIN_6, LOW); } - if(timeCheck>=pumpResetTime&&powermode==2) { + if(timeCheck>=pumpResetTime&&powermode==0) { powermode=1; digitalWrite(GPIO_PIN_6, HIGH); pumpStopTime = timestamp() + 10800; pumpResetTime = timestamp() + 21600; } - - if (inMode(deploy_on_trigger)) - { - deploy(); // if deploy returns false here, the trigger setup has a fatal coding defect not detecting invalid conditions for deployment - goto SLEEP; - return; - } - - if (inMode(logging)) - { - //AE actuate hook before measurement could go here + delay(10000); if (powerCycle) { diff --git a/src/datalogger.h b/src/datalogger.h index 419564c..10e7042 100644 --- a/src/datalogger.h +++ b/src/datalogger.h @@ -94,7 +94,11 @@ class Datalogger void processCLI(); + // actuator timing + unsigned long pumpStopTime = timestamp() + 10800; + unsigned long pumpResetTime = timestamp() + 21600; + unsigned int powermode = 2; // settings void setSiteName(char * siteName);