Mercurial > public > ostc4
diff Discovery/Src/data_central.c @ 891:a7f4451ba69e Evo_2_23
Added hysteresis for ascent speed coloring:
In the previous version acenting with a speed close to the color limits caused a fast changing of the color for depth visiualization. To avoid this "blinking" a hysteresis has been added to the speed evaluation function.
author | ideenmodellierer |
---|---|
date | Tue, 10 Sep 2024 21:16:32 +0200 |
parents | e373e90a48db |
children | d4622533271d |
line wrap: on
line diff
--- a/Discovery/Src/data_central.c Fri Sep 06 18:43:30 2024 +0200 +++ b/Discovery/Src/data_central.c Tue Sep 10 21:16:32 2024 +0200 @@ -922,23 +922,27 @@ #define SPEED_SLOW (5.0f) #define SPEED_MEDIUM (10.0f) #define SPEED_HIGH (15.0f) +#define SPEED_HYSTERESE (1.0f) uint8_t drawingColor_from_ascentspeed(float speed) { + static uint8_t lastColor = 0; + uint8_t color = CLUT_Font020; - if(speed >= SPEED_HIGH) + if((speed >= SPEED_HIGH) || ((lastColor == CLUT_WarningRed) && (speed >= SPEED_HIGH - SPEED_HYSTERESE))) { color = CLUT_WarningRed; } - else if(speed >= SPEED_MEDIUM) + else if((speed >= SPEED_MEDIUM) || ((lastColor == CLUT_WarningYellow) && (speed >= SPEED_MEDIUM - SPEED_HYSTERESE))) { color = CLUT_WarningYellow; } - else if(speed >= SPEED_SLOW) + else if((speed >= SPEED_SLOW) || ((lastColor == CLUT_NiceGreen) && (speed >= SPEED_SLOW - SPEED_HYSTERESE))) { color = CLUT_NiceGreen; } + lastColor = color; return color; }