Mercurial > public > ostc4
annotate Discovery/Src/tMenuHardware.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 | 5e8ad1cd353f |
children | 1f557e5f4b5a |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tMenuHardware.c | |
5 /// \brief Main Template file for Menu Page Hardware | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 05-Aug-2014 | |
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 "tMenu.h" | |
31 #include "tMenuHardware.h" | |
32 | |
33 //#define NEXTLINE(text, textPointer) {text[(textPointer)++] = '\n'; text[textPointer++] = '\r'; text[textPointer] = 0;} | |
34 // NEXTLINE(text,textPointer); | |
35 | |
36 | |
37 //\ text[(*textPointer)++] = '\r'; text[*textPointer] = 0; | |
38 | |
39 /* Exported functions --------------------------------------------------------*/ | |
40 | |
41 uint32_t tMHardware_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext) | |
42 { | |
43 | |
44 SSettings *data; | |
45 uint8_t textPointer, actualBrightness; | |
46 char sensorStatusColor[3]; | |
47 int32_t button[4]; | |
48 data = settingsGetPointer(); | |
49 textPointer = 0; | |
50 *tab = 450; | |
51 *subtext = 0; | |
52 /* | |
53 const char content[6] = | |
54 { TXT_Compass, | |
55 TXT_o2Sensors, | |
56 TXT_Brightness, | |
57 TXT_FirmwareUpdate,//TXT_Luftintegration, | |
58 0,//TXT_FirmwareUpdate, | |
59 0 | |
60 }; | |
61 tM_refresh(text,&textPointer,line,content); | |
62 */ | |
63 if((line == 0) || (line == 1)) | |
64 { | |
65 text[textPointer++] = TXT_2BYTE; | |
66 text[textPointer++] = TXT2BYTE_Bluetooth; | |
67 text[textPointer++] = '\t'; | |
68 if(settingsGetPointer()->bluetoothActive) | |
69 text[textPointer++] = '\005'; | |
70 else | |
71 text[textPointer++] = '\006'; | |
72 text[textPointer] = 0; | |
73 } | |
74 nextline(text,&textPointer); | |
75 | |
76 if((line == 0) || (line == 2)) | |
77 { | |
78 text[textPointer++] = TXT_2BYTE; | |
79 text[textPointer++] = TXT2BYTE_Compass; | |
80 text[textPointer++] = '\t'; | |
81 | |
82 if(settingsGetPointer()->compassBearing != 0) | |
83 { | |
84 textPointer += snprintf(&text[textPointer],20,"(%03u`)",settingsGetPointer()->compassBearing); | |
85 } | |
86 text[textPointer] = 0; | |
87 /* | |
88 textPointer += snprintf(&text[textPointer],20,"%i %i %i" | |
89 ,stateUsed->lifeData.compass_DX_f | |
90 ,stateUsed->lifeData.compass_DY_f | |
91 ,stateUsed->lifeData.compass_DZ_f); | |
92 */ | |
93 } | |
94 nextline(text,&textPointer); | |
95 | |
96 if((line == 0) || (line == 3)) | |
97 { | |
98 text[textPointer++] = TXT_o2Sensors; | |
99 if((stateUsed->lifeData.ppO2Sensor_bar[0] != 0) || (stateUsed->lifeData.ppO2Sensor_bar[1] != 0) || (stateUsed->lifeData.ppO2Sensor_bar[2] != 0)) | |
100 { | |
101 text[textPointer++] = '\t'; | |
102 sensorStatusColor[0] = '\020'; | |
103 sensorStatusColor[1] = '\020'; | |
104 sensorStatusColor[2] = '\020'; | |
105 if(stateUsed->diveSettings.ppo2sensors_deactivated) | |
106 { | |
107 if(stateUsed->diveSettings.ppo2sensors_deactivated & 1) | |
108 sensorStatusColor[0] = '\021'; | |
109 if(stateUsed->diveSettings.ppo2sensors_deactivated & 2) | |
110 sensorStatusColor[1] = '\021'; | |
111 if(stateUsed->diveSettings.ppo2sensors_deactivated & 4) | |
112 sensorStatusColor[2] = '\021'; | |
113 } | |
114 textPointer += snprintf(&text[textPointer],20,"%c%01.1f %c%01.1f %c%01.1f\020" | |
115 ,sensorStatusColor[0], stateUsed->lifeData.ppO2Sensor_bar[0] | |
116 ,sensorStatusColor[1], stateUsed->lifeData.ppO2Sensor_bar[1] | |
117 ,sensorStatusColor[2], stateUsed->lifeData.ppO2Sensor_bar[2]); | |
118 } | |
119 } | |
120 nextline(text,&textPointer); | |
121 | |
122 if((line == 0) || (line == 4)) | |
123 { | |
124 text[textPointer++] = TXT_Brightness; | |
125 text[textPointer++] = '\t'; | |
126 | |
127 actualBrightness = data->brightness; | |
128 | |
129 if(actualBrightness == 0) | |
130 text[textPointer++] = TXT_Cave; | |
131 else if(actualBrightness == 1) | |
132 text[textPointer++] = TXT_Eco; | |
133 else if(actualBrightness == 2) | |
134 text[textPointer++] = TXT_Normal; | |
135 else if(actualBrightness == 3) | |
136 text[textPointer++] = TXT_Bright; | |
137 else if(actualBrightness == 4) | |
138 text[textPointer++] = TXT_Ultrabright; | |
139 else | |
140 text[textPointer++] = '+'; | |
141 } | |
142 nextline(text,&textPointer); | |
143 | |
144 if((line == 0) || (line == 5)) | |
145 { | |
146 text[textPointer++] = TXT_2BYTE; | |
147 text[textPointer++] = TXT2BYTE_ButtonSensitivity; | |
148 text[textPointer++] = '\t'; | |
149 | |
150 for(int i=0;i<=3;i++) | |
151 { | |
152 button[i] = (uint8_t)settingsGetPointer()->ButtonResponsiveness[i]; | |
153 } | |
154 // textPointer += snprintf(&text[textPointer],25,"%i %i %i",button[0],button[1],button[2]); | |
155 textPointer += snprintf(&text[textPointer],25, | |
317 | 156 "%li" |
38 | 157 "\016\016" |
158 " %%" | |
159 "\017", | |
160 button[3]); | |
161 } | |
162 nextline(text,&textPointer); | |
163 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
164 if((line == 0) || (line == 6)) |
38 | 165 { |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
166 text[textPointer++] = TXT_2BYTE; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
167 text[textPointer++] = TXT2BYTE_FLIPDISPLAY; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
168 text[textPointer++] = '\t'; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
169 if(settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
170 text[textPointer++] = '\005'; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
171 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
172 text[textPointer++] = '\006'; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
173 text[textPointer] = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
174 nextline(text,&textPointer); |
38 | 175 } |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
176 |
38 | 177 return StMHARD; |
178 } |