annotate Discovery/Src/tHome.c @ 38:5f11787b4f42

include in ostc4 repository
author heinrichsweikamp
date Sat, 28 Apr 2018 11:52:34 +0200
parents
children a6f0881074a4
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 "t9.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 #include "tDebug.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 #include "timer.h" // for timer_Stopwatch_Restart
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 #include "tMenu.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 #include "tMenuEditGasOC.h" // for openEdit_DiveSelectBetterGas()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 #include "tMenuEditSetpoint.h" // for openEdit_DiveSelectBetterSetpoint()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 #include "simulation.h"
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 uint32_t cv_configuration = 0xFFFFFFFF;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 const uint8_t cv_changelist[6] = {CVIEW_Compass, CVIEW_SummaryOfLeftCorner, CVIEW_Tissues, CVIEW_Profile, CVIEW_EADTime, CVIEW_Gaslist};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 void set_globalState_tHome(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 if(stateUsed->mode == MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 set_globalState(StS);
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 void switch_to_SimData_tHome(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 set_stateUsedToSim();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 void switch_to_RealData_tHome(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 set_stateUsedToReal();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 void tHome_init(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 t7_init(); // standard + surface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 t3_init(); // big font
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 t4_init(); // game
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 t5_init(); // gauge
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 t6_init(); // apnea
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 t9_init(); // bonex
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 void tHome_init_compass(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 init_t7_compass();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 init_t9_compass();
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 void tHome_refresh(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 SSettings* pSettings = settingsGetPointer();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 warning_toogle_count++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 if(warning_toogle_count >= 2* pSettings->warning_blink_dsec)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 warning_toogle_count = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 if(warning_toogle_count >= pSettings->warning_blink_dsec)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 warning_count_high_time = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 warning_count_high_time = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 display_toogle_count++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 if(display_toogle_count >= 2* pSettings->display_toogle_desc)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 display_toogle_count = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 if(display_toogle_count >= pSettings->display_toogle_desc)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 display_count_high_time = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 display_count_high_time = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 if(pSettings->design == 6)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 t6_refresh();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 if(pSettings->design == 5)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 t5_refresh();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 if(pSettings->design == 4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 t4_refresh();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 if(pSettings->design == 3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 t3_refresh();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 if(pSettings->design == 7)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 t7_refresh();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 if(pSettings->design == 9)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 t9_refresh();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 pSettings->design = 7;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 t7_refresh();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 void tHome_sleepmode_fun(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 t7_refresh_sleepmode_fun();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 void tHomeDiveMenuControl(uint8_t sendAction)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 if(sendAction == ACTION_BUTTON_NEXT)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 if(settingsGetPointer()->design == 4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 if(settingsGetPointer()->design == 3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 settingsGetPointer()->design = 7;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 switch(get_globalState())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 case StD:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 if(settingsGetPointer()->design == 6)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 if(is_stateUsedSetToSim())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 set_globalState(StDSIM1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 set_globalState(StDQUIT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 if(settingsGetPointer()->design == 5)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 if(t5_getCustomView() == CVIEW_Compass)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 set_globalState(StDBEAR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 set_globalState(StDRAVG);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 if(stateUsed->warnings.betterGas)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 set_globalState(StDMGAS);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 if(stateUsed->warnings.betterSetpoint)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 set_globalState(StDMSPT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 set_globalState(StDMENU);
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 StDMGAS:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 if(stateUsed->warnings.betterSetpoint)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 set_globalState(StDMSPT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 set_globalState(StDMENU);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 case StDMSPT:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 set_globalState(StDMENU);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 case StDMENU:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 if(is_stateUsedSetToSim())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 set_globalState(StDSIM1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 case StDSIM1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 set_globalState(StDSIM2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 case StDSIM2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 set_globalState(StDSIM3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 case StDSIM3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 set_globalState(StDSIM4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 case StDSIM4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 case StDBEAR: // t5_gauge
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 set_globalState(StDRAVG);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 case StDRAVG: // t5_gauge
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 if(is_stateUsedSetToSim())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 set_globalState(StDSIM1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 case StDQUIT: // t6_apnea
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 if(sendAction == ACTION_BUTTON_ENTER)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 if(settingsGetPointer()->design == 4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 if(settingsGetPointer()->design == 3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 settingsGetPointer()->design = 7;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 switch(get_globalState())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 case StDMGAS:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 openEdit_DiveSelectBetterGas();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 case StDMSPT:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 openEdit_DiveSelectBetterSetpoint();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 case StDMENU:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 openMenu_first_page_with_OC_gas_update();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 case StDSIM1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 Sim_Quit();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 case StDSIM2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 Sim_Ascend();
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 StDSIM3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 Sim_Descend();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 case StDSIM4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 Sim_Divetime();
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 case StDBEAR: // t5_gauge
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 if(is_stateUsedSetToSim())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 stateSimGetPointerWrite()->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 stateRealGetPointerWrite()->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 case StDRAVG: // t5_gauge
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 timer_Stopwatch_Restart();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 case StDQUIT: // t6_apnea
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 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
309 if(is_stateUsedSetToSim())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 Sim_Quit();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 dataOutGetPointer()->setEndDive = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 void tHome_findNextStop(const uint16_t *list, uint8_t *depthOutMeter, uint16_t *lengthOutSeconds)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 uint8_t ptr = DECOINFO_STRUCT_MAX_STOPS - 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 while(ptr && !list[ptr])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 ptr--;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 *lengthOutSeconds = list[ptr];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 if(!(*lengthOutSeconds))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 *depthOutMeter = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 if(ptr == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 *depthOutMeter = (uint8_t)((stateUsed->diveSettings.last_stop_depth_bar*10.0f) + 0.1f);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 ptr -= 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 *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
343 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 void tHome_change_field_button_pressed(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 tHome_tick_count_field = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 if(settingsGetPointer()->design == 7)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 t7_change_field();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 if(settingsGetPointer()->design == 9)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 t9_change_field();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 void tHome_change_customview_button_pressed(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 tHome_tick_count_cview = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 if(settingsGetPointer()->design == 7)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 t7_change_customview();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 if(settingsGetPointer()->design == 9)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 t9_change_customview();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 if(settingsGetPointer()->design == 3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 t3_change_customview();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 if(settingsGetPointer()->design == 5)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 t5_change_customview();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 if(settingsGetPointer()->design == 6)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 t6_change_customview();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 void tHome_tick(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 uint16_t field = settingsGetPointer()->tX_userselectedLeftLowerCornerTimeout;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 uint16_t cview = settingsGetPointer()->tX_customViewTimeout;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 if(field)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 tHome_tick_count_field++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 if(tHome_tick_count_field > (field * 10))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 tHome_tick_count_field = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 if(settingsGetPointer()->design == 7)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 t7_set_field_to_primary();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 if(cview)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 tHome_tick_count_cview++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 if(tHome_tick_count_cview > (cview *10))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 tHome_tick_count_cview = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 if(settingsGetPointer()->design == 7)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 t7_set_customview_to_primary();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 uint32_t tHome_DateCode(RTC_DateTypeDef *dateInput)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 uint32_t answer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414 answer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 answer += (dateInput->Year & 0x7F)<< 9;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416 answer += (dateInput->Month & 0x0F)<< 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 answer += (dateInput->Date & 0x1F);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 return answer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 uint8_t tHome_gas_writer(uint8_t oxygen_percentage, uint8_t helium_percentage, char *text)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425 if(oxygen_percentage == 100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426 return (uint8_t) snprintf(text,10,"Oxy");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 else if((oxygen_percentage == 21) && (!helium_percentage))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428 return (uint8_t) snprintf(text,10,"Air");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 else if(!helium_percentage)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 return (uint8_t) snprintf(text,10,"NX%02i",oxygen_percentage);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431 else if((oxygen_percentage + helium_percentage) == 100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432 return (uint8_t) snprintf(text,10,"HX%02i",oxygen_percentage);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 return (uint8_t) snprintf(text,10,"%02i/%02i",oxygen_percentage,helium_percentage);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 uint8_t tHome_show_lost_connection_count(GFX_DrawCfgScreen *ScreenToWriteOn)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441 if(!DataEX_lost_connection_count())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 char text[10];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 snprintf(text,10,"\002 %i",DataEX_lost_connection_count());
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 Gfx_write_label_var(ScreenToWriteOn, 600,800, 0,&FontT48,CLUT_ButtonSymbols,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 return DataEX_lost_connection_count();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450 }