diff --git a/Claire.ino b/Claire.ino index d5ac353..97f93d9 100644 --- a/Claire.ino +++ b/Claire.ino @@ -581,6 +581,30 @@ static int colormap(float x) { return y; } +float colormapIaqi(void) +{ + float x = 0.0f; + float iaqi = iaqSensor.iaq; + + if (iaqi <= 50.0f) { + x = 1.0f; // Excellent + } else if (iaqi <= 100.0f) { + x = 2.0f; // Good + } else if (iaqi <= 150.0f) { + x = 4.0f; // Lightly polluted + } else if (iaqi <= 200.0f) { + x = 7.0f; // Moderately polluted + } else if (iaqi <= 250.0f) { + x = 9.0f; // Heavily polluted + } else if (iaqi <= 350.0f) { + x = 10.0f; // Severely polluted + } else { + x = 11.0f; // Extremely polluted + } + + return colormap(x); +} + static float buienradarMap(float x) { // Input: rain intensity (mm/h) // Output: floating point number which can be mapped on color scale @@ -814,9 +838,7 @@ static void updateLeds(void) { ledsSetPixelColor(IAQI_LED, r, g, b); if (hw_variant == HW_PROTO_V1) { - float x = iaqSensor.iaq / 40; - x = x < 1.0f ? 1.0f : x; - color = colormap(x); + color = colormapIaqi(); r = (color & 0xFF0000) >> 16; g = (color & 0x00FF00) >> 8;