Mercurial > public > ostc4
annotate Discovery/Inc/motion.h @ 664:667093daa937 Betatest
Stability improvment bluetooth startup:
The previous implementation expected a default setup of the Bluetooth module. Deviations from the default expectation caused the init function to stop. The new implementation is able to fix wrong baud rate setting (reset baudrate to default 115200).
In addition the function evaluating the answers of the module is not able to derive the status out of a data stream.
author | Ideenmodellierer |
---|---|
date | Tue, 21 Dec 2021 19:36:41 +0100 |
parents | c737cf5d9067 |
children |
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.h |
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 #ifndef INC_MOTION_H_ |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
9 #define INC_MOTION_H_ |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
10 |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
11 |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
12 /* exported data types */ |
373
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
13 #define CUSTOMER_DEFINED_VIEWS (100u) /* value will cause the function to detect the number of selected views */ |
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
14 #define CUSTOMER_KEEP_LAST_SECTORS (200u) /* do not update number of sectors, just define the new center position */ |
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
|
15 |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
611
diff
changeset
|
16 #define MOTION_ENABLE_ROLL (0x01u) |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
611
diff
changeset
|
17 #define MOTION_ENABLE_PITCH (0x02u) |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
611
diff
changeset
|
18 #define MOTION_ENABLE_YAW (0x04u) |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
611
diff
changeset
|
19 #define MOTION_ENABLE_ALL (MOTION_ENABLE_ROLL | MOTION_ENABLE_PITCH | MOTION_ENABLE_YAW) |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
611
diff
changeset
|
20 |
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 typedef enum |
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
|
22 { |
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
|
23 MOTION_DETECT_OFF = 0, |
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
|
24 MOTION_DETECT_SECTOR, |
373
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
25 MOTION_DETECT_MOVE, |
375
4bb5ceebfaf9
Use Enum values for initialization and setting check:
ideenmodellierer
parents:
373
diff
changeset
|
26 MOTION_DETECT_SCROLL, |
4bb5ceebfaf9
Use Enum values for initialization and setting check:
ideenmodellierer
parents:
373
diff
changeset
|
27 MOTION_DETECT_END |
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
|
28 } MotionDetectMethod_t; |
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
|
29 |
359
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
30 typedef enum |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
31 { |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
32 DETECT_START = 0, |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
33 DETECT_POS_MOVE, |
363 | 34 DETECT_MAXIMA, |
35 DETECT_FALLBACK, | |
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
|
36 DETECT_POS_PITCH, |
359
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
37 DETECT_NEG_MOVE, |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
38 DETECT_MINIMA, |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
39 DETECT_RISEBACK, |
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
|
40 DETECT_NEG_PITCH, |
359
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
41 DETECT_NOTHING |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
42 } detectionState_t; |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
43 |
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
|
44 typedef struct |
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
|
45 { |
383
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
46 float upperborder; /* current sector is changed if pitch exceeds these borders */ |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
47 float lowerborder; |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
48 |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
49 uint8_t current; /* number of the current visible sector */ |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
50 uint8_t target; /* used for sector switch => number of the sector which shall be finnaly displayed */ |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
51 |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
52 float offset; /* offset to adjust minimum pitch value used for detection to zero */ |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
53 float size; /* delta of upper and lower boarder defining the sector in degree */ |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
54 float window; /* defines which range of pitch values are used for detection */ |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
55 float center; /* defines the offset from pitch to middle of active sector (avoid center position is close to the calculated borders) */ |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
56 uint8_t count; /* number of sectors used for detection */ |
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
|
57 } SSector; |
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
|
58 |
551 | 59 typedef struct |
60 { | |
61 float x; | |
62 float y; | |
63 float z; | |
64 } SCoord; | |
383
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
65 |
551 | 66 typedef enum |
67 { | |
68 MOTION_HISTORY_ROLL = 0, | |
69 MOTION_HISTORY_PITCH, | |
70 MOTION_HISTORY_YAW | |
71 } MotionHistoryEntry_t; | |
383
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
72 |
551 | 73 typedef struct |
74 { | |
75 uint8_t roll; | |
76 uint8_t pitch; | |
77 uint8_t yaw; | |
78 } SDeltaHistory; | |
383
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
79 |
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
|
80 void InitMotionDetection(void); |
611
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
597
diff
changeset
|
81 void suspendMotionDetection(uint8_t seconds); |
916998f90e39
Suspend MotionDetection events while diver is operationg the OSTC:
Ideenmodellierer
parents:
597
diff
changeset
|
82 void HandleMotionDetection(void); |
551 | 83 void resetMotionDeltaHistory(); |
84 void evaluateMotionDelta(float roll, float pitch, float yaw); | |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
611
diff
changeset
|
85 void DefineSectorCount(uint8_t numOfSectors); |
597
132e7e3d13a7
MotionControl-Sector: Map sectors during switch T7 <=> T3:
Ideenmodellierer
parents:
551
diff
changeset
|
86 void MapCVToSector(void); |
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
|
87 detectionState_t detectPitch(float currentPitch); |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
611
diff
changeset
|
88 detectionState_t detectSectorButtonEvent(float focusOffset); |
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
611
diff
changeset
|
89 detectionState_t detectScrollButtonEvent(float focusOffset); |
359
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
90 |
551 | 91 void anglesToCoord(float roll, float pitch, float yaw, SCoord *pCoord); |
92 void calibrateViewport(float roll, float pitch, float yaw); | |
625
028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
Ideenmodellierer
parents:
611
diff
changeset
|
93 float checkViewport(float roll, float pitch, float yaw, uint8_t enableAxis); |
551 | 94 uint8_t viewInFocus(void); |
642
c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Ideenmodellierer
parents:
625
diff
changeset
|
95 uint8_t viewDetectionSuspended(void); |
551 | 96 void resetFocusState(void); |
97 | |
359
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
98 #endif /* INC_MOTION_H_ */ |