Mercurial > public > ostc4
annotate Discovery/Inc/motion.h @ 471:73da921869d9 fix-bat-2
bugfix: implement battery charge percentage in dive header
This commit is (much) less trivial than the related 919e5cb51c92.
First, rename the CCRmode attribute (corresponding to byte Ox59) of
the SLogbookHeaderOSTC3. This byte (according to the hwOS interface
document) does not contain any CCR related value, but it contains
"battery information". Already since 2017, this byte is used from
libdivecomputer to interface the charge percentage. So, its
renamed from CCRmode to batteryCharge, to reflect its true purpose.
Now, simply add a batteryCharge attribute to the SLogbookHeader
(and see below why that is possible, without breaking things).
The remaining changes are trivial to implement battery charge
percentage in dive header.
Caveat: do not get confused by the exact role of the individual
logbook header types. SLogbookHeaderOSTC3 is the formal type of
the logbook format that the OSTC4 produces. This format is
supposed to identical to the format, as is used in hwOS for the
series of small OSTCs. Only some values of attributes are different.
For example, the OSTC4 supports VPM, so byte 0x79 (deco model used
for this dive) also has a value for VPM. But the SLogbookHeader
type, despite its name and structure, is *not* a true logbook
header, as it includes attributes that are not available in the
SLogbookHeaderOSTC3 formal header type.
Signed-off-by: Jan Mulder <jan@jlmulder.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Wed, 22 Apr 2020 13:08:57 +0200 |
parents | 49a02dea8ae3 |
children | e3237f580ae9 |
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 |
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
|
16 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
|
17 { |
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
|
18 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
|
19 MOTION_DETECT_SECTOR, |
373
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
20 MOTION_DETECT_MOVE, |
375
4bb5ceebfaf9
Use Enum values for initialization and setting check:
ideenmodellierer
parents:
373
diff
changeset
|
21 MOTION_DETECT_SCROLL, |
4bb5ceebfaf9
Use Enum values for initialization and setting check:
ideenmodellierer
parents:
373
diff
changeset
|
22 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
|
23 } 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
|
24 |
359
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
25 typedef enum |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
26 { |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
27 DETECT_START = 0, |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
28 DETECT_POS_MOVE, |
363 | 29 DETECT_MAXIMA, |
30 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
|
31 DETECT_POS_PITCH, |
359
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
32 DETECT_NEG_MOVE, |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
33 DETECT_MINIMA, |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
34 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
|
35 DETECT_NEG_PITCH, |
359
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
36 DETECT_NOTHING |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
37 } detectionState_t; |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
38 |
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
|
39 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
|
40 { |
383
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
41 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
|
42 float lowerborder; |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
43 |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
44 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
|
45 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
|
46 |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
47 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
|
48 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
|
49 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
|
50 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
|
51 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
|
52 } 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
|
53 |
383
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
54 |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
55 |
49a02dea8ae3
Combine variables in a structure to improve readability of code
ideenmodellierer
parents:
375
diff
changeset
|
56 |
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 void InitMotionDetection(void); |
371
fca370f847f8
Added parameter for number of sectors to be defined
ideenmodellierer
parents:
370
diff
changeset
|
58 void DefinePitchSectors(float centerAngle, 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
|
59 detectionState_t detectPitch(float currentPitch); |
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 detectionState_t detectSectorButtonEvent(float curPitch); |
373
7b981f8bdd41
Add scroll event by pitch angle detection:
ideenmodellierer
parents:
371
diff
changeset
|
61 detectionState_t detectScrollButtonEvent(float curPitch); |
359
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
62 |
4258ea9b67fa
Added new files for motion detection (shaking) detection
ideenmodellierer
parents:
diff
changeset
|
63 #endif /* INC_MOTION_H_ */ |