359
+ − 1 /*
+ − 2 * motion.h
+ − 3 *
+ − 4 * Created on: 20.05.2019
+ − 5 * Author: Thorsten Sonntag
+ − 6 */
+ − 7
+ − 8 #ifndef INC_MOTION_H_
+ − 9 #define INC_MOTION_H_
+ − 10
+ − 11
+ − 12 /* exported data types */
373
+ − 13 #define CUSTOMER_DEFINED_VIEWS (100u) /* value will cause the function to detect the number of selected views */
+ − 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
diff
changeset
+ − 15
625
+ − 16 #define MOTION_ENABLE_ROLL (0x01u)
+ − 17 #define MOTION_ENABLE_PITCH (0x02u)
+ − 18 #define MOTION_ENABLE_YAW (0x04u)
+ − 19 #define MOTION_ENABLE_ALL (MOTION_ENABLE_ROLL | MOTION_ENABLE_PITCH | MOTION_ENABLE_YAW)
+ − 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
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
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
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
diff
changeset
+ − 24 MOTION_DETECT_SECTOR,
373
+ − 25 MOTION_DETECT_MOVE,
375
+ − 26 MOTION_DETECT_SCROLL,
+ − 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
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
diff
changeset
+ − 29
359
+ − 30 typedef enum
+ − 31 {
+ − 32 DETECT_START = 0,
+ − 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
diff
changeset
+ − 36 DETECT_POS_PITCH,
359
+ − 37 DETECT_NEG_MOVE,
+ − 38 DETECT_MINIMA,
+ − 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
diff
changeset
+ − 40 DETECT_NEG_PITCH,
359
+ − 41 DETECT_NOTHING
+ − 42 } detectionState_t;
+ − 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
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
diff
changeset
+ − 45 {
383
+ − 46 float upperborder; /* current sector is changed if pitch exceeds these borders */
+ − 47 float lowerborder;
+ − 48
+ − 49 uint8_t current; /* number of the current visible sector */
+ − 50 uint8_t target; /* used for sector switch => number of the sector which shall be finnaly displayed */
+ − 51
+ − 52 float offset; /* offset to adjust minimum pitch value used for detection to zero */
+ − 53 float size; /* delta of upper and lower boarder defining the sector in degree */
+ − 54 float window; /* defines which range of pitch values are used for detection */
+ − 55 float center; /* defines the offset from pitch to middle of active sector (avoid center position is close to the calculated borders) */
+ − 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
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
diff
changeset
+ − 58
551
+ − 59 typedef struct
+ − 60 {
+ − 61 float x;
+ − 62 float y;
+ − 63 float z;
+ − 64 } SCoord;
383
+ − 65
551
+ − 66 typedef enum
+ − 67 {
+ − 68 MOTION_HISTORY_ROLL = 0,
+ − 69 MOTION_HISTORY_PITCH,
+ − 70 MOTION_HISTORY_YAW
+ − 71 } MotionHistoryEntry_t;
383
+ − 72
551
+ − 73 typedef struct
+ − 74 {
+ − 75 uint8_t roll;
+ − 76 uint8_t pitch;
+ − 77 uint8_t yaw;
+ − 78 } SDeltaHistory;
383
+ − 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
diff
changeset
+ − 80 void InitMotionDetection(void);
611
+ − 81 void suspendMotionDetection(uint8_t seconds);
+ − 82 void HandleMotionDetection(void);
551
+ − 83 void resetMotionDeltaHistory();
+ − 84 void evaluateMotionDelta(float roll, float pitch, float yaw);
625
+ − 85 void DefineSectorCount(uint8_t numOfSectors);
597
+ − 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
diff
changeset
+ − 87 detectionState_t detectPitch(float currentPitch);
625
+ − 88 detectionState_t detectSectorButtonEvent(float focusOffset);
+ − 89 detectionState_t detectScrollButtonEvent(float focusOffset);
359
+ − 90
551
+ − 91 void anglesToCoord(float roll, float pitch, float yaw, SCoord *pCoord);
+ − 92 void calibrateViewport(float roll, float pitch, float yaw);
625
+ − 93 float checkViewport(float roll, float pitch, float yaw, uint8_t enableAxis);
551
+ − 94 uint8_t viewInFocus(void);
642
+ − 95 uint8_t viewDetectionSuspended(void);
551
+ − 96 void resetFocusState(void);
+ − 97
359
+ − 98 #endif /* INC_MOTION_H_ */