Skip to content

Commit

Permalink
Changed calibration logic to prevent passing to the next phase if any…
Browse files Browse the repository at this point in the history
… red cells are shown.
  • Loading branch information
gbevin committed May 15, 2021
1 parent f1d3a63 commit 1e81e9a
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions ls_calibration.ino
Original file line number Diff line number Diff line change
Expand Up @@ -430,22 +430,26 @@ boolean handleCalibrationRelease() {
int delta = calSampleRows[i1][i2].maxValue - calSampleRows[i1][i2].minValue;
if (delta > 1) {
cellPass = calSampleRows[i1][i2].pass;
calSampleRows[i1][i2].pass += 1;

// Adapt the color if the the delta is below expected values
if (delta <= 40) {
cellColor = COLOR_RED;
}
else if (delta <= 65) {
cellColor = COLOR_YELLOW;
}
// This is the first pass for a sensor, switch the led to cyan
else if (cellPass == 0) {
cellColor = COLOR_CYAN;
}
// This is the second pass for a sensor, switch the led to green
else if (cellPass > 0) {
cellColor = COLOR_GREEN;
else {
// Only advance the pass when at least a delta of 40 in X values is measured
calSampleRows[i1][i2].pass += 1;

if (delta <= 65) {
cellColor = COLOR_YELLOW;
}
// This is the first pass for a sensor, switch the led to cyan
else if (cellPass == 0) {
cellColor = COLOR_CYAN;
}
// This is the second pass for a sensor, switch the led to green
else if (cellPass > 0) {
cellColor = COLOR_GREEN;
}
}
}
}
Expand All @@ -459,22 +463,26 @@ boolean handleCalibrationRelease() {
int delta = calSampleCols[i1][i2].maxValue - calSampleCols[i1][i2].minValue;
if (delta > 1) {
cellPass = calSampleCols[i1][i2].pass;
calSampleCols[i1][i2].pass += 1;

// Adapt the color if the the delta is below expected values
if (delta <= 100) {
if (delta <= 110) {
cellColor = COLOR_RED;
}
else if (delta <= 180) {
cellColor = COLOR_YELLOW;
}
// This is the first pass for a sensor, switch the led to cyan
else if (cellPass == 0) {
cellColor = COLOR_CYAN;
}
// This is the second pass for a sensor, switch the led to green
else if (cellPass > 0) {
cellColor = COLOR_GREEN;
else {
// Only advance the pass when at least a delta of 110 in Y values is measured
calSampleCols[i1][i2].pass += 1;

if (delta <= 180) {
cellColor = COLOR_YELLOW;
}
// This is the first pass for a sensor, switch the led to cyan
else if (cellPass == 0) {
cellColor = COLOR_CYAN;
}
// This is the second pass for a sensor, switch the led to green
else if (cellPass > 0) {
cellColor = COLOR_GREEN;
}
}
}
}
Expand Down

0 comments on commit 1e81e9a

Please sign in to comment.