comparison Discovery/Src/tMenuEditCustom.c @ 835:717b460294cd Evo_2_23

Added autofocus for BF Navigation view: In case of activated autofocus feature for big font the navigation view will now be activated in case the OSTC4 is hold in horizontal position (like it is for example done if you take a bearing). The OSTC4 will return to the previous view in case the OSTC4 is no longer hold in horizontal position.
author Ideenmodellierer
date Sun, 17 Dec 2023 21:49:02 +0100
parents 2a8af51ab04d
children 8d6c35655d4d
comparison
equal deleted inserted replaced
834:2a8af51ab04d 835:717b460294cd
45 45
46 #define CV_PER_PAGE (5u) /* number of cv selections shown at one page */ 46 #define CV_PER_PAGE (5u) /* number of cv selections shown at one page */
47 #define MAX_BACKLIGHT_BOOST (2u) /* max number of backlight levels which may be increased during focus state */ 47 #define MAX_BACKLIGHT_BOOST (2u) /* max number of backlight levels which may be increased during focus state */
48 48
49 #define MAX_FOCUS_LIMITER (2u) /* max number for reducing the spot used for focus detection */ 49 #define MAX_FOCUS_LIMITER (2u) /* max number for reducing the spot used for focus detection */
50
51 /* defines for autofocus of compass */
52 #define AF_COMPASS_ACTIVATION_ANGLE (5.0f) /* angle for pitch and roll. Compass gets activated in case the value is smaller (OSTC4 hold in horitontal position */
53 #define AF_COMPASS_DEBOUNCE (10u) /* debouncing value to avoid compass activation during normal movement */
50 54
51 static uint8_t customviewsSubpage = 0; 55 static uint8_t customviewsSubpage = 0;
52 static uint8_t customviewsSubpageMax = 0; /* number of pages needed to display all selectable views */ 56 static uint8_t customviewsSubpageMax = 0; /* number of pages needed to display all selectable views */
53 static const uint8_t* pcv_curchangelist; 57 static const uint8_t* pcv_curchangelist;
54 /* Private function prototypes -----------------------------------------------*/ 58 /* Private function prototypes -----------------------------------------------*/
1091 } 1095 }
1092 1096
1093 uint8_t HandleAFCompass() 1097 uint8_t HandleAFCompass()
1094 { 1098 {
1095 static uint8_t debounce = 0; 1099 static uint8_t debounce = 0;
1096 static uint8_t lastState = 0; 1100 static uint8_t lastState = AF_VIEW_NOCHANGE;
1097 uint8_t detectionState = 0; 1101 uint8_t detectionState = AF_VIEW_NOCHANGE;
1098 1102
1099 float pitch = stateRealGetPointer()->lifeData.compass_pitch; 1103 float pitch = stateRealGetPointer()->lifeData.compass_pitch;
1100 float roll = stateRealGetPointer()->lifeData.compass_roll; 1104 float roll = stateRealGetPointer()->lifeData.compass_roll;
1101 1105
1102 if((pitch > -5.0) && (pitch < 5.0) && (roll > -5.0) && (roll < 5.0)) /* OSTC in horizontal position */ 1106 /* OSTC in horizontal position ?*/
1103 { 1107 if((pitch > -AF_COMPASS_ACTIVATION_ANGLE) && (pitch < AF_COMPASS_ACTIVATION_ANGLE) && (roll > -AF_COMPASS_ACTIVATION_ANGLE) && (roll < AF_COMPASS_ACTIVATION_ANGLE))
1104 if(debounce < 10) debounce++; 1108 {
1105 if(debounce == 10) 1109 if(debounce < AF_COMPASS_DEBOUNCE) debounce++;
1110 if(debounce == AF_COMPASS_DEBOUNCE)
1106 { 1111 {
1107 detectionState = 1; 1112 detectionState = AF_VIEW_ACTIVATED;
1108 // debounce = 0;
1109 // t3_select_customview(CVIEW_T3_Navigation);
1110 } 1113 }
1111 } 1114 }
1112 else 1115 else
1113 { 1116 {
1114 if(debounce > 0) debounce--; 1117 if(debounce > 0) debounce--;
1115 if(debounce == 0) 1118 if(debounce == 0)
1116 { 1119 {
1117 detectionState = 2; 1120 detectionState = AF_VIEW_DEACTIVATED;
1118 } 1121 }
1119 } 1122 }
1120 if(detectionState) /* no state change => return 0 */ 1123 if(detectionState) /* no state change => return 0 */
1121 { 1124 {
1122 if((detectionState == lastState)) 1125 if((detectionState == lastState))
1123 { 1126 {
1124 detectionState = 0; 1127 detectionState = AF_VIEW_NOCHANGE;
1125 } 1128 }
1126 else 1129 else
1127 { 1130 {
1128 lastState = detectionState; 1131 lastState = detectionState;
1129 } 1132 }