annotate Discovery/Src/tInfoCompass.c @ 84:e6abbef57475 kittz

Remove unusable code!!! prepare data for SPI in ONLY 1 IRQ!!!!
author Dmitry Romanov <kitt@bk.ru>
date Wed, 21 Nov 2018 10:25:15 +0300
parents 5f11787b4f42
children b7b481df4f22
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 ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 #include "tInfoCompass.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 #include "gfx_fonts.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 #include "tInfo.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 #include <string.h>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 uint16_t tInfoCompassTimeout = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 int16_t minMaxCompassDX[3][2] = { 0 };
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 void openInfo_Compass(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 set_globalState(StICOMPASS);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 tInfoCompassTimeout = settingsGetPointer()->timeoutInfoCompass;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 tInfoCompassTimeout *= 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 for(int i = 0; i<3;i ++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 minMaxCompassDX[i][0] = 999;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 minMaxCompassDX[i][1] = -999;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 }
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 // refreshInfo_Compass
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 /// @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
60 /// the accel is not called during this process
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 // ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 void refreshInfo_Compass(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 tInfoCompassTimeout--;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 if(tInfoCompassTimeout == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 exitInfo();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 char text[80];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 int16_t compassValues[3];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 compassValues[0] = stateUsed->lifeData.compass_DX_f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 compassValues[1] = stateUsed->lifeData.compass_DY_f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 compassValues[2] = stateUsed->lifeData.compass_DZ_f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 for(int i = 0; i<3;i ++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 // do not accept zero
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 if(minMaxCompassDX[i][0] == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 minMaxCompassDX[i][0] = compassValues[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][1] == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 minMaxCompassDX[i][1] = compassValues[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 if(compassValues[i] < minMaxCompassDX[i][0])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 minMaxCompassDX[i][0] = compassValues[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 if(compassValues[i] > minMaxCompassDX[i][1])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 minMaxCompassDX[i][1] = compassValues[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 snprintf(text,80,"Time left: %u s",(tInfoCompassTimeout+9)/10);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 tInfo_write_content_simple( 20,800, 20, &FontT42, text, CLUT_InfoCompass);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 for(int i = 0; i<3;i ++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 snprintf(text,80,"%c: %i" "\t(%i, %i)",
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 'X'+i,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 compassValues[i],
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 minMaxCompassDX[i][0],
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 minMaxCompassDX[i][1]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 tInfo_write_content_simple( 20,800, 96 + (i*96), &FontT48, text, CLUT_InfoCompass);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 snprintf(text,80,"roll %.1f" "\tpitch %.1f",
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 stateUsed->lifeData.compass_roll,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 stateUsed->lifeData.compass_pitch);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 tInfo_write_content_simple( 20,800, 96 * 4, &FontT42, text, CLUT_InfoCompass);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 }