annotate Discovery/Src/tInfoCompass.c @ 680:5575f21382d5 Betatest

Bugfix visualization better setpoint: Due to a formating mistake a complete float was show in case a better setpoint had been suggested. The string formating has been updated to show a 4 characters string
author Ideenmodellierer
date Mon, 25 Apr 2022 21:07:28 +0200
parents b7b481df4f22
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 /// -*- coding: UTF-8 -*-
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 /// \file Discovery/Src/tInfoCompass.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 /// \brief there is only compass_DX_f, compass_DY_f, compass_DZ_f output during this mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 /// \author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 /// \date 23-Feb-2015
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 /// \details
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 /// $Id$
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 /// This program is free software: you can redistribute it and/or modify
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 /// it under the terms of the GNU General Public License as published by
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 /// the Free Software Foundation, either version 3 of the License, or
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 /// (at your option) any later version.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 /// This program is distributed in the hope that it will be useful,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 /// GNU General Public License for more details.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 /// You should have received a copy of the GNU General Public License
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 //////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 #include "tInfoCompass.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 #include <string.h>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 uint16_t tInfoCompassTimeout = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 int16_t minMaxCompassDX[3][2] = { 0 };
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 void openInfo_Compass(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 set_globalState(StICOMPASS);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 tInfoCompassTimeout = settingsGetPointer()->timeoutInfoCompass;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 tInfoCompassTimeout *= 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 for(int i = 0; i<3;i ++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 minMaxCompassDX[i][0] = 999;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 minMaxCompassDX[i][1] = -999;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 // ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 // refreshInfo_Compass
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 /// @brief there is only compass_DX_f, compass_DY_f, compass_DZ_f output during this mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 /// the accel is not called during this process
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 tInfoCompassTimeout--;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 if(tInfoCompassTimeout == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 exitInfo();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 char text[80];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 int16_t compassValues[3];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 compassValues[0] = stateUsed->lifeData.compass_DX_f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 compassValues[1] = stateUsed->lifeData.compass_DY_f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 compassValues[2] = stateUsed->lifeData.compass_DZ_f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 for(int i = 0; i<3;i ++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 // do not accept zero
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 if(minMaxCompassDX[i][0] == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 minMaxCompassDX[i][0] = compassValues[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 // do not accept zero
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 if(minMaxCompassDX[i][1] == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 minMaxCompassDX[i][1] = compassValues[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 if(compassValues[i] < minMaxCompassDX[i][0])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 minMaxCompassDX[i][0] = compassValues[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 if(compassValues[i] > minMaxCompassDX[i][1])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 minMaxCompassDX[i][1] = compassValues[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 for(int i = 0; i<3;i ++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 snprintf(text,80,"%c: %i" "\t(%i, %i)",
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 'X'+i,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 compassValues[i],
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 minMaxCompassDX[i][0],
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 minMaxCompassDX[i][1]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 tInfo_write_content_simple( 20,800, 96 + (i*96), &FontT48, text, CLUT_InfoCompass);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 snprintf(text,80,"roll %.1f" "\tpitch %.1f",
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 stateUsed->lifeData.compass_roll,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 stateUsed->lifeData.compass_pitch);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 tInfo_write_content_simple( 20,800, 96 * 4, &FontT42, text, CLUT_InfoCompass);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 }