Skip to content

Commit

Permalink
moving motor code to correct place
Browse files Browse the repository at this point in the history
  • Loading branch information
jakehosen committed Jun 18, 2024
1 parent 882bf83 commit 8079463
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 30 deletions.
50 changes: 20 additions & 30 deletions src/datalogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 4 additions & 0 deletions src/datalogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8079463

Please sign in to comment.