Skip to content

Commit

Permalink
Merge pull request #73 from fablabbcn/enhancement/pio-env-info
Browse files Browse the repository at this point in the history
Enhancement/pio env info
  • Loading branch information
oscgonfer authored Nov 8, 2024
2 parents c3c5bd4 + a4d2ac3 commit ae48627
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 12 deletions.
Binary file not shown.
Binary file not shown.
12 changes: 6 additions & 6 deletions sam/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -131,31 +131,31 @@ lib_deps =

[env:sck2]
build_flags =
!sh ../tools/git-rev.sh
!sh ../tools/git-rev.sh -e sck2
-D SCK2

[env:sck21_air]
build_flags =
!sh ../tools/git-rev.sh
!sh ../tools/git-rev.sh -e sck21_air
-D SCK21_AIR

[env:sck22_air]
build_flags =
!sh ../tools/git-rev.sh
!sh ../tools/git-rev.sh -e sck22_air
-D SCK22_AIR

[env:sck23_air]
build_flags =
!sh ../tools/git-rev.sh
!sh ../tools/git-rev.sh -e sck23_air
-D SCK23_AIR

[env:sck_water]
build_flags =
!sh ../tools/git-rev.sh
!sh ../tools/git-rev.sh -e sck_water
-D SCK_WATER

[env:sck23_air_test]
build_flags =
!sh ../tools/git-rev.sh
!sh ../tools/git-rev.sh -e sck23_air_test
-D SCK23_AIR
-D TESTING
54 changes: 50 additions & 4 deletions sam/src/SckAux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ bool AuxBoards::start(SckBase *base, SensorType wichSensor)
moistureChirp.calibrated = true;
}
#endif

#ifdef WITH_ATLAS
atlasPH.enableTComp = data.config.pHEnableTComp;
atlasEC.enableTComp = data.config.ECEnableTComp;
atlasDO.enableTComp = data.config.DOEnableTComp;
#endif
}

switch (wichSensor) {
Expand Down Expand Up @@ -597,6 +603,35 @@ String AuxBoards::control(SensorType wichSensor, String command)
if (responseCode == 1) return thisAtlas->atlasResponse;
else return String(responseCode);

} else if (command.startsWith("tcomp")) {
// Enable or disable temperature compensation on sensors
if (wichSensor == SENSOR_ATLAS_TEMPERATURE || wichSensor == SENSOR_ATLAS_ORP) {
return String("Sensor does not support temperature compensation. Ignoring");
}

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

// Value: 0 -> disable, 1 -> enable, any other -> get current setting
if (command.startsWith("on")){
thisAtlas->enableTComp = true;
} else if (command.startsWith("off")) {
thisAtlas->enableTComp = false;
}

if (wichSensor == SENSOR_ATLAS_EC || wichSensor == SENSOR_ATLAS_EC_SG || wichSensor == SENSOR_ATLAS_EC_TDS || wichSensor == SENSOR_ATLAS_EC_SAL) {
data.config.ECEnableTComp = thisAtlas->enableTComp;
} else if (wichSensor == SENSOR_ATLAS_DO || wichSensor == SENSOR_ATLAS_DO_SAT) {
data.config.DOEnableTComp = thisAtlas->enableTComp;
} else if (wichSensor == SENSOR_ATLAS_PH) {
data.config.pHEnableTComp = thisAtlas->enableTComp;
}

eepromAuxData.write(data);

return String F("Atlas temperature compensation: ") + String(thisAtlas->enableTComp ? "on" : "off");
} else {
return F("Wrong command!!\r\nOptions:\r\ntcomp [on/off] # Enables temperature compensation\r\ncom [atlas commands]");
}
break;

Expand Down Expand Up @@ -1505,7 +1540,6 @@ bool Atlas::start()

if (!I2Cdetect(&auxWire, deviceAddress)) return false;


// Protocol lock
if (!sendCommand((char*)"Plock,1")) return false;
delay(shortWait);
Expand Down Expand Up @@ -1577,7 +1611,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 All @@ -1596,7 +1636,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 @@ -1662,13 +1702,16 @@ bool Atlas::getBusyState()
lastUpdate = millis();
return true;
}

void Atlas::goToSleep()
{

auxWire.beginTransmission(deviceAddress);
auxWire.write("Sleep");
auxWire.endTransmission();
state = SLEEP;
}

bool Atlas::sendCommand(char* command)
{

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

delay(300);
delay(shortWait);
}
return false;
}
bool Atlas::tempCompensation()
{
// If we don't enable Temperature compensation, we directly return
if (!enableTComp) return true;

if (!ORP) {
// Temperature compensation for PH, EC, and DO
float temperature = -1000;
Expand Down
9 changes: 9 additions & 0 deletions sam/src/SckAux.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,16 @@ struct Calibration {
int32_t wetPoint;
};

struct Config {
bool pHEnableTComp = true;
bool DOEnableTComp = true;
bool ECEnableTComp = true;
};

struct EepromAuxData {
bool valid = false;
Calibration calibration;
Config config;
};

bool I2Cdetect(byte address);
Expand Down Expand Up @@ -354,12 +361,14 @@ class Atlas
bool DO = false;
bool TEMP = false;
bool ORP = false;
bool enableTComp = true;
float newReading[4];
String atlasResponse;
uint32_t lastCommandSent = 0;
uint32_t lastUpdate = 0;
enum State {
REST,
SLEEP,
TEMP_COMP_SENT,
ASKED_READING,
};
Expand Down
2 changes: 1 addition & 1 deletion sam/src/SckBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class SckBase
// TODO At some point this will need to change.
const String hardwareVer = "2.1";
#endif
const String SAMversion = SAMverNum + "-" + String(__GIT_HASH__) + "-" + String(__GIT_BRANCH__); // mayor.minor.build-gitcommit-branch
const String SAMversion = SAMverNum + "-" + String(__GIT_HASH__) + "-" + String(__GIT_BRANCH__) + "-" + String(__PIO_ENV__); // mayor.minor.build-gitcommit-branch-platformioenv
const String SAMbuildDate = String(__ISO_DATE__);
String ESPversion = "not synced";
String ESPbuildDate = "not synced";
Expand Down
2 changes: 1 addition & 1 deletion tools
Submodule tools updated 2 files
+25 −8 git-rev.py
+9 −0 git-rev.sh

0 comments on commit ae48627

Please sign in to comment.