Mercurial > public > ostc4
annotate Discovery/Src/tMenuXtra.c @ 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 | 77de014928d6 |
children | 12f8745c8a94 |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tMenuXtra.c | |
5 /// \brief Menu Xtra - Specials in Divemode like Reset Stopwatch | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 02-Mar-2015 | |
8 /// | |
9 /// \details | |
10 /// | |
11 /// $Id$ | |
12 /////////////////////////////////////////////////////////////////////////////// | |
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
14 /// | |
15 /// This program is free software: you can redistribute it and/or modify | |
16 /// it under the terms of the GNU General Public License as published by | |
17 /// the Free Software Foundation, either version 3 of the License, or | |
18 /// (at your option) any later version. | |
19 /// | |
20 /// This program is distributed in the hope that it will be useful, | |
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 /// GNU General Public License for more details. | |
24 /// | |
25 /// You should have received a copy of the GNU General Public License | |
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
27 ////////////////////////////////////////////////////////////////////////////// | |
28 | |
29 /* Includes ------------------------------------------------------------------*/ | |
30 #include <stdio.h> | |
31 #include <string.h> | |
32 #include "tMenu.h" | |
33 #include "tStructure.h" | |
34 #include "tMenuXtra.h" | |
35 #include "text_multilanguage.h" | |
36 #include "data_central.h" | |
37 #include "simulation.h" | |
38 | |
39 /* Exported functions --------------------------------------------------------*/ | |
40 | |
41 uint32_t tMXtra_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext) | |
42 { | |
43 uint8_t textPointer; | |
44 | |
45 textPointer = 0; | |
46 *tab = 500; | |
47 *subtext = 0; | |
48 | |
49 if((line == 0) || (line == 1)) | |
50 { | |
51 text[textPointer++] = TXT_2BYTE; | |
52 text[textPointer++] = TXT2BYTE_ResetStopwatch; | |
53 } | |
54 strcpy(&text[textPointer],"\n\r"); | |
55 textPointer += 2; | |
56 /* | |
57 if((line == 0) || (line == 2)) | |
58 { | |
59 text[textPointer++] = TXT_2BYTE; | |
60 text[textPointer++] = TXT2BYTE_ResetAvgDepth; | |
61 } | |
62 strcpy(&text[textPointer],"\n\r"); | |
63 textPointer += 2; | |
64 */ | |
65 if((line == 0) || (line == 2)) | |
66 { | |
67 text[textPointer++] = TXT_2BYTE; | |
68 text[textPointer++] = TXT2BYTE_CompassHeading; | |
69 } | |
70 strcpy(&text[textPointer],"\n\r"); | |
71 textPointer += 2; | |
72 | |
73 if((line == 0) || (line == 3)) | |
74 { | |
75 text[textPointer++] = TXT_2BYTE; | |
76 text[textPointer++] = TXT2BYTE_SetMarker; | |
77 } | |
78 strcpy(&text[textPointer],"\n\r"); | |
79 textPointer += 2; | |
80 | |
81 if(is_stateUsedSetToSim()) | |
82 { | |
83 if((line == 0) || (line == 4)) | |
84 { | |
85 text[textPointer++] = TXT_2BYTE; | |
86 text[textPointer++] = TXT2BYTE_SimFollowDecoStops; | |
87 text[textPointer++] = ' '; | |
88 text[textPointer++] = ' '; | |
89 if(simulation_get_heed_decostops()) | |
90 text[textPointer++] = '\005'; | |
91 else | |
92 text[textPointer++] = '\006'; | |
93 } | |
94 strcpy(&text[textPointer],"\n\r"); | |
95 textPointer += 2; | |
96 } | |
347
77de014928d6
Added option to manually leave dive mode to system menu
ideenmodellierer
parents:
38
diff
changeset
|
97 else |
77de014928d6
Added option to manually leave dive mode to system menu
ideenmodellierer
parents:
38
diff
changeset
|
98 { |
77de014928d6
Added option to manually leave dive mode to system menu
ideenmodellierer
parents:
38
diff
changeset
|
99 if((line == 0) || (line == 4)) /* end dive mode only used during real dives */ |
77de014928d6
Added option to manually leave dive mode to system menu
ideenmodellierer
parents:
38
diff
changeset
|
100 { |
77de014928d6
Added option to manually leave dive mode to system menu
ideenmodellierer
parents:
38
diff
changeset
|
101 text[textPointer++] = TXT_2BYTE; |
77de014928d6
Added option to manually leave dive mode to system menu
ideenmodellierer
parents:
38
diff
changeset
|
102 text[textPointer++] = TXT2BYTE_EndDiveMode; |
77de014928d6
Added option to manually leave dive mode to system menu
ideenmodellierer
parents:
38
diff
changeset
|
103 } |
77de014928d6
Added option to manually leave dive mode to system menu
ideenmodellierer
parents:
38
diff
changeset
|
104 strcpy(&text[textPointer],"\n\r"); |
77de014928d6
Added option to manually leave dive mode to system menu
ideenmodellierer
parents:
38
diff
changeset
|
105 textPointer += 2; |
77de014928d6
Added option to manually leave dive mode to system menu
ideenmodellierer
parents:
38
diff
changeset
|
106 } |
38 | 107 |
108 return StMXTRA; | |
109 } | |
110 |