Mercurial > public > ostc4
annotate Discovery/Src/tInfoCompass.c @ 306:2f43419102c8 cleanup-4
bugfix, cleanup: do not clip depth to 0
A real dive with the previous commits shows that testing from the simulator
cannot be fully trusted in relation to logic that is close to the depth
sensor (that is obviously bypassed using the simulator). So 1) there is
3 second interval between the stopwatch and the divetime, and 2) the depth
flips from 1m depth to surface 0m depth, and that is visible in the
profile data.
Point 2) is definitely caused by the removed code in this commit. It likely
is not right to clip the depth value at all. It is fine to base decisions like is
done in is_ambient_pressure_close_to_surface on it, but clipping the depth value
itself is seems wrong. This has become more prominent with commit eba8d1eb5bef
where the clipping depth changed from 40cm of depth to 1m of depth. When
comparing profiles from an OSTC Plus, it shows that no depth clipping is
present there, so that is one more argument to remove it here.
Point 1) The 3 sec interval is likely not a coincidence. It is the time
to travel for 1m depth with a default descend speed of 20m/min.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Wed, 22 May 2019 14:39:04 +0200 |
parents | b7b481df4f22 |
children |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tInfoCompass.c | |
5 /// \brief there is only compass_DX_f, compass_DY_f, compass_DZ_f output during this mode | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 23-Feb-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 ------------------------------------------------------------------*/ | |
243
b7b481df4f22
debug: add SPI error counter to compass calibration
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
30 |
b7b481df4f22
debug: add SPI error counter to compass calibration
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
31 #include "gfx_engine.h" |
b7b481df4f22
debug: add SPI error counter to compass calibration
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
32 #include "gfx_fonts.h" |
b7b481df4f22
debug: add SPI error counter to compass calibration
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
33 #include "tHome.h" |
b7b481df4f22
debug: add SPI error counter to compass calibration
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
34 #include "tInfo.h" |
38 | 35 #include "tInfoCompass.h" |
36 | |
37 #include <string.h> | |
38 | |
39 /* Private variables ---------------------------------------------------------*/ | |
40 | |
41 uint16_t tInfoCompassTimeout = 0; | |
42 int16_t minMaxCompassDX[3][2] = { 0 }; | |
43 | |
44 /* Exported functions --------------------------------------------------------*/ | |
45 void openInfo_Compass(void) | |
46 { | |
47 set_globalState(StICOMPASS); | |
48 tInfoCompassTimeout = settingsGetPointer()->timeoutInfoCompass; | |
49 tInfoCompassTimeout *= 10; | |
50 | |
51 for(int i = 0; i<3;i ++) | |
52 { | |
53 minMaxCompassDX[i][0] = 999; | |
54 minMaxCompassDX[i][1] = -999; | |
55 } | |
56 } | |
57 | |
58 | |
59 // =============================================================================== | |
60 // refreshInfo_Compass | |
61 /// @brief there is only compass_DX_f, compass_DY_f, compass_DZ_f output during this mode | |
62 /// the accel is not called during this process | |
63 // =============================================================================== | |
243
b7b481df4f22
debug: add SPI error counter to compass calibration
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
64 void refreshInfo_Compass(GFX_DrawCfgScreen s) |
38 | 65 { |
243
b7b481df4f22
debug: add SPI error counter to compass calibration
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
66 |
b7b481df4f22
debug: add SPI error counter to compass calibration
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
67 tHome_show_lost_connection_count(&s); |
38 | 68 tInfoCompassTimeout--; |
69 if(tInfoCompassTimeout == 0) | |
70 { | |
71 exitInfo(); | |
72 return; | |
73 } | |
74 | |
75 char text[80]; | |
76 | |
77 int16_t compassValues[3]; | |
78 | |
79 compassValues[0] = stateUsed->lifeData.compass_DX_f; | |
80 compassValues[1] = stateUsed->lifeData.compass_DY_f; | |
81 compassValues[2] = stateUsed->lifeData.compass_DZ_f; | |
82 | |
83 for(int i = 0; i<3;i ++) | |
84 { | |
85 // do not accept zero | |
86 if(minMaxCompassDX[i][0] == 0) | |
87 minMaxCompassDX[i][0] = compassValues[i]; | |
88 | |
89 // do not accept zero | |
90 if(minMaxCompassDX[i][1] == 0) | |
91 minMaxCompassDX[i][1] = compassValues[i]; | |
92 | |
93 if(compassValues[i] < minMaxCompassDX[i][0]) | |
94 minMaxCompassDX[i][0] = compassValues[i]; | |
95 | |
96 if(compassValues[i] > minMaxCompassDX[i][1]) | |
97 minMaxCompassDX[i][1] = compassValues[i]; | |
98 } | |
99 | |
100 snprintf(text,80,"Time left: %u s",(tInfoCompassTimeout+9)/10); | |
243
b7b481df4f22
debug: add SPI error counter to compass calibration
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
101 tInfo_write_content_simple( 20,800, 25, &FontT42, text, CLUT_InfoCompass); |
38 | 102 |
103 for(int i = 0; i<3;i ++) | |
104 { | |
105 snprintf(text,80,"%c: %i" "\t(%i, %i)", | |
106 'X'+i, | |
107 compassValues[i], | |
108 minMaxCompassDX[i][0], | |
109 minMaxCompassDX[i][1]); | |
110 tInfo_write_content_simple( 20,800, 96 + (i*96), &FontT48, text, CLUT_InfoCompass); | |
111 } | |
112 | |
113 snprintf(text,80,"roll %.1f" "\tpitch %.1f", | |
114 stateUsed->lifeData.compass_roll, | |
115 stateUsed->lifeData.compass_pitch); | |
116 tInfo_write_content_simple( 20,800, 96 * 4, &FontT42, text, CLUT_InfoCompass); | |
117 } |