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 ------------------------------------------------------------------*/
|
|
30 #include "tInfoCompass.h"
|
|
31
|
|
32 #include "gfx_fonts.h"
|
|
33 #include "tInfo.h"
|
|
34
|
|
35 #include <string.h>
|
|
36
|
|
37 /* Private variables ---------------------------------------------------------*/
|
|
38
|
|
39 uint16_t tInfoCompassTimeout = 0;
|
|
40 int16_t minMaxCompassDX[3][2] = { 0 };
|
|
41
|
|
42 /* Exported functions --------------------------------------------------------*/
|
|
43 void openInfo_Compass(void)
|
|
44 {
|
|
45 set_globalState(StICOMPASS);
|
|
46 tInfoCompassTimeout = settingsGetPointer()->timeoutInfoCompass;
|
|
47 tInfoCompassTimeout *= 10;
|
|
48
|
|
49 for(int i = 0; i<3;i ++)
|
|
50 {
|
|
51 minMaxCompassDX[i][0] = 999;
|
|
52 minMaxCompassDX[i][1] = -999;
|
|
53 }
|
|
54 }
|
|
55
|
|
56
|
|
57 // ===============================================================================
|
|
58 // refreshInfo_Compass
|
|
59 /// @brief there is only compass_DX_f, compass_DY_f, compass_DZ_f output during this mode
|
|
60 /// the accel is not called during this process
|
|
61 // ===============================================================================
|
|
62 void refreshInfo_Compass(void)
|
|
63 {
|
|
64 tInfoCompassTimeout--;
|
|
65 if(tInfoCompassTimeout == 0)
|
|
66 {
|
|
67 exitInfo();
|
|
68 return;
|
|
69 }
|
|
70
|
|
71 char text[80];
|
|
72
|
|
73 int16_t compassValues[3];
|
|
74
|
|
75 compassValues[0] = stateUsed->lifeData.compass_DX_f;
|
|
76 compassValues[1] = stateUsed->lifeData.compass_DY_f;
|
|
77 compassValues[2] = stateUsed->lifeData.compass_DZ_f;
|
|
78
|
|
79 for(int i = 0; i<3;i ++)
|
|
80 {
|
|
81 // do not accept zero
|
|
82 if(minMaxCompassDX[i][0] == 0)
|
|
83 minMaxCompassDX[i][0] = compassValues[i];
|
|
84
|
|
85 // do not accept zero
|
|
86 if(minMaxCompassDX[i][1] == 0)
|
|
87 minMaxCompassDX[i][1] = compassValues[i];
|
|
88
|
|
89 if(compassValues[i] < minMaxCompassDX[i][0])
|
|
90 minMaxCompassDX[i][0] = compassValues[i];
|
|
91
|
|
92 if(compassValues[i] > minMaxCompassDX[i][1])
|
|
93 minMaxCompassDX[i][1] = compassValues[i];
|
|
94 }
|
|
95
|
|
96 snprintf(text,80,"Time left: %u s",(tInfoCompassTimeout+9)/10);
|
|
97 tInfo_write_content_simple( 20,800, 20, &FontT42, text, CLUT_InfoCompass);
|
|
98
|
|
99 for(int i = 0; i<3;i ++)
|
|
100 {
|
|
101 snprintf(text,80,"%c: %i" "\t(%i, %i)",
|
|
102 'X'+i,
|
|
103 compassValues[i],
|
|
104 minMaxCompassDX[i][0],
|
|
105 minMaxCompassDX[i][1]);
|
|
106 tInfo_write_content_simple( 20,800, 96 + (i*96), &FontT48, text, CLUT_InfoCompass);
|
|
107 }
|
|
108
|
|
109 snprintf(text,80,"roll %.1f" "\tpitch %.1f",
|
|
110 stateUsed->lifeData.compass_roll,
|
|
111 stateUsed->lifeData.compass_pitch);
|
|
112 tInfo_write_content_simple( 20,800, 96 * 4, &FontT42, text, CLUT_InfoCompass);
|
|
113 }
|