Skip to content

Commit

Permalink
Merge pull request #71 from fablabbcn/bugfix/atlas-sleep
Browse files Browse the repository at this point in the history
Bugfix/atlas sleep
  • Loading branch information
oscgonfer authored Nov 8, 2024
2 parents ced6b84 + 079e7b9 commit e0096e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions sam/src/SckAux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,13 @@ bool Atlas::getBusyState()
if (millis() - lastUpdate < 2) return true;
switch (state) {

case REST: {
case SLEEP: {

if (millis() - lastCommandSent >= shortWait) {
if (sendCommand((char*)"r")) state = REST;
}

} case REST: {

// ORP doesn't need temp compensation so we jump directly to ask reading
if (ORP) {
Expand Down Expand Up @@ -1668,7 +1674,9 @@ void Atlas::goToSleep()
auxWire.beginTransmission(deviceAddress);
auxWire.write("Sleep");
auxWire.endTransmission();
state = SLEEP;
}

bool Atlas::sendCommand(char* command)
{

Expand All @@ -1688,7 +1696,7 @@ bool Atlas::sendCommand(char* command)
return true;
}

delay(300);
delay(shortWait);
}
return false;
}
Expand Down
1 change: 1 addition & 0 deletions sam/src/SckAux.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ class Atlas
uint32_t lastUpdate = 0;
enum State {
REST,
SLEEP,
TEMP_COMP_SENT,
ASKED_READING,
};
Expand Down

0 comments on commit e0096e1

Please sign in to comment.