annotate Discovery/Src/motion.c @ 421:3f7d80f37bfc ImprovmentNVM_2

Enable sequentionel writing of device data: DeviceData was always written to the start of the the DD ringbuffer causing everytime a sector erase delay (~200ms). To avoid this the ring buffer functionality has been activated. To be backward compatible the latest DD set will be written to DD ring buffer start at shutdown time. In case of a reset the firmware scans for the latest DD block and restores its content giving the same data consistency intervall (10 minutes) as the previous implementation without having the 200ms penality for sector erases
author ideenmodellierer
date Mon, 10 Feb 2020 19:25:09 +0100
parents 0cd862e501f6
children e3237f580ae9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
359
4258ea9b67fa Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff changeset
17
4258ea9b67fa Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff changeset
18 #define STABLE_STATE_COUNT 2 /* number of count to declare a state as stable (at the moment based on 100ms) */
363
bdf978d2a5d4 Reworked detection function
ideenmodellierer
parents: 362
diff changeset
19 #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
20
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
21 #define SECTOR_WINDOW 80.0 /* Pitch window which is used for custom view projection */
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
22 #define SECTOR_WINDOW_MAX 120.0 /* Pitch window which will be greater than the divers field of view */
385
0cd862e501f6 Finetune parameter for detection of small sectors as used for the pitch detection
ideenmodellierer
parents: 384
diff changeset
23 #define SECTOR_HYSTERY 2 /* Additional offset to avoid fast changing displays */
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
24 #define SECTOR_BORDER 400.0 /* Define a value which is out of limit to avoid not wanted key events */
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
25 #define SECTOR_FILTER 10 /* Define speed for calculated angle to follow real value */
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
26
385
0cd862e501f6 Finetune parameter for detection of small sectors as used for the pitch detection
ideenmodellierer
parents: 384
diff changeset
27 #define SECTOR_MAX 24 /* maximum number of sectors */
378
834e087505ec Incremented "idle window" for scroll detection
ideenmodellierer
parents: 373
diff changeset
28 #define SECTOR_SCROLL 7 /* number of sectors used for scroll detection */
359
4258ea9b67fa Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff changeset
29
385
0cd862e501f6 Finetune parameter for detection of small sectors as used for the pitch detection
ideenmodellierer
parents: 384
diff changeset
30 detectionState_t detectionState = DETECT_NOTHING;
0cd862e501f6 Finetune parameter for detection of small sectors as used for the pitch detection
ideenmodellierer
parents: 384
diff changeset
31 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
32
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
33
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
34 uint8_t GetSectorForPitch(float pitch)
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
35 {
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
36 static uint8_t lastsector = 0;
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
37 float newPitch;
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
38 uint8_t sector = 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
39
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
40 newPitch = pitch + sectorDetection.offset + sectorDetection.center; /* do not use negative values and consider offset to center position */
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
41 if (newPitch < 0.0) /* clip value */
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
42 {
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
43 newPitch = 0.0;
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
44 }
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
45 if (newPitch > sectorDetection.window) /* clip value */
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
46 {
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
47 newPitch = sectorDetection.window;
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
48 }
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
49
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
50 /* switch to other sector? */
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
51 if((newPitch > sectorDetection.upperborder) || (newPitch <= sectorDetection.lowerborder))
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
52 {
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
53 sector = (uint16_t) newPitch / sectorDetection.size;
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
54 sectorDetection.lowerborder = sector * sectorDetection.size - SECTOR_HYSTERY;
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
55 sectorDetection.upperborder = (sector + 1) * sectorDetection.size + SECTOR_HYSTERY;
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
56 lastsector = sector;
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
57 }
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
58
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
59 return lastsector;
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
60 }
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
61
371
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
62 void DefinePitchSectors(float centerPitch,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
63 {
371
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
64 if(numOfSectors == CUSTOMER_DEFINED_VIEWS)
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
65 {
384
427ae9f8e28e Consider number of available t3 views in sector handling:
ideenmodellierer
parents: 383
diff changeset
66 if(settingsGetPointer()->design == 3) /* Big font view ? */
427ae9f8e28e Consider number of available t3 views in sector handling:
ideenmodellierer
parents: 383
diff changeset
67 {
427ae9f8e28e Consider number of available t3 views in sector handling:
ideenmodellierer
parents: 383
diff changeset
68 sectorDetection.count = t3_GetEnabled_customviews();
427ae9f8e28e Consider number of available t3 views in sector handling:
ideenmodellierer
parents: 383
diff changeset
69 }
427ae9f8e28e Consider number of available t3 views in sector handling:
ideenmodellierer
parents: 383
diff changeset
70 else
427ae9f8e28e Consider number of available t3 views in sector handling:
ideenmodellierer
parents: 383
diff changeset
71 {
427ae9f8e28e Consider number of available t3 views in sector handling:
ideenmodellierer
parents: 383
diff changeset
72 sectorDetection.count = t7_GetEnabled_customviews();
427ae9f8e28e Consider number of available t3 views in sector handling:
ideenmodellierer
parents: 383
diff changeset
73 }
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
74 if(sectorDetection.count > 7)
371
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
75 {
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
76 sectorDetection.count = 7; /* more views are hard to manually control */
371
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
77 }
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
78 }
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
79 else
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
80 if(numOfSectors != CUSTOMER_KEEP_LAST_SECTORS)
371
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
81 {
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
82 sectorDetection.count = numOfSectors;
371
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
83 }
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
84
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
85 if(sectorDetection.count == SECTOR_MAX)
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
86 {
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
87 sectorDetection.window = SECTOR_WINDOW_MAX;
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
88 }
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
89 else
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
90 {
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
91 sectorDetection.window = SECTOR_WINDOW;
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
92 }
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
93
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
94 sectorDetection.offset = (centerPitch - (sectorDetection.window / 2)) * -1.0;
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
95 sectorDetection.size = sectorDetection.window / sectorDetection.count;
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
96 sectorDetection.center = 0;
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
97
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
98 /* reset border values */
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
99 sectorDetection.lowerborder = SECTOR_BORDER;
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
100 sectorDetection.upperborder = SECTOR_BORDER * -1.0;
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
101 /* get the current sector */
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
102 sectorDetection.current = GetSectorForPitch(stateRealGetPointer()->lifeData.compass_pitch);
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
103 sectorDetection.target = sectorDetection.current;
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
104 /* do a small adjustment to center pitch to make sure the actual pitch is in the center of the current sector */
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
105 sectorDetection.center = (sectorDetection.upperborder) - ((sectorDetection.size + 2 *SECTOR_HYSTERY) / 2.0) - (centerPitch + sectorDetection.offset);
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
106
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
107 }
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
108
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
109 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
110 {
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
111 sectorDetection.target = 0;
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
112 sectorDetection.current = 0;
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
113 sectorDetection.size = 0;
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
114 sectorDetection.count = 0;
371
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
115
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
116 switch(settingsGetPointer()->MotionDetection)
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
117 {
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
118 case MOTION_DETECT_SECTOR: DefinePitchSectors(0,CUSTOMER_DEFINED_VIEWS);
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
119 break;
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
120 case MOTION_DETECT_MOVE: DefinePitchSectors(0,SECTOR_MAX);
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
121 break;
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
122 case MOTION_DETECT_SCROLL: DefinePitchSectors(0,SECTOR_SCROLL);
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
123 break;
371
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
124 default:
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
125 break;
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
126 }
fca370f847f8 Added parameter for number of sectors to be defined
ideenmodellierer
parents: 370
diff changeset
127
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
128 }
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
129
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
130 /* Map the current pitch value to a sector and create button event in case the sector is left */
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
131 detectionState_t detectSectorButtonEvent(float curPitch)
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
132 {
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
133 static uint8_t lastTargetSector = 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
134 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
135 uint8_t PitchEvent = DETECT_NOTHING;
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
136
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
137 /* only change sector if reading is stable */
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
138 newTargetSector = GetSectorForPitch(stateRealGetPointer()->lifeData.compass_pitch);
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
139 if(lastTargetSector == 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
140 {
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
141 sectorDetection.target = newTargetSector;
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
142 }
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
143 lastTargetSector = newTargetSector;
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
144 if(sectorDetection.target != sectorDetection.current)
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
145 {
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
146 if(sectorDetection.target > sectorDetection.current)
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
147 {
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
148 sectorDetection.current++;
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 PitchEvent = DETECT_POS_PITCH;
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
150 }
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 else
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 {
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
153 sectorDetection.current--;
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 PitchEvent = DETECT_NEG_PITCH;
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
155 }
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
156 }
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
157 return PitchEvent;
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
158 }
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
159
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
160 /* Check if pitch is not in center position and trigger a button action if needed */
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
161 detectionState_t detectScrollButtonEvent(float curPitch)
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
162 {
378
834e087505ec Incremented "idle window" for scroll detection
ideenmodellierer
parents: 373
diff changeset
163 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
164
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
165 uint8_t PitchEvent = DETECT_NOTHING;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
166 uint8_t newSector;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
167
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
168 if(delayscroll == 0)
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
169 {
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
170 newSector = GetSectorForPitch(stateRealGetPointer()->lifeData.compass_pitch);
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
171 /* for scroll detection the motion windoe is split into 6 sectors => set event accoring to the sector number*/
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
172 switch(newSector)
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
173 {
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
174 case 0:
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
175 case 1: PitchEvent = DETECT_POS_PITCH;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
176 break;
378
834e087505ec Incremented "idle window" for scroll detection
ideenmodellierer
parents: 373
diff changeset
177 case 5:
834e087505ec Incremented "idle window" for scroll detection
ideenmodellierer
parents: 373
diff changeset
178 case 6: PitchEvent = DETECT_NEG_PITCH;
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
179 break;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
180 default:
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
181 break;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
182 }
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
183 if(PitchEvent != DETECT_NOTHING)
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
184 {
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
185 delayscroll = 5;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
186 }
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
187 }
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
188 else
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
189 {
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
190 delayscroll--;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
191 }
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
192 return PitchEvent;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
193 }
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
194
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
195
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
196 /* 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
197 /* 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
198 detectionState_t detectPitch(float currentPitch)
359
4258ea9b67fa Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff changeset
199 {
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
200 static uint8_t lastSector = 0;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
201 static uint8_t startSector = 0;
359
4258ea9b67fa Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff changeset
202 static uint8_t stableCnt = 0;
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
203
383
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
204 uint8_t curSector;
49a02dea8ae3 Combine variables in a structure to improve readability of code
ideenmodellierer
parents: 381
diff changeset
205
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
206 if((detectionState == DETECT_NEG_PITCH) || (detectionState == DETECT_POS_PITCH)) /* discard last detection */
359
4258ea9b67fa Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff changeset
207 {
4258ea9b67fa Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff changeset
208 detectionState = DETECT_NOTHING;
4258ea9b67fa Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff changeset
209 }
363
bdf978d2a5d4 Reworked detection function
ideenmodellierer
parents: 362
diff changeset
210
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
211 curSector = GetSectorForPitch(stateRealGetPointer()->lifeData.compass_pitch);
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
212
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
213 /* feed value into state machine */
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
214 switch (detectionState)
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
215 {
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
216 case DETECT_NOTHING: if(curSector != lastSector) /* detect a stable condition before evaluating for the next move */
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
217 {
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
218 stableCnt=0;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
219 }
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
220
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
221 if(stableCnt > STABLE_STATE_COUNT)
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
222 {
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
223 detectionState = DETECT_START;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
224 stableCnt = 0;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
225 startSector = lastSector;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
226 }
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
227 break;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
228 case DETECT_START: if(curSector != lastSector)
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
229 {
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
230 if(abs(curSector - startSector) > 1)
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
231 {
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
232 if(curSector > lastSector)
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
233 {
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
234 detectionState = DETECT_POS_MOVE;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
235 }
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
236 else
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
237 {
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
238 detectionState = DETECT_NEG_MOVE;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
239 }
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
240 stableCnt = 0;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
241 startSector = lastSector;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
242 }
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
243 }
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
244 break;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
245 case DETECT_NEG_MOVE:
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
246 case DETECT_POS_MOVE: if(curSector == lastSector) /* Moved to a max? */
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
247 {
378
834e087505ec Incremented "idle window" for scroll detection
ideenmodellierer
parents: 373
diff changeset
248 if(abs(startSector - curSector) > 2)
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
249 {
378
834e087505ec Incremented "idle window" for scroll detection
ideenmodellierer
parents: 373
diff changeset
250 detectionState++;
834e087505ec Incremented "idle window" for scroll detection
ideenmodellierer
parents: 373
diff changeset
251 stableCnt = 0;
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
252 }
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
253 if(stableCnt > 2)
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
254 {
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
255 detectionState = DETECT_NOTHING;
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
256 stableCnt = 0;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
257 }
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
258 }
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
259 break;
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
260 case DETECT_MAXIMA:
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
261 case DETECT_MINIMA: if(curSector != lastSector) /* reset timeout detection */
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
262 {
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
263 detectionState++;
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
264 stableCnt = 0;
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
265 }
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
266 break;
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
267 case DETECT_RISEBACK:
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
268 case DETECT_FALLBACK:
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
269 if(curSector == lastSector) /* check if we are back at start position at end of movement */
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
270 {
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
271 if(abs(startSector - curSector) <= 1)
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
272 {
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
273 if(stableCnt > 2)
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
274 {
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
275 detectionState++;
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
276 stableCnt = 0;
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
277 }
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
278 }
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
279 }
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
280 break;
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
281 default:
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
282 detectionState = DETECT_NOTHING;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
283 break;
381
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
284 }
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
285 if(detectionState != DETECT_START)
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
286 {
695434a6dcf6 Simplified pitch detection state machine:
ideenmodellierer
parents: 378
diff changeset
287 stableCnt++;
373
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
288 }
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
289 lastSector = curSector;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
290 if(stableCnt > STABLE_STATE_TIMEOUT)
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
291 {
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
292 detectionState = DETECT_NOTHING;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
293 stableCnt = 0;
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
294 }
7b981f8bdd41 Add scroll event by pitch angle detection:
ideenmodellierer
parents: 371
diff changeset
295
359
4258ea9b67fa Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff changeset
296 return detectionState;
4258ea9b67fa Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff changeset
297 }