Making some adjustments to IR auto calibration

This commit is contained in:
skogaby
2020-10-21 03:07:39 -05:00
parent 37337d7c65
commit 3049a27f24
2 changed files with 11 additions and 8 deletions
+8 -6
View File
@@ -120,14 +120,16 @@ void AirSensor::analogCalibrate() {
}
// take some initial readings before the main loop so we can establish baselines
uint16_t max_values[6] = { 0, 0, 0, 0, 0, 0 };
for (int sample = 0; sample < CALIBRATION_SAMPLES; sample++) {
for (int i = 0; i < 6; i++) {
max_values[i] = max(max_values[i], getValue(i));
}
}
for (int i = 0; i < 6; i++) {
// determine the current thresholds for trigger
// and release based on the configured delta threhsold
// and the current readings
uint16_t value = getValue(i);
states[i] = false;
calcThresholds(i, value);
calcThresholds(i, max_values[i]);
}
#endif
+3 -2
View File
@@ -20,7 +20,8 @@
#include <FastLED.h>
#define AIR_LED_DELAY 135
#define AIR_LED_DELAY 100
#define CALIBRATION_SAMPLES 100
#ifndef KEY_DIVIDERS
extern CRGB leds[16];
@@ -30,7 +31,7 @@ extern CRGB leds[31];
class AirSensor {
private:
int deltaThreshold = 80;
int deltaThreshold = 45;
double releaseThreshold = 0.5;
int calibrationCounter;
bool calibrated;