Skip to content

Commit

Permalink
Improved display for averaging mode
Browse files Browse the repository at this point in the history
  • Loading branch information
myTonino committed Feb 23, 2016
1 parent afdb6fa commit 1a38890
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Tonino/tonino_lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void LCD::clear() {

// light up the dot of the first digit
void LCD::averaged(boolean dot) {
writeDigitRaw(0, 0 | (dot << 7));
writeDigitRaw(0, (displaybuffer[0] & 0b01111111) | (dot << 7));
writeDisplay();
}

Expand Down
18 changes: 12 additions & 6 deletions Tonino/tonino_tcs3200.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,19 @@ int32_t TCS3200::fitValue(sensorData *sd, float* raw, uint8_t colorMode, boolean
float v = (r / b) * _cal[0] + _cal[1];

// averaging
if (raw != NULL && *raw != 0.0 && abs(v - *raw) < AVERAGE_THRESHOLD) { // 0,011 correspond to about 1 Tonino value)
WRITEDEBUGLN("averaged:");
WRITEDEBUG(v);
WRITEDEBUG(SEPARATOR);
WRITEDEBUGLN(*raw);
v = (v + *raw) / 2.0;
if (raw != NULL && *raw != 0.0 && abs(v - *raw) < AVERAGE_THRESHOLD) {
WRITEDEBUGLN("averaged:");
WRITEDEBUG(v);
WRITEDEBUG(SEPARATOR);
WRITEDEBUGLN(*raw);
v = (v + *raw) / 2.0;
if (averaged != NULL) {
*averaged = true;
}
} else {
if (averaged != NULL) {
*averaged = false;
}
}

WRITEDEBUG(v);
Expand Down
2 changes: 1 addition & 1 deletion Tonino/tonino_tcs3200.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class TCS3200 {
// convert raw sensor data (in sd) into T-value using calibration and scaling
// return value is T-value
// if raw is not NULL, it contains the calibrated single value
int32_t fitValue(sensorData *sd, float* raw, uint8_t colorMode = COLOR_FULL, boolean* averaged = NULL);
int32_t fitValue(sensorData *sd, float *raw, uint8_t colorMode = COLOR_FULL, boolean *averaged = NULL);
};

#endif

0 comments on commit 1a38890

Please sign in to comment.