annotate Discovery/Src/tHome.c @ 381:695434a6dcf6 MotionDetection

Simplified pitch detection state machine: Considering a pitch to last 1 to 2 seconds only around 5 to 10 iterations are used. As result the used counters had limits of 1 or 2 => not really needed
author ideenmodellierer
date Thu, 10 Oct 2019 22:11:59 +0200
parents 0dbf550dc743
children 427ae9f8e28e
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/tHome.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 /// \brief Control for Surface and Dive Templates
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 10-November-2014
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 "tHome.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 #include "data_exchange_main.h" // for dataOutGetPointer()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 #include "gfx_fonts.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 #include "t3.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 #include "t4_tetris.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 #include "t5_gauge.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 #include "t6_apnea.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 #include "t7.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 #include "tDebug.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 #include "timer.h" // for timer_Stopwatch_Restart
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 #include "tMenu.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 #include "tMenuEditGasOC.h" // for openEdit_DiveSelectBetterGas()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 #include "tMenuEditSetpoint.h" // for openEdit_DiveSelectBetterSetpoint()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 #include "simulation.h"
361
b111fc4250e9 Pass action to customer vie update function.
Ideenmodellierer
parents: 289
diff changeset
45 #include "motion.h"
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 /* Private types -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 /* Exported variables --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 _Bool warning_count_high_time = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 _Bool display_count_high_time = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 uint8_t errorsInSettings = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 static uint8_t warning_toogle_count;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 static uint16_t display_toogle_count;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 static uint16_t tHome_tick_count_cview;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 static uint16_t tHome_tick_count_field;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59
379
0dbf550dc743 Added missing customerview selection
ideenmodellierer
parents: 361
diff changeset
60 const uint8_t cv_changelist[] = {CVIEW_Compass, CVIEW_SummaryOfLeftCorner, CVIEW_Tissues, CVIEW_Profile, CVIEW_EADTime, CVIEW_Gaslist, CVIEW_noneOrDebug, CVIEW_Decolist,CVIEW_sensors,CVIEW_sensors_mV, CVIEW_END};
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 void set_globalState_tHome(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 if(stateUsed->mode == MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 set_globalState(StS);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 }
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 void tHome_init(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 t7_init(); // standard + surface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 t3_init(); // big font
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 t4_init(); // game
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 t5_init(); // gauge
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 t6_init(); // apnea
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 void tHome_init_compass(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 init_t7_compass();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 void tHome_refresh(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 SSettings* pSettings = settingsGetPointer();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 warning_toogle_count++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 if(warning_toogle_count >= 2* pSettings->warning_blink_dsec)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 warning_toogle_count = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 if(warning_toogle_count >= pSettings->warning_blink_dsec)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 warning_count_high_time = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 warning_count_high_time = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 display_toogle_count++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 if(display_toogle_count >= 2* pSettings->display_toogle_desc)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 display_toogle_count = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 if(display_toogle_count >= pSettings->display_toogle_desc)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 display_count_high_time = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 display_count_high_time = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 if(pSettings->design == 6)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 t6_refresh();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 if(pSettings->design == 5)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 t5_refresh();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 if(pSettings->design == 4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 t4_refresh();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 if(pSettings->design == 3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 t3_refresh();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 if(pSettings->design == 7)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 t7_refresh();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 pSettings->design = 7;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 t7_refresh();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 void tHome_sleepmode_fun(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 t7_refresh_sleepmode_fun();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 void tHomeDiveMenuControl(uint8_t sendAction)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 if(sendAction == ACTION_BUTTON_NEXT)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 if(settingsGetPointer()->design == 4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 if(settingsGetPointer()->design == 3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 settingsGetPointer()->design = 7;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 switch(get_globalState())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 case StD:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 if(settingsGetPointer()->design == 6)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 if(is_stateUsedSetToSim())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 set_globalState(StDSIM1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 set_globalState(StDQUIT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 if(settingsGetPointer()->design == 5)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 if(t5_getCustomView() == CVIEW_Compass)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 set_globalState(StDBEAR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 set_globalState(StDRAVG);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 if(stateUsed->warnings.betterGas)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 set_globalState(StDMGAS);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 if(stateUsed->warnings.betterSetpoint)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 set_globalState(StDMSPT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 set_globalState(StDMENU);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 case StDMGAS:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 if(stateUsed->warnings.betterSetpoint)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 set_globalState(StDMSPT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 set_globalState(StDMENU);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 case StDMSPT:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 set_globalState(StDMENU);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 case StDMENU:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 if(is_stateUsedSetToSim())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 set_globalState(StDSIM1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 case StDSIM1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 set_globalState(StDSIM2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 case StDSIM2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 set_globalState(StDSIM3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 case StDSIM3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 set_globalState(StDSIM4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 case StDSIM4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 case StDBEAR: // t5_gauge
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 set_globalState(StDRAVG);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 case StDRAVG: // t5_gauge
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 if(is_stateUsedSetToSim())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 set_globalState(StDSIM1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 case StDQUIT: // t6_apnea
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 if(sendAction == ACTION_BUTTON_ENTER)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 if(settingsGetPointer()->design == 4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 if(settingsGetPointer()->design == 3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 settingsGetPointer()->design = 7;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 switch(get_globalState())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 case StDMGAS:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 openEdit_DiveSelectBetterGas();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 case StDMSPT:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 openEdit_DiveSelectBetterSetpoint();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 case StDMENU:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 openMenu_first_page_with_OC_gas_update();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 case StDSIM1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 Sim_Quit();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 case StDSIM2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 Sim_Ascend();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 case StDSIM3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 Sim_Descend();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 case StDSIM4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 Sim_Divetime();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 case StDBEAR: // t5_gauge
272
74a8296a2318 cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents: 210
diff changeset
277 stateUsedWrite->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 case StDRAVG: // t5_gauge
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 timer_Stopwatch_Restart();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 case StDQUIT: // t6_apnea
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 set_globalState(StD); // used to end StDQUIT, is called before everything else because changes are made in the next lines
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 if(is_stateUsedSetToSim())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 Sim_Quit();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 dataOutGetPointer()->setEndDive = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 void tHome_findNextStop(const uint16_t *list, uint8_t *depthOutMeter, uint16_t *lengthOutSeconds)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 uint8_t ptr = DECOINFO_STRUCT_MAX_STOPS - 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 while(ptr && !list[ptr])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 ptr--;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 *lengthOutSeconds = list[ptr];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 if(!(*lengthOutSeconds))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 *depthOutMeter = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 if(ptr == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 *depthOutMeter = (uint8_t)((stateUsed->diveSettings.last_stop_depth_bar*10.0f) + 0.1f);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 ptr -= 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 *depthOutMeter = (uint8_t)(((stateUsed->diveSettings.input_second_to_last_stop_depth_bar + (stateUsed->diveSettings.input_next_stop_increment_depth_bar * ptr))*10.0f) + 0.1f);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 void tHome_change_field_button_pressed(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 tHome_tick_count_field = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 if(settingsGetPointer()->design == 7)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 t7_change_field();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333
361
b111fc4250e9 Pass action to customer vie update function.
Ideenmodellierer
parents: 289
diff changeset
334 void tHome_change_customview_button_pressed(uint8_t action)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 tHome_tick_count_cview = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 if(settingsGetPointer()->design == 7)
361
b111fc4250e9 Pass action to customer vie update function.
Ideenmodellierer
parents: 289
diff changeset
338 t7_change_customview(action);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 if(settingsGetPointer()->design == 3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 t3_change_customview();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 if(settingsGetPointer()->design == 5)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 t5_change_customview();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 if(settingsGetPointer()->design == 6)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 t6_change_customview();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 void tHome_tick(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 uint16_t field = settingsGetPointer()->tX_userselectedLeftLowerCornerTimeout;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 uint16_t cview = settingsGetPointer()->tX_customViewTimeout;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 if(field)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 tHome_tick_count_field++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 if(tHome_tick_count_field > (field * 10))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 tHome_tick_count_field = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 if(settingsGetPointer()->design == 7)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 t7_set_field_to_primary();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 if(cview)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 tHome_tick_count_cview++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 if(tHome_tick_count_cview > (cview *10))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 tHome_tick_count_cview = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 if(settingsGetPointer()->design == 7)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 t7_set_customview_to_primary();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 uint32_t tHome_DateCode(RTC_DateTypeDef *dateInput)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 uint32_t answer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 answer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 answer += (dateInput->Year & 0x7F)<< 9;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 answer += (dateInput->Month & 0x0F)<< 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 answer += (dateInput->Date & 0x1F);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 return answer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 uint8_t tHome_gas_writer(uint8_t oxygen_percentage, uint8_t helium_percentage, char *text)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 if(oxygen_percentage == 100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 return (uint8_t) snprintf(text,10,"Oxy");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 else if((oxygen_percentage == 21) && (!helium_percentage))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 return (uint8_t) snprintf(text,10,"Air");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 else if(!helium_percentage)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 return (uint8_t) snprintf(text,10,"NX%02i",oxygen_percentage);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 else if((oxygen_percentage + helium_percentage) == 100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 return (uint8_t) snprintf(text,10,"HX%02i",oxygen_percentage);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 return (uint8_t) snprintf(text,10,"%02i/%02i",oxygen_percentage,helium_percentage);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 uint8_t tHome_show_lost_connection_count(GFX_DrawCfgScreen *ScreenToWriteOn)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 {
208
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 191
diff changeset
413 static uint8_t LastKnowRTEState = SPI_RX_STATE_INVALID;
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 191
diff changeset
414
99
6a2308b9a3d4 Config for debug data
Dmitry Romanov <kitt@bk.ru>
parents: 84
diff changeset
415 if(!SPI_MIN_ERROR_SHOW) return 0;
172
c659fda83e44 Minor: Button defaults, release date adjusted, use SPI_SHOW_SYNC_STATS
heinrichsweikamp
parents: 138
diff changeset
416 if(DataEX_lost_connection_count()>=SPI_MIN_ERROR_SHOW && SPI_SHOW_SYNC_STATS){
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417
99
6a2308b9a3d4 Config for debug data
Dmitry Romanov <kitt@bk.ru>
parents: 84
diff changeset
418 char text[64];
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419
82
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 38
diff changeset
420 SDataExchangeSlaveToMaster* dataIn=get_dataInPointer();
208
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 191
diff changeset
421 SDataReceiveFromMaster* pDataOut = dataOutGetPointer();
82
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 38
diff changeset
422
99
6a2308b9a3d4 Config for debug data
Dmitry Romanov <kitt@bk.ru>
parents: 84
diff changeset
423 snprintf(text,32,"spi err:\002 %i/%i",DataEX_lost_connection_count(),get_num_SPI_CALLBACKS());
6a2308b9a3d4 Config for debug data
Dmitry Romanov <kitt@bk.ru>
parents: 84
diff changeset
424 Gfx_write_label_var(ScreenToWriteOn, 100,300, 0,&FontT24,CLUT_ButtonSymbols,text);
82
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 38
diff changeset
425
104
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 99
diff changeset
426 // snprintf(text,32,"header:\002%X%X%X%X",dataIn->header.checkCode[0],dataIn->header.checkCode[1],dataIn->header.checkCode[2],dataIn->header.checkCode[3]);
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 99
diff changeset
427 // Gfx_write_label_var(ScreenToWriteOn, 350,550, 0,&FontT24,CLUT_ButtonSymbols,text);
82
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 38
diff changeset
428
208
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 191
diff changeset
429 //snprintf(text,32,"footer:\002%X%X%X%X",dataIn->footer.checkCode[0],dataIn->footer.checkCode[1],dataIn->footer.checkCode[2],dataIn->footer.checkCode[3]);
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 191
diff changeset
430
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 191
diff changeset
431 /* data shifted => ignore received data */
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 191
diff changeset
432 if((pDataOut->header.checkCode[SPI_HEADER_INDEX_RX_STATE] == SPI_RX_STATE_SHIFTED) || (pDataOut->header.checkCode[SPI_HEADER_INDEX_RX_STATE] == SPI_RX_STATE_OFFLINE))
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 191
diff changeset
433 {
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 191
diff changeset
434 dataIn->header.checkCode[SPI_HEADER_INDEX_RX_STATE] = LastKnowRTEState;
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 191
diff changeset
435 }
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 191
diff changeset
436 else
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 191
diff changeset
437 {
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 191
diff changeset
438 LastKnowRTEState =dataIn->header.checkCode[SPI_HEADER_INDEX_RX_STATE];
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 191
diff changeset
439 }
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 191
diff changeset
440 snprintf(text,32,"RX State M|R:\002%X|%X",pDataOut->header.checkCode[SPI_HEADER_INDEX_RX_STATE], dataIn->header.checkCode[SPI_HEADER_INDEX_RX_STATE] );
99
6a2308b9a3d4 Config for debug data
Dmitry Romanov <kitt@bk.ru>
parents: 84
diff changeset
441 Gfx_write_label_var(ScreenToWriteOn, 600,800, 0,&FontT24,CLUT_ButtonSymbols,text);
6a2308b9a3d4 Config for debug data
Dmitry Romanov <kitt@bk.ru>
parents: 84
diff changeset
442 }
82
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 38
diff changeset
443
99
6a2308b9a3d4 Config for debug data
Dmitry Romanov <kitt@bk.ru>
parents: 84
diff changeset
444
6a2308b9a3d4 Config for debug data
Dmitry Romanov <kitt@bk.ru>
parents: 84
diff changeset
445
6a2308b9a3d4 Config for debug data
Dmitry Romanov <kitt@bk.ru>
parents: 84
diff changeset
446 // snprintf(text,32,"cpt:\002%i",get_num_SPI_CALLBACKS());
6a2308b9a3d4 Config for debug data
Dmitry Romanov <kitt@bk.ru>
parents: 84
diff changeset
447 // Gfx_write_label_var(ScreenToWriteOn, 600,800, 90,&FontT24,CLUT_ButtonSymbols,text);
82
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 38
diff changeset
448
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 38
diff changeset
449 // snprintf(text,10,"i2c:\002%i",get_DataEX_Error_place());
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 38
diff changeset
450 // Gfx_write_label_var(ScreenToWriteOn, 600,800, 90,&FontT24,CLUT_ButtonSymbols,text);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452 return DataEX_lost_connection_count();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453 }