diff Discovery/Src/data_central.c @ 895:94535e672583 Evo_2_23

Zusammenf?hren
author heinrichsweikamp
date Wed, 18 Sep 2024 14:31:06 +0200
parents a7f4451ba69e
children d4622533271d
line wrap: on
line diff
--- a/Discovery/Src/data_central.c	Wed Sep 18 14:30:45 2024 +0200
+++ b/Discovery/Src/data_central.c	Wed Sep 18 14:31:06 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;
 }