Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditXtra.c @ 319:d8e86af78474 fix-version
bugfix: correct packed main version number in dive header
This fixes a rather mysterious bug. Users report that up to 1.3.5 beta,
a correct version number is shown in libdivecomputer based
applications (like in Subsurface, in the extra data tab). Careful
examining the code in both libdivecomputer and the firmware shows
a subtle error in the bit mask and shift operation to pack a full
X.Y.Z.beta version number in 2 bytes (as is available in the
dive header) in the firmware end (as the libdivecomputer code
looks sane, assuming this is the right way to pack things).
Likely, this bug crept in in the conversion from the closed
source Keil period into the open source GCC setup of
the code base. So its impossible to document the exact
history of this problem here.
Further notice that the main version number is only 1 of 3 version
numbers, denoting the full version of the firmware (besides Font
and RTE).
Finally notice that this way of packing is limited to 2^5 bits
(decimal 32), so we could easily build a 1.4.21, but not a
1.4.55.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Wed, 19 Jun 2019 14:31:50 +0200 |
parents | ba229a012ac7 |
children | 77de014928d6 |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tMenuEditXtra.c | |
5 /// \brief Menu Edit 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 "tMenuEditXtra.h" | |
31 | |
32 #include "gfx_fonts.h" | |
33 #include "simulation.h" | |
34 #include "timer.h" | |
35 #include "tMenuEdit.h" | |
36 | |
37 /* Private function prototypes -----------------------------------------------*/ | |
38 void openEdit_CompassHeading(void); | |
39 void openEdit_ResetStopwatch(void); | |
40 void openEdit_SimFollowDecostops(void); | |
41 void openEdit_SetManualMarker(void); | |
42 | |
43 /* Announced function prototypes -----------------------------------------------*/ | |
44 uint8_t OnAction_CompassHeading (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
45 | |
46 /* Exported functions --------------------------------------------------------*/ | |
47 | |
48 void openEdit_Xtra(uint8_t line) | |
49 { | |
50 set_globalState_Menu_Line(line); | |
51 resetMenuEdit(CLUT_MenuPageXtra); | |
52 | |
53 switch(line) | |
54 { | |
55 case 1: | |
56 default: | |
57 openEdit_ResetStopwatch(); | |
58 break; | |
59 case 2: | |
60 openEdit_CompassHeading(); | |
61 break; | |
62 case 3: | |
63 openEdit_SetManualMarker(); | |
64 break; | |
65 case 4: | |
66 openEdit_SimFollowDecostops(); | |
67 break; | |
68 } | |
69 } | |
70 | |
71 /* Private functions ---------------------------------------------------------*/ | |
72 void openEdit_ResetStopwatch(void) | |
73 { | |
74 timer_Stopwatch_Restart(); | |
75 exitMenuEdit_to_Home(); | |
76 } | |
77 | |
78 void openEdit_SetManualMarker(void) | |
79 { | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
272
diff
changeset
|
80 stateUsedWrite->events.manualMarker = 1; |
38 | 81 exitMenuEdit_to_Home(); |
82 } | |
83 | |
84 void openEdit_SimFollowDecostops(void) | |
85 { | |
86 simulation_set_heed_decostops(!simulation_get_heed_decostops()); | |
87 exitMenuEdit_to_Menu_with_Menu_Update(); | |
88 } | |
89 | |
90 void refresh_CompassHeading(void) | |
91 { | |
92 uint16_t heading; | |
93 char text[32]; | |
94 | |
95 text[0] = '\001'; | |
96 text[1] = TXT_2BYTE; | |
97 text[2] = TXT2BYTE_CompassHeading; | |
98 text[3] = 0; | |
99 write_topline(text); | |
100 | |
101 heading = (uint16_t)stateUsed->lifeData.compass_heading; | |
102 snprintf(text,32,"\001%03i`",heading); | |
103 write_label_var( 0, 800, ME_Y_LINE1, &FontT54, text); | |
104 | |
105 tMenuEdit_refresh_field(StMXTRA_CompassHeading); | |
106 } | |
107 | |
108 void openEdit_CompassHeading(void) | |
109 { | |
110 | |
111 write_field_button(StMXTRA_CompassHeading,20, 800, ME_Y_LINE4, &FontT48, "Set"); | |
112 | |
113 setEvent(StMXTRA_CompassHeading, (uint32_t)OnAction_CompassHeading); | |
114 // startEdit(); | |
115 } | |
116 | |
117 | |
118 uint8_t OnAction_CompassHeading (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
119 { | |
272
74a8296a2318
cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
120 stateUsedWrite->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading; |
38 | 121 exitMenuEdit_to_Home_with_Menu_Update(); |
122 return EXIT_TO_HOME; | |
123 } |