comparison 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
comparison
equal deleted inserted replaced
890:651d21777b61 891:a7f4451ba69e
920 } 920 }
921 921
922 #define SPEED_SLOW (5.0f) 922 #define SPEED_SLOW (5.0f)
923 #define SPEED_MEDIUM (10.0f) 923 #define SPEED_MEDIUM (10.0f)
924 #define SPEED_HIGH (15.0f) 924 #define SPEED_HIGH (15.0f)
925 #define SPEED_HYSTERESE (1.0f)
925 926
926 uint8_t drawingColor_from_ascentspeed(float speed) 927 uint8_t drawingColor_from_ascentspeed(float speed)
927 { 928 {
929 static uint8_t lastColor = 0;
930
928 uint8_t color = CLUT_Font020; 931 uint8_t color = CLUT_Font020;
929 932
930 if(speed >= SPEED_HIGH) 933 if((speed >= SPEED_HIGH) || ((lastColor == CLUT_WarningRed) && (speed >= SPEED_HIGH - SPEED_HYSTERESE)))
931 { 934 {
932 color = CLUT_WarningRed; 935 color = CLUT_WarningRed;
933 } 936 }
934 else if(speed >= SPEED_MEDIUM) 937 else if((speed >= SPEED_MEDIUM) || ((lastColor == CLUT_WarningYellow) && (speed >= SPEED_MEDIUM - SPEED_HYSTERESE)))
935 { 938 {
936 color = CLUT_WarningYellow; 939 color = CLUT_WarningYellow;
937 } 940 }
938 else if(speed >= SPEED_SLOW) 941 else if((speed >= SPEED_SLOW) || ((lastColor == CLUT_NiceGreen) && (speed >= SPEED_SLOW - SPEED_HYSTERESE)))
939 { 942 {
940 color = CLUT_NiceGreen; 943 color = CLUT_NiceGreen;
941 } 944 }
945 lastColor = color;
942 return color; 946 return color;
943 } 947 }
944 948
945 949