Update to IAQI colormap
This commit is contained in:
parent
b05800e3f0
commit
971c3bcee2
28
Claire.ino
28
Claire.ino
|
@ -581,6 +581,30 @@ static int colormap(float x) {
|
||||||
return y;
|
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) {
|
static float buienradarMap(float x) {
|
||||||
// Input: rain intensity (mm/h)
|
// Input: rain intensity (mm/h)
|
||||||
// Output: floating point number which can be mapped on color scale
|
// 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);
|
ledsSetPixelColor(IAQI_LED, r, g, b);
|
||||||
|
|
||||||
if (hw_variant == HW_PROTO_V1) {
|
if (hw_variant == HW_PROTO_V1) {
|
||||||
float x = iaqSensor.iaq / 40;
|
color = colormapIaqi();
|
||||||
x = x < 1.0f ? 1.0f : x;
|
|
||||||
color = colormap(x);
|
|
||||||
|
|
||||||
r = (color & 0xFF0000) >> 16;
|
r = (color & 0xFF0000) >> 16;
|
||||||
g = (color & 0x00FF00) >> 8;
|
g = (color & 0x00FF00) >> 8;
|
||||||
|
|
Loading…
Reference in New Issue