Mercurial > public > ostc4
annotate Discovery/Src/motion.c @ 645:e58f81cb25a7
Small changes in charger state handling:
Charger debounce time has been reduced to 5 seconds and the detection time of charger removal has been reduced to 15 second to be able to provide a faster feedback to the user.
In addition the battery stage reset has been added (only relevant for a getState function which is not used within the firmware at the moment.
author | Ideenmodellierer |
---|---|
date | Tue, 13 Apr 2021 19:18:32 +0200 |
parents | c737cf5d9067 |
children | ff2b393e290f |
rev | line source |
---|---|
359
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
1 /* |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
2 * motion.c |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
3 * |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
4 * Created on: 20.05.2019 |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
5 * Author: Thorsten Sonntag |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
6 */ |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
7 |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
8 #include <stdint.h> |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
9 #include <string.h> |
373
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
10 #include <stdlib.h> |
359
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
11 #include <math.h> |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
12 #include "motion.h" |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
13 #include "data_central.h" |
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
14 #include "t7.h" |
384
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
383
diff
changeset
|
15 #include "t3.h" |
371
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
16 #include "settings.h" |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
17 #include "base.h" |
359
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
18 |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
19 #define STABLE_STATE_COUNT 2 /* number of count to declare a state as stable (at the moment based on 100ms) */ |
363 | 20 #define STABLE_STATE_TIMEOUT 5 /* Detection shall be aborted if a movement state is stable for more than 500ms */ |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
21 |
385
0cd862e501f6
Finetune parameter for detection of small sectors as used for the pitch detection
ideenmodellierer
parents:
384
diff
changeset
|
22 #define SECTOR_MAX 24 /* maximum number of sectors */ |
378
834e087505ec
Incremented "idle window" for scroll detection
ideenmodellierer
parents:
373
diff
changeset
|
23 #define SECTOR_SCROLL 7 /* number of sectors used for scroll detection */ |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
24 #define SECTOR_MAX_CNT 5 /* max number of views used for sector control */ |
359
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
25 |
627 | 26 |
27 typedef enum | |
28 { | |
29 MOTION_DELTA_STABLE = 0, | |
30 MOTION_DELTA_JITTER, | |
31 MOTION_DELTA_RAISE, | |
32 MOTION_DELTA_RAISE_FAST, | |
33 MOTION_DELTA_FALL, | |
34 MOTION_DELTA_FALL_FAST | |
35 } MotionDeltaState_t; | |
551 | 36 |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
37 #define MOTION_DELTA_JITTER_LEVEL 2.0 /* lower values are considered as stable */ |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
38 #define MOTION_DELTA_RAISE_LEVEL 4.0 /* Movement causing a significant change detected */ |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
39 #define MOTION_DELTA_FALL_LEVEL -4.0 /* Movement causing a significant change detected */ |
627 | 40 #define MOTION_DELTA_FAST_LEVEL 6.0 /* Movement causing a fast change detected */ |
551 | 41 |
42 #define MOTION_DELTA_HISTORY_SIZE 20 /* Number of history data sets */ | |
43 | |
627 | 44 #define MOTION_FOCUS_LIMIT 0.5 /* +/- value which defines the border of the focus area */ |
45 #define MOTION_FOCUS_USE_SECTOR 0.4 /* +/- value for the focus area used to map secors to views */ | |
46 #define MOTION_FOCUS_SCROLL_IDLE 0.3 /* +/- value for starting generation of scroll events */ | |
47 | |
385
0cd862e501f6
Finetune parameter for detection of small sectors as used for the pitch detection
ideenmodellierer
parents:
384
diff
changeset
|
48 detectionState_t detectionState = DETECT_NOTHING; |
0cd862e501f6
Finetune parameter for detection of small sectors as used for the pitch detection
ideenmodellierer
parents:
384
diff
changeset
|
49 SSector sectorDetection; |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
50 |
551 | 51 static uint8_t motionDeltaHistory[3][MOTION_DELTA_HISTORY_SIZE]; /* Change history of roll, pitch and yaw */ |
52 static uint8_t motionDeltaHistoryIdx; /* Current index of history data */ | |
53 | |
54 static uint8_t focusCnt = 0; | |
55 static uint8_t inFocus = 0; | |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
56 static uint8_t sectorMap[SECTOR_MAX_CNT]; |
551 | 57 |
611
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
58 static uint8_t suspendMotionDetectionSec = 0; |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
59 |
551 | 60 void resetMotionDeltaHistory() |
61 { | |
62 motionDeltaHistoryIdx = 0; | |
63 memset(motionDeltaHistory, 0, sizeof(motionDeltaHistory)); | |
64 } | |
65 | |
66 void evaluateMotionDelta(float roll, float pitch, float yaw) | |
67 { | |
68 static float lastValue[3] = {0.0,0.0,0.0}; | |
69 uint8_t nextIndex = motionDeltaHistoryIdx + 1; | |
70 uint8_t axis; | |
71 float curValue; | |
72 | |
73 if(nextIndex == MOTION_DELTA_HISTORY_SIZE) | |
74 { | |
75 nextIndex = 0; | |
76 } | |
77 for(axis=0; axis < 3; axis++) | |
78 { | |
79 switch(axis) | |
80 { | |
81 case MOTION_HISTORY_ROLL: curValue = roll; | |
82 break; | |
83 case MOTION_HISTORY_PITCH: curValue = pitch; | |
84 break; | |
85 default: | |
86 case MOTION_HISTORY_YAW: if((yaw < 90) && (lastValue[MOTION_HISTORY_YAW] > 270.0)) /* transition 360 => 0 */ | |
87 { | |
88 lastValue[MOTION_HISTORY_YAW] -= 360; | |
89 } | |
90 else if((yaw > 270) && (lastValue[MOTION_HISTORY_YAW] < 90.0)) /* transition 0 => 360 */ | |
91 { | |
92 lastValue[MOTION_HISTORY_YAW] += 360; | |
93 } | |
94 curValue = yaw; | |
95 break; | |
96 } | |
97 if(curValue - lastValue[axis] > MOTION_DELTA_RAISE_LEVEL) | |
98 { | |
99 motionDeltaHistory[axis][nextIndex] = MOTION_DELTA_RAISE; | |
100 } | |
101 if(fabsf(curValue - lastValue[axis]) < MOTION_DELTA_RAISE_LEVEL) | |
102 { | |
103 motionDeltaHistory[axis][nextIndex] = MOTION_DELTA_JITTER; | |
104 } | |
105 if(fabsf(curValue - lastValue[axis]) < MOTION_DELTA_JITTER_LEVEL) | |
106 { | |
107 motionDeltaHistory[axis][nextIndex] = MOTION_DELTA_STABLE; | |
108 } | |
109 if(curValue - lastValue[axis] < MOTION_DELTA_FALL_LEVEL) | |
110 { | |
111 motionDeltaHistory[axis][nextIndex] = MOTION_DELTA_FALL; | |
112 } | |
627 | 113 |
114 if(fabsf(curValue - lastValue[axis]) > MOTION_DELTA_FAST_LEVEL) | |
115 { | |
116 motionDeltaHistory[axis][nextIndex]++; | |
117 } | |
118 | |
551 | 119 lastValue[axis] = curValue; |
120 } | |
121 motionDeltaHistoryIdx = nextIndex; | |
122 } | |
123 | |
124 SDeltaHistory GetDeltaHistory(uint8_t stepback) | |
125 { | |
578 | 126 uint8_t loop; |
551 | 127 uint8_t index = motionDeltaHistoryIdx; |
128 | |
129 SDeltaHistory result = {0,0,0}; | |
130 | |
627 | 131 loop = stepback + 1; /* motionDeltaHistoryIdx is pointing to future entry => step back one more to get the latest */ |
551 | 132 if(stepback < MOTION_DELTA_HISTORY_SIZE) |
133 { | |
134 while(loop != 0) /* find requested entry */ | |
135 { | |
136 loop--; | |
137 index--; | |
138 if(index == 0) | |
139 { | |
140 index = MOTION_DELTA_HISTORY_SIZE - 1; | |
141 } | |
142 } | |
143 result.roll = motionDeltaHistory[MOTION_HISTORY_ROLL][index]; | |
144 result.pitch = motionDeltaHistory[MOTION_HISTORY_PITCH][index]; | |
145 result.yaw = motionDeltaHistory[MOTION_HISTORY_YAW][index]; | |
146 } | |
147 return result; | |
148 } | |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
149 |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
150 uint8_t GetSectorForFocus(float focusOffset) |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
151 { |
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
152 uint8_t sector = 0; |
627 | 153 float compare = -1.0 * MOTION_FOCUS_USE_SECTOR + sectorDetection.size ; /* start with first sector upper limit */ |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
154 |
627 | 155 while(compare <= MOTION_FOCUS_USE_SECTOR) |
381 | 156 { |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
157 if(focusOffset > compare) |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
158 { |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
159 sector++; |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
160 } |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
161 else |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
162 { |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
163 break; |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
164 } |
627 | 165 compare += sectorDetection.size; |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
166 } |
627 | 167 if(sector >= sectorDetection.count) |
381 | 168 { |
627 | 169 sector = sectorDetection.count - 1; |
381 | 170 } |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
171 return sector; |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
172 } |
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
173 |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
174 void DefineSectorCount(uint8_t numOfSectors) |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
175 { |
371
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
176 if(numOfSectors == CUSTOMER_DEFINED_VIEWS) |
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
177 { |
384
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
383
diff
changeset
|
178 if(settingsGetPointer()->design == 3) /* Big font view ? */ |
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
383
diff
changeset
|
179 { |
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
383
diff
changeset
|
180 sectorDetection.count = t3_GetEnabled_customviews(); |
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
383
diff
changeset
|
181 } |
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
383
diff
changeset
|
182 else |
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
383
diff
changeset
|
183 { |
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
383
diff
changeset
|
184 sectorDetection.count = t7_GetEnabled_customviews(); |
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
383
diff
changeset
|
185 } |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
186 if(sectorDetection.count > SECTOR_MAX_CNT) |
371
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
187 { |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
188 sectorDetection.count = SECTOR_MAX_CNT; /* more views are hard to manually control */ |
371
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
189 } |
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
190 } |
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
191 else |
373
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
192 if(numOfSectors != CUSTOMER_KEEP_LAST_SECTORS) |
371
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
193 { |
383
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
381
diff
changeset
|
194 sectorDetection.count = numOfSectors; |
371
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
195 } |
627 | 196 sectorDetection.size = MOTION_FOCUS_USE_SECTOR * 2.0 / sectorDetection.count; |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
197 } |
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
198 |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
199 |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
200 uint8_t GetCVForSector(uint8_t selSector) |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
201 { |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
202 if(selSector < sectorDetection.count) |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
203 { |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
204 return sectorMap[selSector]; |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
205 } |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
206 else |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
207 { |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
208 return 0; |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
209 } |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
210 } |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
211 |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
212 void MapCVToSector() |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
213 { |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
214 uint8_t ViewIndex = 0; |
627 | 215 memset(sectorMap, 0, sizeof(sectorMap)); |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
216 |
627 | 217 while(ViewIndex < (sectorDetection.count / 2)) /* define center sector */ |
218 { | |
219 ViewIndex++; | |
220 } | |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
221 |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
222 if(settingsGetPointer()->design == 3) /* Big font view ? */ |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
223 { |
595 | 224 t3_set_customview_to_primary(); |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
225 sectorMap[ViewIndex] = t3_change_customview(ACTION_END); |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
226 } |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
227 else |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
228 { |
595 | 229 t7_set_customview_to_primary(); |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
230 sectorMap[ViewIndex] = t7_change_customview(ACTION_END); |
595 | 231 |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
232 } |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
233 |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
234 ViewIndex++; |
627 | 235 while(sectorMap[ViewIndex] == 0) |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
236 { |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
237 if(settingsGetPointer()->design == 3) /* Big font view ? */ |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
238 { |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
239 sectorMap[ViewIndex] = t3_change_customview(ACTION_BUTTON_ENTER); |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
240 } |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
241 else |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
242 { |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
243 sectorMap[ViewIndex] = t7_change_customview(ACTION_BUTTON_ENTER); |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
244 } |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
245 ViewIndex++; |
627 | 246 if(ViewIndex == sectorDetection.count) |
247 { | |
248 ViewIndex = 0; | |
249 } | |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
250 } |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
251 |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
252 } |
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
253 |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
254 void InitMotionDetection(void) |
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
255 { |
383
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
381
diff
changeset
|
256 sectorDetection.target = 0; |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
381
diff
changeset
|
257 sectorDetection.current = 0; |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
381
diff
changeset
|
258 sectorDetection.size = 0; |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
381
diff
changeset
|
259 sectorDetection.count = 0; |
371
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
260 |
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
261 switch(settingsGetPointer()->MotionDetection) |
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
262 { |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
263 case MOTION_DETECT_SECTOR: DefineSectorCount(CUSTOMER_DEFINED_VIEWS); |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
264 MapCVToSector(); |
371
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
265 break; |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
266 case MOTION_DETECT_MOVE: DefineSectorCount(SECTOR_MAX); |
371
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
267 break; |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
268 case MOTION_DETECT_SCROLL: DefineSectorCount(SECTOR_SCROLL); |
373
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
269 break; |
371
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
270 default: |
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
271 break; |
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
272 } |
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
273 |
551 | 274 resetMotionDeltaHistory(); |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
275 } |
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
276 |
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
277 /* Map the current pitch value to a sector and create button event in case the sector is left */ |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
278 detectionState_t detectSectorButtonEvent(float focusOffset) |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
279 { |
642
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
280 static uint8_t lastTargetSector = 0xFF; |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
281 static float lastfocusOffset = 0.0; |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
282 |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
283 uint8_t newTargetSector; |
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
284 |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
285 newTargetSector = GetSectorForFocus(focusOffset); |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
286 |
642
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
287 /* take a small hysteresis into account to avoid fast display changes (flicker) */ |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
288 if((newTargetSector != lastTargetSector) && (fabsf(focusOffset - lastfocusOffset) > (sectorDetection.size / 3))) |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
289 { |
642
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
290 lastfocusOffset = focusOffset; |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
291 if(settingsGetPointer()->design == 3) /* Big font view ? */ |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
292 { |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
293 t3_select_customview(GetCVForSector(newTargetSector)); |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
294 } |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
295 else |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
296 { |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
297 t7_select_customview(GetCVForSector(newTargetSector)); |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
298 } |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
299 } |
592
f52bc70e380f
MotionCtrl - Sectorview Map sectors directly to custom views:
Ideenmodellierer
parents:
585
diff
changeset
|
300 return DETECT_NOTHING; |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
301 } |
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
302 |
373
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
303 /* Check if pitch is not in center position and trigger a button action if needed */ |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
304 detectionState_t detectScrollButtonEvent(float focusOffset) |
373
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
305 { |
378
834e087505ec
Incremented "idle window" for scroll detection
ideenmodellierer
parents:
373
diff
changeset
|
306 static uint8_t delayscroll = 0; /* slow down the number of scroll events */ |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
307 |
373
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
308 uint8_t PitchEvent = DETECT_NOTHING; |
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
309 |
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
310 if(delayscroll == 0) |
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
311 { |
627 | 312 if(focusOffset > MOTION_FOCUS_SCROLL_IDLE) |
373
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
313 { |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
314 PitchEvent = DETECT_POS_PITCH; |
574 | 315 delayscroll = 7; |
373
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
316 } |
627 | 317 if(focusOffset < (-1.0 * MOTION_FOCUS_SCROLL_IDLE)) |
318 { | |
319 PitchEvent = DETECT_NEG_PITCH; | |
320 delayscroll = 7; | |
321 } | |
373
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
322 } |
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
323 else |
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
324 { |
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
325 delayscroll--; |
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
326 } |
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
327 return PitchEvent; |
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
328 } |
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
329 |
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
330 |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
331 /* Detect if user is generating an pitch including return to starting position */ |
359
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
332 /* This is done by feeding the past movements value per value into a state machine */ |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
333 detectionState_t detectPitch(float currentPitch) |
359
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
334 { |
578 | 335 static int8_t lastStart = 0; |
551 | 336 uint8_t exit = 0; |
578 | 337 int8_t step = 0; |
574 | 338 uint8_t duration = 0; |
551 | 339 SDeltaHistory test; |
370
77cdfbdaca8c
Changed function names from shake to pitch and improved detection function: Shake might be confusing for people reading the code because pitch values are ased for calculation => changed name to pitch to be more transparent
ideenmodellierer
parents:
363
diff
changeset
|
340 |
578 | 341 if(lastStart < 0) |
342 { | |
343 detectionState = DETECT_NOTHING; | |
344 lastStart = 0; | |
345 } | |
346 else | |
347 { | |
348 detectionState = DETECT_START; | |
349 } | |
350 step = lastStart; | |
351 do | |
551 | 352 { |
353 test = GetDeltaHistory(step); | |
574 | 354 duration++; |
551 | 355 switch (detectionState) |
356 { | |
357 case DETECT_NOTHING: if(test.pitch > MOTION_DELTA_STABLE) | |
358 { | |
359 exit = 1; | |
578 | 360 lastStart = -2; |
551 | 361 } |
362 else | |
363 { | |
364 detectionState = DETECT_START; | |
578 | 365 lastStart = -1; |
551 | 366 } |
367 break; | |
368 case DETECT_START: if(test.pitch == MOTION_DELTA_RAISE) | |
369 { | |
370 detectionState = DETECT_POS_MOVE; | |
578 | 371 lastStart = step; |
551 | 372 } |
578 | 373 else |
551 | 374 if(test.pitch == MOTION_DELTA_FALL) |
375 { | |
376 detectionState = DETECT_NEG_MOVE; | |
578 | 377 lastStart = step; |
378 } | |
379 else | |
380 { | |
381 lastStart = -1; | |
551 | 382 } |
574 | 383 duration = 0; |
551 | 384 break; |
627 | 385 case DETECT_NEG_MOVE: if((test.pitch <= MOTION_DELTA_JITTER) || (test.pitch == MOTION_DELTA_RAISE) || (test.pitch == MOTION_DELTA_RAISE_FAST)) |
578 | 386 { |
387 detectionState++; | |
388 } | |
389 break; | |
627 | 390 case DETECT_POS_MOVE: if((test.pitch <= MOTION_DELTA_JITTER) || (test.pitch == MOTION_DELTA_FALL) || (test.pitch == MOTION_DELTA_FALL_FAST)) |
551 | 391 { |
392 detectionState++; | |
393 } | |
394 break; | |
395 case DETECT_MAXIMA: if(test.pitch == MOTION_DELTA_FALL) | |
396 { | |
397 detectionState = DETECT_FALLBACK; | |
398 } | |
399 break; | |
400 case DETECT_MINIMA: if(test.pitch == MOTION_DELTA_RAISE) | |
401 { | |
402 detectionState = DETECT_RISEBACK; | |
403 } | |
404 break; | |
405 case DETECT_RISEBACK: | |
406 case DETECT_FALLBACK: if(test.pitch == MOTION_DELTA_STABLE) | |
407 { | |
578 | 408 if(duration > 4) /* avoid detection triggered by short moves */ |
574 | 409 { |
410 detectionState++; | |
411 } | |
578 | 412 exit = 1; |
413 lastStart = -2; | |
551 | 414 } |
415 break; | |
416 default: | |
417 detectionState = DETECT_NOTHING; | |
418 exit = 1; | |
419 break; | |
420 } | |
578 | 421 step--; |
422 } while((step >= 0) && (!exit)); | |
423 | |
424 if((lastStart < MOTION_DELTA_HISTORY_SIZE)) | |
425 { | |
426 lastStart++; /* prepare value for next iteration (history index will be increased) */ | |
427 } | |
428 else | |
429 { | |
430 lastStart = -1; | |
551 | 431 } |
432 if((detectionState != DETECT_POS_PITCH) && (detectionState != DETECT_NEG_PITCH)) /* nothing found */ | |
359
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
433 { |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
434 detectionState = DETECT_NOTHING; |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
435 } |
551 | 436 else /* dont detect the same event twice */ |
437 { | |
438 resetMotionDeltaHistory(); | |
439 } | |
440 return detectionState; | |
441 } | |
363 | 442 |
551 | 443 void anglesToCoord(float roll, float pitch, float yaw, SCoord *pCoord) |
444 { | |
445 pCoord->x = ((cosf(yaw) * cosf(pitch)) * pCoord->x + (cosf(yaw)*sinf(pitch)*sinf(roll) - (sinf(yaw)* cosf(roll))) * pCoord->y + (cosf(yaw)*sinf(pitch)*cosf(roll) + sinf(yaw)*sinf(roll)) * pCoord->z); | |
446 pCoord->y = ((sinf(yaw) * cosf(pitch)) * pCoord->x + (sinf(yaw)*sinf(pitch)*sinf(roll) + cosf(yaw) * cosf(roll)) * pCoord->y + ( sinf(yaw) * sinf(pitch) * cosf(roll) - cosf(yaw) * sinf(roll))* pCoord->z); | |
447 pCoord->z = ((-1*sinf(pitch)) * pCoord->x + (cosf(pitch) *sinf(roll)) * pCoord->y + (cosf(pitch) * cosf(roll))* pCoord->z); | |
448 } | |
449 | |
450 SCoord CoordAdd(SCoord cA, SCoord cB) | |
451 { | |
452 SCoord result; | |
453 | |
454 result.x = cA.x + cB.x; | |
455 result.y = cA.y + cB.y; | |
456 result.z = cA.z + cB.z; | |
457 return result; | |
458 } | |
459 | |
460 SCoord CoordSub(SCoord cA, SCoord cB) | |
461 { | |
462 SCoord result; | |
373
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
463 |
551 | 464 result.x = cA.x - cB.x; |
465 result.y = cA.y - cB.y; | |
466 result.z = cA.z - cB.z; | |
467 return result; | |
468 } | |
469 | |
470 SCoord CoordCross(SCoord cA, SCoord cB) | |
471 { | |
472 SCoord result; | |
473 | |
474 result.x = (cA.y * cB.z) - (cA.z * cB.y); | |
475 result.y = (cA.z * cB.x) - (cA.x * cB.z); | |
476 result.z = (cA.x * cB.y) - (cA.y * cB.x); | |
477 | |
478 return result; | |
479 | |
480 } | |
481 | |
482 SCoord CoordMulF(SCoord op, float factor) | |
483 { | |
484 SCoord result; | |
485 result.x = (op.x * factor); | |
486 result.y = (op.y * factor); | |
487 result.z = (op.z * factor); | |
488 | |
489 return result; | |
490 } | |
373
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
491 |
551 | 492 SCoord CoordDivF(SCoord op, float factor) |
493 { | |
494 SCoord result; | |
495 result.x = (op.x / factor); | |
496 result.y = (op.y / factor); | |
497 result.z = (op.z / factor); | |
498 | |
499 return result; | |
500 } | |
501 | |
502 float CoordDot(SCoord cA, SCoord cB) | |
503 { | |
504 float result; | |
505 | |
506 result = cA.x * cB.x + cA.y * cB.y + cB.z*cA.z; | |
507 return result; | |
508 } | |
509 | |
510 void calibrateViewport(float roll, float pitch, float yaw) | |
511 { | |
512 SSettings* pSettings = settingsGetPointer(); | |
513 | |
621 | 514 pSettings->viewPitch = pitch + 180; |
515 pSettings->viewRoll = roll+ 180; | |
551 | 516 pSettings->viewYaw = yaw; |
517 } | |
518 | |
519 | |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
520 float checkViewport(float roll, float pitch, float yaw, uint8_t enableAxis) |
551 | 521 { |
522 uint8_t retval = 0; | |
523 float angleYaw; | |
524 float anglePitch; | |
525 float angleRoll; | |
526 float distance = 0; | |
527 float _a, _b; | |
528 SCoord u,v,n; | |
627 | 529 float r = 0.0; |
530 float focusLimit = 0; | |
551 | 531 |
532 SCoord refVec; | |
533 SCoord axis_1; | |
534 SCoord axis_2; | |
535 SCoord curVec; | |
536 SCoord resultVec; | |
537 | |
627 | 538 SDeltaHistory movementDelta; |
539 | |
551 | 540 SSettings* pSettings = settingsGetPointer(); |
541 | |
621 | 542 roll += 180; |
543 pitch += 180; | |
544 | |
551 | 545 /* calculate base vector taking calibration delta into account yaw (heading) */ |
621 | 546 float compYaw; |
574 | 547 |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
548 if(enableAxis & MOTION_ENABLE_YAW) |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
549 { |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
550 compYaw = 360.0 - yaw; /* turn to 0° */ |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
551 compYaw += pSettings->viewYaw; /* consider calib yaw value */ |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
552 compYaw += yaw; |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
553 |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
554 if (compYaw < 0.0) |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
555 { |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
556 compYaw = 360.0 + compYaw; |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
557 } |
574 | 558 |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
559 if (compYaw > 360.0) |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
560 { |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
561 compYaw = compYaw - 360.0; |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
562 } |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
563 if (compYaw > 360.0) |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
564 { |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
565 compYaw = compYaw - 360.0; |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
566 } |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
567 angleYaw = pSettings->viewYaw * M_PI / 180.0; |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
568 } |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
569 else |
551 | 570 { |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
571 compYaw = 0.0; |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
572 angleYaw = 0.0; |
381 | 573 } |
551 | 574 |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
575 if(enableAxis & MOTION_ENABLE_PITCH) |
381 | 576 { |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
577 anglePitch = pSettings->viewPitch * M_PI / 180.0; |
373
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
578 } |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
579 else |
574 | 580 { |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
581 anglePitch = 0; |
574 | 582 } |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
583 if(enableAxis & MOTION_ENABLE_ROLL) |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
584 { |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
585 angleRoll = pSettings->viewRoll * M_PI / 180.0; |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
586 } |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
587 else |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
588 { |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
589 angleRoll = 0; |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
590 } |
551 | 591 |
592 refVec.x = 0; | |
593 refVec.y = 0; | |
594 refVec.z = 1.0; | |
595 | |
596 anglesToCoord(angleRoll,anglePitch,angleYaw, &refVec); | |
597 | |
598 /* assume x = 0 and y = 1 => find matching vector so axis_1 is 90° to axis_2 */ | |
599 axis_1.x = 0; | |
600 if(refVec.y >=0) | |
601 { | |
602 axis_2.y = 1; /* => Spawn y == refVec y */ | |
603 } | |
604 else axis_1.y = -1; | |
605 axis_1.z = -1.0 * refVec.y / refVec.z; | |
606 axis_2 = CoordCross(refVec, axis_1); /* Cross is 90° to refVec and Spawn as well => Plane Spawn / cross */ | |
607 | |
608 /* check if detection plane is correct */ | |
609 u = CoordSub(axis_1,refVec); | |
610 v = CoordSub(axis_2,refVec); | |
611 n = CoordCross(u,v); | |
612 | |
613 if((fabsf(n.x) <= 0.0001) && (fabsf(n.y) <= 0.0001) && (fabsf(n.z) <= 0.0001)) | |
614 { | |
615 retval = 2; | |
616 } | |
617 else | |
618 { | |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
619 if(enableAxis & MOTION_ENABLE_PITCH) |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
620 { |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
621 anglePitch = pitch * M_PI / 180.0; |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
622 } |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
623 else |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
624 { |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
625 anglePitch = 0.0; |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
626 } |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
627 if(enableAxis & MOTION_ENABLE_ROLL) |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
628 { |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
629 angleRoll = roll * M_PI / 180.0; |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
630 } |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
631 else |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
632 { |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
633 angleRoll = 0.0; |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
634 } |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
635 if(enableAxis & MOTION_ENABLE_YAW) |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
636 { |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
637 angleYaw = compYaw * M_PI / 180.0; |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
638 } |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
639 else |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
640 { |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
641 angleYaw = 0.0; |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
642 } |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
643 |
551 | 644 curVec.x = 0; |
645 curVec.y = 0; | |
646 curVec.z = 1.0; | |
647 anglesToCoord(angleRoll,anglePitch,angleYaw, &curVec); | |
648 | |
649 _a = CoordDot(curVec,n); | |
650 _b = CoordDot(refVec,n); | |
651 | |
652 if(_b>=(-0.0001)&&_b<=0.0001) /* Check if view port is parallel (no matchpoint) */ | |
653 { | |
654 retval = 3; | |
655 } | |
656 else | |
657 { | |
658 r=_a/_b; | |
659 if(r<0.00||r>1.40) /* are we looking into wrong direction? */ | |
660 { | |
661 retval = 4; | |
662 } | |
663 } | |
664 distance = retval * 1.0; /* just for debugging */ | |
665 if(retval == 0) | |
666 { | |
667 /* start calculating the matchpoint */ | |
668 curVec = CoordMulF(curVec,r); | |
669 resultVec = CoordSub(refVec,curVec); | |
670 | |
671 /* calculate the distance between reference and actual vector */ | |
672 resultVec.x = resultVec.x * resultVec.x; | |
673 resultVec.y = resultVec.y * resultVec.y; | |
674 resultVec.z = resultVec.z * resultVec.z; | |
675 | |
676 if((resultVec.x == 0) && (resultVec.y == 0) && (resultVec.z == 0)) | |
677 { | |
678 distance = 0.0; | |
679 } | |
680 else | |
681 { | |
682 distance = sqrtf((resultVec.x + resultVec.y + resultVec.z)); | |
683 } | |
684 } | |
685 } | |
686 | |
627 | 687 movementDelta = GetDeltaHistory(0); |
688 | |
689 if(inFocus == 0) /* consider option to use smaller spot to detect focus state */ | |
690 { | |
691 focusLimit = MOTION_FOCUS_LIMIT - (((pSettings->viewPortMode >> 5) & 0x03) / 10.0); | |
692 } | |
693 else | |
694 { | |
695 focusLimit = MOTION_FOCUS_LIMIT; /* use standard spot to detect diver interactions */ | |
696 } | |
697 | |
698 if((distance <= focusLimit) && (movementDelta.yaw != MOTION_DELTA_RAISE_FAST) && (movementDelta.yaw != MOTION_DELTA_FALL_FAST)) /* handle focus counter to avoid fast in/out focus changes */ | |
551 | 699 { |
700 if(focusCnt < 10) | |
701 { | |
702 if((focusCnt == 9) && (inFocus == 0)) /* we will get into focus */ | |
703 { | |
704 resetMotionDeltaHistory(); | |
705 } | |
706 focusCnt++; | |
707 } | |
574 | 708 if((focusCnt == 10) && (inFocus == 0)) |
551 | 709 { |
710 inFocus = 1; | |
711 } | |
712 } | |
713 else | |
714 { | |
627 | 715 if((movementDelta.yaw > MOTION_DELTA_JITTER ) && (focusCnt >= 5)) |
716 { | |
717 focusCnt--; | |
718 } | |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
719 if(focusCnt >= 5) /* Reset focus faster then setting focus */ |
551 | 720 { |
721 focusCnt--; | |
722 } | |
723 else | |
724 { | |
574 | 725 focusCnt = 0; |
551 | 726 inFocus = 0; |
727 } | |
728 } | |
627 | 729 if ((r<1) && (retval == 0)) /* add direction information to distance */ |
730 { | |
731 distance *= -1.0; | |
732 } | |
551 | 733 return distance; |
359
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
734 } |
551 | 735 uint8_t viewInFocus(void) |
736 { | |
737 return inFocus; | |
738 } | |
739 void resetFocusState(void) | |
740 { | |
741 inFocus = 0; | |
742 } | |
611
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
743 |
642
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
744 uint8_t viewDetectionSuspended(void) |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
745 { |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
746 uint8_t retVal = 0; |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
747 |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
748 if(suspendMotionDetectionSec) |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
749 { |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
750 retVal = 1; |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
751 } |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
752 return retVal; |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
753 } |
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
627
diff
changeset
|
754 |
611
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
755 void suspendMotionDetection(uint8_t seconds) |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
756 { |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
757 suspendMotionDetectionSec = seconds * 10; /* detection function is called every 100ms */ |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
758 } |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
759 |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
760 void HandleMotionDetection(void) |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
761 { |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
762 detectionState_t pitchstate = DETECT_NOTHING; |
618
96af74455420
Development bugfix: focus state not remembered:
Ideenmodellierer
parents:
611
diff
changeset
|
763 static uint8_t wasInFocus = 0; |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
764 float focusOffset = 0.0; |
611
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
765 |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
766 evaluateMotionDelta(stateUsed->lifeData.compass_roll, stateUsed->lifeData.compass_pitch, stateUsed->lifeData.compass_heading); |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
767 if(viewInFocus()) |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
768 { |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
769 focusOffset = checkViewport(stateUsed->lifeData.compass_roll, stateUsed->lifeData.compass_pitch, stateUsed->lifeData.compass_heading, (MOTION_ENABLE_PITCH | MOTION_ENABLE_YAW)); |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
770 } |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
771 else |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
772 { |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
773 focusOffset = checkViewport(stateUsed->lifeData.compass_roll, stateUsed->lifeData.compass_pitch, stateUsed->lifeData.compass_heading, MOTION_ENABLE_ALL); |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
774 } |
611
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
775 if(viewInFocus()) |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
776 { |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
777 wasInFocus = 1; |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
778 set_Backlight_Boost(settingsGetPointer()->viewPortMode & 0x03); |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
779 |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
780 if(suspendMotionDetectionSec == 0) /* suspend detection while diver is manually operating the OSTC */ |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
781 { |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
782 switch(settingsGetPointer()->MotionDetection) |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
783 { |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
784 case MOTION_DETECT_MOVE: pitchstate = detectPitch(stateRealGetPointer()->lifeData.compass_pitch); |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
785 break; |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
621
diff
changeset
|
786 case MOTION_DETECT_SECTOR: pitchstate = detectSectorButtonEvent(focusOffset); |
611
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
787 break; |
627 | 788 case MOTION_DETECT_SCROLL: pitchstate = detectScrollButtonEvent(fabs(focusOffset)); |
611
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
789 break; |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
790 default: |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
791 pitchstate = DETECT_NOTHING; |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
792 break; |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
793 } |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
794 } |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
795 |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
796 if(DETECT_NEG_PITCH == pitchstate) |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
797 { |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
798 StoreButtonAction((uint8_t)ACTION_PITCH_NEG); |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
799 } |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
800 if(DETECT_POS_PITCH == pitchstate) |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
801 { |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
802 StoreButtonAction((uint8_t)ACTION_PITCH_POS); |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
803 } |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
804 } |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
805 else |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
806 { |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
807 if(wasInFocus) |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
808 { |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
809 wasInFocus = 0; |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
810 if(suspendMotionDetectionSec == 0) |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
811 { |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
812 if(settingsGetPointer()->design == 7) |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
813 { |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
814 t7_set_customview_to_primary(); |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
815 } |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
816 else |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
817 { |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
818 t3_set_customview_to_primary(); |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
819 } |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
820 } |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
821 } |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
822 set_Backlight_Boost(0); |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
823 } |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
824 if(suspendMotionDetectionSec != 0) |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
825 { |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
826 suspendMotionDetectionSec--; |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
827 } |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
828 } |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
829 |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
595
diff
changeset
|
830 |