Skip to content

Commit

Permalink
WIP tcomp command for atlas sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
oscgonfer committed Oct 28, 2024
1 parent 30e490d commit a4cae9c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 21 additions & 1 deletion sam/src/SckAux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,15 @@ String AuxBoards::control(SensorType wichSensor, String command)
if (responseCode == 1) return thisAtlas->atlasResponse;
else return String(responseCode);

} else if (command.startsWith("tcomp")) {

command.replace("tcomp", "");
command.trim();

if (command.startsWith("on")) thisAtlas->tComp(1);
else if (command.startsWith("off")) thisAtlas.tComp(0);

return String F("Atlas temperature compensation: ") + String(thisAtlas.tComp() ? "on" : "off");
}
break;

Expand Down Expand Up @@ -1602,7 +1611,7 @@ bool Atlas::getBusyState()

} case TEMP_COMP_SENT: {

if (millis() - lastCommandSent >= shortWait) {
if (millis() - lastCommandSent >= longWait) {
if (sendCommand((char*)"r")) state = ASKED_READING;
}
break;
Expand Down Expand Up @@ -1668,6 +1677,17 @@ bool Atlas::getBusyState()
lastUpdate = millis();
return true;
}

bool Atlas::tComp(int8_t value)
{
// Value: 0 -> disable, 1 -> enable, any other -> get current setting

if (value == 1) sparkfun_scd30.setAutoSelfCalibration(true);
else if (value == 0) sparkfun_scd30.setAutoSelfCalibration(false);

return sparkfun_scd30.getAutoSelfCalibration();
}

void Atlas::goToSleep()
{

Expand Down
2 changes: 2 additions & 0 deletions sam/src/SckAux.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ class Atlas
bool DO = false;
bool TEMP = false;
bool ORP = false;
bool enableTComp = true;
float newReading[4];
String atlasResponse;
uint32_t lastCommandSent = 0;
Expand Down Expand Up @@ -415,6 +416,7 @@ class Atlas
bool stop();
bool getReading();
bool getBusyState();
bool tComp(int8_t value=-1);

void goToSleep();
bool sendCommand(char* command);
Expand Down

0 comments on commit a4cae9c

Please sign in to comment.