38
+ − 1 ///////////////////////////////////////////////////////////////////////////////
+ − 2 /// -*- coding: UTF-8 -*-
+ − 3 ///
+ − 4 /// \file Discovery/Src/tHome.c
+ − 5 /// \brief Control for Surface and Dive Templates
+ − 6 /// \author heinrichs weikamp gmbh
+ − 7 /// \date 10-November-2014
+ − 8 ///
+ − 9 /// \details
+ − 10 ///
+ − 11 /// $Id$
+ − 12 ///////////////////////////////////////////////////////////////////////////////
+ − 13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
+ − 14 ///
+ − 15 /// This program is free software: you can redistribute it and/or modify
+ − 16 /// it under the terms of the GNU General Public License as published by
+ − 17 /// the Free Software Foundation, either version 3 of the License, or
+ − 18 /// (at your option) any later version.
+ − 19 ///
+ − 20 /// This program is distributed in the hope that it will be useful,
+ − 21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
+ − 22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ − 23 /// GNU General Public License for more details.
+ − 24 ///
+ − 25 /// You should have received a copy of the GNU General Public License
+ − 26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
+ − 27 //////////////////////////////////////////////////////////////////////////////
+ − 28
+ − 29 /* Includes ------------------------------------------------------------------*/
+ − 30 #include "tHome.h"
+ − 31
+ − 32 #include "data_exchange_main.h" // for dataOutGetPointer()
+ − 33 #include "gfx_fonts.h"
+ − 34 #include "t3.h"
+ − 35 #include "t4_tetris.h"
+ − 36 #include "t5_gauge.h"
+ − 37 #include "t6_apnea.h"
+ − 38 #include "t7.h"
+ − 39 #include "tDebug.h"
+ − 40 #include "timer.h" // for timer_Stopwatch_Restart
+ − 41 #include "tMenu.h"
+ − 42 #include "tMenuEditGasOC.h" // for openEdit_DiveSelectBetterGas()
+ − 43 #include "tMenuEditSetpoint.h" // for openEdit_DiveSelectBetterSetpoint()
+ − 44 #include "simulation.h"
361
+ − 45 #include "motion.h"
619
+ − 46 #include "logbook_miniLive.h"
38
+ − 47
+ − 48 /* Private types -------------------------------------------------------------*/
+ − 49
+ − 50 /* Exported variables --------------------------------------------------------*/
+ − 51 _Bool warning_count_high_time = 0;
+ − 52 _Bool display_count_high_time = 0;
+ − 53
+ − 54 uint8_t errorsInSettings = 0;
+ − 55 /* Private variables ---------------------------------------------------------*/
+ − 56 static uint8_t warning_toogle_count;
+ − 57 static uint16_t display_toogle_count;
+ − 58 static uint16_t tHome_tick_count_cview;
+ − 59 static uint16_t tHome_tick_count_field;
576
+ − 60 static uint16_t tHome_tick_count_o2sens;
38
+ − 61
805
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
diff
changeset
+ − 62 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_Timer, CVIEW_END};
594
+ − 63 const uint8_t cv_changelist_BS[] = {CVIEW_T3_Decostop, CVIEW_sensors, CVIEW_Compass, CVIEW_T3_MaxDepth,CVIEW_T3_StopWatch, CVIEW_T3_TTS, CVIEW_T3_GasList, CVIEW_T3_ppO2andGas, CVIEW_noneOrDebug,
+ − 64 CVIEW_T3_Navigation, CVIEW_T3_DepthData, CVIEW_T3_DecoTTS,
+ − 65 #ifdef ENABLE_T3_PROFILE_VIEW
+ − 66 CVIEW_T3_Profile,
+ − 67 #endif
836
+ − 68 CVIEW_T3_Temperature,
594
+ − 69 CVIEW_T3_END};
38
+ − 70
+ − 71 /* Private function prototypes -----------------------------------------------*/
+ − 72
576
+ − 73 #define AUTORETURN_O2SENS (200u) /* return to sensor view after 20 seconds in case sensor is connected */
+ − 74
+ − 75
38
+ − 76 /* Exported functions --------------------------------------------------------*/
+ − 77
+ − 78 void set_globalState_tHome(void)
+ − 79 {
+ − 80 if(stateUsed->mode == MODE_DIVE)
739
+ − 81 {
38
+ − 82 set_globalState(StD);
739
+ − 83 }
38
+ − 84 else
+ − 85 set_globalState(StS);
816
c4ee952b9425
Fix a bug that disables arbitrary menu lines in dive mode if lines are disabled / inactive in surface mode. (mikeller)
heinrichsweikamp
diff
changeset
+ − 86
c4ee952b9425
Fix a bug that disables arbitrary menu lines in dive mode if lines are disabled / inactive in surface mode. (mikeller)
heinrichsweikamp
diff
changeset
+ − 87 clearDisabledMenuLines();
38
+ − 88 }
+ − 89
+ − 90
+ − 91 void tHome_init(void)
+ − 92 {
+ − 93 t7_init(); // standard + surface
+ − 94 t3_init(); // big font
+ − 95 t4_init(); // game
+ − 96 t5_init(); // gauge
+ − 97 t6_init(); // apnea
+ − 98 }
+ − 99
+ − 100
+ − 101 void tHome_init_compass(void)
+ − 102 {
+ − 103 init_t7_compass();
+ − 104 }
+ − 105
+ − 106
+ − 107 void tHome_refresh(void)
+ − 108 {
+ − 109 SSettings* pSettings = settingsGetPointer();
+ − 110
+ − 111 warning_toogle_count++;
+ − 112 if(warning_toogle_count >= 2* pSettings->warning_blink_dsec)
+ − 113 warning_toogle_count = 0;
+ − 114
+ − 115 if(warning_toogle_count >= pSettings->warning_blink_dsec)
+ − 116 warning_count_high_time = 1;
+ − 117 else
+ − 118 warning_count_high_time = 0;
+ − 119
+ − 120
+ − 121 display_toogle_count++;
+ − 122 if(display_toogle_count >= 2* pSettings->display_toogle_desc)
+ − 123 display_toogle_count = 0;
+ − 124
+ − 125 if(display_toogle_count >= pSettings->display_toogle_desc)
+ − 126 display_count_high_time = 1;
+ − 127 else
+ − 128 display_count_high_time = 0;
+ − 129
+ − 130
+ − 131 if(pSettings->design == 6)
+ − 132 t6_refresh();
+ − 133 else
+ − 134 if(pSettings->design == 5)
+ − 135 t5_refresh();
+ − 136 else
+ − 137 if(pSettings->design == 4)
+ − 138 t4_refresh();
+ − 139 else
+ − 140 if(pSettings->design == 3)
+ − 141 t3_refresh();
+ − 142 else
+ − 143 if(pSettings->design == 7)
+ − 144 t7_refresh();
+ − 145 else
+ − 146 {
+ − 147 pSettings->design = 7;
+ − 148 t7_refresh();
+ − 149 }
+ − 150 }
+ − 151
+ − 152
+ − 153 void tHome_sleepmode_fun(void)
+ − 154 {
+ − 155 t7_refresh_sleepmode_fun();
+ − 156 }
+ − 157
+ − 158
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 159 static void checkSetStateSim(SSettings *settings)
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 160 {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 161 if (is_stateUsedSetToSim()) {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 162 if (settings->design != 3) {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 163 set_globalState(StDSIM1);
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 164 } else {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 165 #ifdef ENABLE_T3_PPO_SIM
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 166 if (stateUsed->diveSettings.ppo2sensors_deactivated & 0x01 == 0) {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 167 set_globalState(StDSIM1);
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 168 } else if (stateUsed->diveSettings.ppo2sensors_deactivated & 0x02 == 0) {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 169 set_globalState(StDSIM3);
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 170 } else if (stateUsed->diveSettings.ppo2sensors_deactivated & 0x04 == 0) {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 171 set_globalState(StDSIM5);
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 172 } else {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 173 set_globalState(StD);
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 174 }
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 175 #endif
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 176 }
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 177 } else {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 178 set_globalState(StD);
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 179 }
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 180 }
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 181
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 182
777
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 183 static void checkSetStateCompassSim(SSettings *settings)
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 184 {
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 185 if (settings->design == 7 && t7_isCompassShowing()) {
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 186 set_globalState(StDBEAR);
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 187 } else {
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 188 checkSetStateSim(settings);
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 189 }
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 190 }
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 191
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 192
38
+ − 193 void tHomeDiveMenuControl(uint8_t sendAction)
+ − 194 {
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 195 SSettings *settings = settingsGetPointer();
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 196
38
+ − 197 if(sendAction == ACTION_BUTTON_NEXT)
+ − 198 {
+ − 199 if(settingsGetPointer()->design == 4)
+ − 200 return;
+ − 201
+ − 202 switch(get_globalState())
+ − 203 {
516
+ − 204 case StD:
+ − 205 if(settingsGetPointer()->design == 6)
38
+ − 206 {
+ − 207 if(is_stateUsedSetToSim())
+ − 208 set_globalState(StDSIM1);
+ − 209 else
+ − 210 set_globalState(StDQUIT);
+ − 211 break;
+ − 212 }
+ − 213
+ − 214 if(settingsGetPointer()->design == 5)
+ − 215 {
+ − 216 if(t5_getCustomView() == CVIEW_Compass)
+ − 217 set_globalState(StDBEAR);
+ − 218 else
+ − 219 set_globalState(StDRAVG);
+ − 220 break;
+ − 221 }
+ − 222
516
+ − 223 if(settingsGetPointer()->design == 3)
+ − 224 {
+ − 225 switch(t3_getCustomView())
+ − 226 {
+ − 227 case CVIEW_T3_Navigation:
+ − 228 case CVIEW_Compass: set_globalState(StDBEAR);
+ − 229 break;
+ − 230 case CVIEW_T3_StopWatch: set_globalState(StDRAVG);
+ − 231 break;
+ − 232 case CVIEW_T3_GasList: if(stateUsed->warnings.betterGas)
+ − 233 {
+ − 234 set_globalState(StDMGAS);
+ − 235 }
838
+ − 236 else
+ − 237 {
+ − 238 set_globalState(StDMENU);
+ − 239 }
516
+ − 240 break;
633
+ − 241 #ifdef ENABLE_T3_PPO_SIM
+ − 242 case CVIEW_sensors: if(is_stateUsedSetToSim())
+ − 243 {
+ − 244 set_globalState(StDSIM1);
+ − 245 }
+ − 246 break;
+ − 247 #endif
628
+ − 248 #ifdef ENABLE_T3_PROFILE_VIEW
613
+ − 249 case CVIEW_T3_Profile: set_globalState(StDMARK);
628
+ − 250 #endif
613
+ − 251 break;
516
+ − 252 default:
739
+ − 253 set_globalState(StDMENU);
516
+ − 254 break;
+ − 255 }
+ − 256 break;
+ − 257 }
+ − 258
38
+ − 259 if(stateUsed->warnings.betterGas)
+ − 260 set_globalState(StDMGAS);
+ − 261 else
+ − 262 if(stateUsed->warnings.betterSetpoint)
+ − 263 set_globalState(StDMSPT);
+ − 264 else
+ − 265 set_globalState(StDMENU);
+ − 266 break;
+ − 267
+ − 268 case StDMGAS:
516
+ − 269 if(settingsGetPointer()->design == 3)
+ − 270 {
+ − 271 set_globalState(StD);
+ − 272 }
+ − 273 else
+ − 274 {
+ − 275 if(stateUsed->warnings.betterSetpoint)
+ − 276 set_globalState(StDMSPT);
+ − 277 else
+ − 278 set_globalState(StDMENU);
+ − 279 }
38
+ − 280 break;
+ − 281
+ − 282 case StDMSPT:
+ − 283 set_globalState(StDMENU);
+ − 284 break;
+ − 285
+ − 286 case StDMENU:
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 287 if (settings->design == 7 && isLoopMode(settings->dive_mode)) {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 288 set_globalState(StDBAILOUT);
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 289
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 290 break;
633
+ − 291 }
+ − 292
777
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 293 checkSetStateCompassSim(settings);
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 294
38
+ − 295 break;
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 296 case StDBAILOUT:
775
46c6d2380d4e
Add a shortcuts to change the setpoint to the loop to the 'normal' display when diving. It is only shown when diving in CCR mode and on the loop.
heinrichsweikamp
diff
changeset
+ − 297 if (settingsGetPointer()->dive_mode == DIVEMODE_CCR && isLoopMode(stateUsed->diveSettings.diveMode) && findSwitchToSetpoint()) {
46c6d2380d4e
Add a shortcuts to change the setpoint to the loop to the 'normal' display when diving. It is only shown when diving in CCR mode and on the loop.
heinrichsweikamp
diff
changeset
+ − 298 set_globalState(StDSETPOINT);
46c6d2380d4e
Add a shortcuts to change the setpoint to the loop to the 'normal' display when diving. It is only shown when diving in CCR mode and on the loop.
heinrichsweikamp
diff
changeset
+ − 299
46c6d2380d4e
Add a shortcuts to change the setpoint to the loop to the 'normal' display when diving. It is only shown when diving in CCR mode and on the loop.
heinrichsweikamp
diff
changeset
+ − 300 break;
46c6d2380d4e
Add a shortcuts to change the setpoint to the loop to the 'normal' display when diving. It is only shown when diving in CCR mode and on the loop.
heinrichsweikamp
diff
changeset
+ − 301 }
46c6d2380d4e
Add a shortcuts to change the setpoint to the loop to the 'normal' display when diving. It is only shown when diving in CCR mode and on the loop.
heinrichsweikamp
diff
changeset
+ − 302
777
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 303 checkSetStateCompassSim(settings);
775
46c6d2380d4e
Add a shortcuts to change the setpoint to the loop to the 'normal' display when diving. It is only shown when diving in CCR mode and on the loop.
heinrichsweikamp
diff
changeset
+ − 304
46c6d2380d4e
Add a shortcuts to change the setpoint to the loop to the 'normal' display when diving. It is only shown when diving in CCR mode and on the loop.
heinrichsweikamp
diff
changeset
+ − 305 break;
46c6d2380d4e
Add a shortcuts to change the setpoint to the loop to the 'normal' display when diving. It is only shown when diving in CCR mode and on the loop.
heinrichsweikamp
diff
changeset
+ − 306 case StDSETPOINT:
777
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 307 checkSetStateCompassSim(settings);
38
+ − 308
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 309 break;
38
+ − 310 case StDSIM1:
+ − 311 set_globalState(StDSIM2);
+ − 312 break;
+ − 313
+ − 314 case StDSIM2:
633
+ − 315 if(settingsGetPointer()->design != 3)
+ − 316 {
+ − 317 set_globalState(StDSIM3);
+ − 318 }
+ − 319 else
+ − 320 {
+ − 321 #ifdef ENABLE_T3_PPO_SIM
+ − 322 if((stateUsed->diveSettings.ppo2sensors_deactivated & 0x02) == 0)
+ − 323 {
+ − 324 set_globalState(StDSIM3);
+ − 325 }
+ − 326 else if((stateUsed->diveSettings.ppo2sensors_deactivated & 0x04) == 0)
+ − 327 {
+ − 328 set_globalState(StDSIM5);
+ − 329 }
+ − 330 else
+ − 331 {
+ − 332 set_globalState(StD);
+ − 333 }
+ − 334 #endif
+ − 335 }
38
+ − 336 break;
+ − 337
+ − 338 case StDSIM3:
+ − 339 set_globalState(StDSIM4);
+ − 340 break;
+ − 341
+ − 342 case StDSIM4:
633
+ − 343 if(settingsGetPointer()->design != 3)
+ − 344 {
+ − 345 set_globalState(StD);
+ − 346 }
+ − 347 else
+ − 348 {
+ − 349 #ifdef ENABLE_T3_PPO_SIM
+ − 350 if((stateUsed->diveSettings.ppo2sensors_deactivated & 0x04) == 0)
+ − 351 {
+ − 352 set_globalState(StDSIM5);
+ − 353 }
+ − 354 else
+ − 355 {
+ − 356 set_globalState(StD);
+ − 357 }
+ − 358 #endif
+ − 359 }
+ − 360 break;
+ − 361 #ifdef ENABLE_T3_PPO_SIM
+ − 362 case StDSIM5:
+ − 363 set_globalState(StDSIM6);
+ − 364 break;
+ − 365
+ − 366 case StDSIM6:
38
+ − 367 set_globalState(StD);
+ − 368 break;
633
+ − 369 #endif
516
+ − 370 case StDBEAR:
777
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 371 if (settingsGetPointer()->design == 7) {
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 372 checkSetStateSim(settings);
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 373
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 374 break;
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 375 }
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 376
516
+ − 377 if(settingsGetPointer()->design == 5)
+ − 378 {
+ − 379 set_globalState(StDRAVG);
+ − 380 }
38
+ − 381
516
+ − 382 if(settingsGetPointer()->design == 3)
+ − 383 {
+ − 384 if(t3_getCustomView() == CVIEW_T3_Navigation)
+ − 385 {
+ − 386 set_globalState(StDRAVG);
+ − 387 }
+ − 388 else
+ − 389 {
+ − 390 set_globalState(StD);
+ − 391 }
+ − 392 }
38
+ − 393 break;
516
+ − 394 case StDRAVG:
+ − 395 if(settingsGetPointer()->design == 5)
+ − 396 {
+ − 397 if(is_stateUsedSetToSim())
+ − 398 set_globalState(StDSIM1);
+ − 399 else
+ − 400 set_globalState(StD);
+ − 401 break;
+ − 402 }
+ − 403 else
+ − 404 {
+ − 405 set_globalState(StD);
+ − 406 }
+ − 407 break;
38
+ − 408 case StDQUIT: // t6_apnea
+ − 409 set_globalState(StD);
+ − 410 break;
+ − 411
619
+ − 412 case StDMARK:
+ − 413 if((settingsGetPointer()->design == 3) && (MiniLiveLogbook_getNextMarkerIndex(0) != 0))
+ − 414 {
+ − 415 set_globalState(StDCHECK);
+ − 416 }
+ − 417 else
+ − 418 {
+ − 419 set_globalState(StD);
+ − 420 }
+ − 421 break;
+ − 422
38
+ − 423 default:
+ − 424 set_globalState(StD);
+ − 425 }
+ − 426 }
+ − 427
+ − 428 if(sendAction == ACTION_BUTTON_ENTER)
+ − 429 {
+ − 430 if(settingsGetPointer()->design == 4)
+ − 431 return;
+ − 432
+ − 433 switch(get_globalState())
+ − 434 {
+ − 435 case StDMGAS:
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 436 openEdit_DiveSelectBetterGas(false);
38
+ − 437 set_globalState(StD);
+ − 438 break;
+ − 439 case StDMSPT:
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 440 openEdit_DiveSelectBetterSetpoint(false);
38
+ − 441 set_globalState(StD);
+ − 442 break;
+ − 443
+ − 444 case StDMENU:
+ − 445 openMenu_first_page_with_OC_gas_update();
+ − 446 break;
+ − 447
+ − 448 case StDSIM1:
633
+ − 449 if(settingsGetPointer()->design != 3)
+ − 450 {
38
+ − 451 Sim_Quit();
633
+ − 452 }
+ − 453 else
+ − 454 {
+ − 455 Sim_IncreasePPO(0);
+ − 456 }
38
+ − 457 break;
+ − 458
+ − 459 case StDSIM2:
633
+ − 460 if(settingsGetPointer()->design != 3)
+ − 461 {
+ − 462 Sim_Ascend();
+ − 463 }
+ − 464 else
+ − 465 {
+ − 466 Sim_DecreasePPO(0);
+ − 467 }
+ − 468
38
+ − 469 break;
+ − 470
+ − 471 case StDSIM3:
633
+ − 472 if(settingsGetPointer()->design != 3)
+ − 473 {
38
+ − 474 Sim_Descend();
633
+ − 475 }
+ − 476 else
+ − 477 {
+ − 478 Sim_IncreasePPO(1);
+ − 479 }
+ − 480
38
+ − 481 break;
+ − 482
+ − 483 case StDSIM4:
633
+ − 484 if(settingsGetPointer()->design != 3)
+ − 485 {
38
+ − 486 Sim_Divetime();
633
+ − 487 }
+ − 488 else
+ − 489 {
+ − 490 Sim_DecreasePPO(1);
+ − 491 }
+ − 492
38
+ − 493 break;
633
+ − 494 #ifdef ENABLE_T3_PPO_SIM
+ − 495 case StDSIM5:
+ − 496 Sim_IncreasePPO(2);
+ − 497 break;
+ − 498 case StDSIM6:
+ − 499 Sim_DecreasePPO(2);
+ − 500 break;
+ − 501 #endif
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 502 case StDBAILOUT:
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 503 if (isLoopMode(stateUsed->diveSettings.diveMode)) {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 504 tMEGas_check_switch_to_bailout();
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 505
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 506 openEdit_DiveSelectBetterGas(true);
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 507 } else {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 508 checkSwitchToLoop();
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 509
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 510 openEdit_DiveSelectBetterSetpoint(true);
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 511 }
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 512
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 513 set_globalState(StD);
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 514
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 515 break;
775
46c6d2380d4e
Add a shortcuts to change the setpoint to the loop to the 'normal' display when diving. It is only shown when diving in CCR mode and on the loop.
heinrichsweikamp
diff
changeset
+ − 516 case StDSETPOINT:
46c6d2380d4e
Add a shortcuts to change the setpoint to the loop to the 'normal' display when diving. It is only shown when diving in CCR mode and on the loop.
heinrichsweikamp
diff
changeset
+ − 517 checkSwitchSetpoint();
46c6d2380d4e
Add a shortcuts to change the setpoint to the loop to the 'normal' display when diving. It is only shown when diving in CCR mode and on the loop.
heinrichsweikamp
diff
changeset
+ − 518
46c6d2380d4e
Add a shortcuts to change the setpoint to the loop to the 'normal' display when diving. It is only shown when diving in CCR mode and on the loop.
heinrichsweikamp
diff
changeset
+ − 519 set_globalState(StD);
46c6d2380d4e
Add a shortcuts to change the setpoint to the loop to the 'normal' display when diving. It is only shown when diving in CCR mode and on the loop.
heinrichsweikamp
diff
changeset
+ − 520
46c6d2380d4e
Add a shortcuts to change the setpoint to the loop to the 'normal' display when diving. It is only shown when diving in CCR mode and on the loop.
heinrichsweikamp
diff
changeset
+ − 521 break;
777
6a8cf91e5b22
This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
heinrichsweikamp
diff
changeset
+ − 522 case StDBEAR: // t5_gauge, t7
774
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
diff
changeset
+ − 523 setCompassHeading((uint16_t)stateUsed->lifeData.compass_heading);
38
+ − 524 set_globalState(StD);
+ − 525 break;
+ − 526
+ − 527 case StDRAVG: // t5_gauge
+ − 528 timer_Stopwatch_Restart();
+ − 529 set_globalState(StD);
+ − 530 break;
+ − 531
+ − 532 case StDQUIT: // t6_apnea
+ − 533 set_globalState(StD); // used to end StDQUIT, is called before everything else because changes are made in the next lines
+ − 534 if(is_stateUsedSetToSim())
+ − 535 Sim_Quit();
+ − 536 else
+ − 537 dataOutGetPointer()->setEndDive = 1;
+ − 538 break;
613
+ − 539 case StDMARK: stateUsedWrite->events.manualMarker = 1;
+ − 540 set_globalState(StD);
+ − 541 break;
38
+ − 542
619
+ − 543 case StDCHECK: MiniLiveLogbook_checkMarker();
+ − 544 break;
38
+ − 545 default:
+ − 546 break;
+ − 547 }
+ − 548 }
+ − 549 }
+ − 550
+ − 551
+ − 552 void tHome_findNextStop(const uint16_t *list, uint8_t *depthOutMeter, uint16_t *lengthOutSeconds)
+ − 553 {
+ − 554 uint8_t ptr = DECOINFO_STRUCT_MAX_STOPS - 1;
+ − 555
+ − 556 while(ptr && !list[ptr])
+ − 557 ptr--;
+ − 558
+ − 559 *lengthOutSeconds = list[ptr];
+ − 560 if(!(*lengthOutSeconds))
+ − 561 {
+ − 562 *depthOutMeter = 0;
+ − 563 }
+ − 564 else
+ − 565 if(ptr == 0)
+ − 566 {
+ − 567 *depthOutMeter = (uint8_t)((stateUsed->diveSettings.last_stop_depth_bar*10.0f) + 0.1f);
+ − 568 }
+ − 569 else
+ − 570 {
+ − 571 ptr -= 1;
+ − 572 *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);
+ − 573 }
+ − 574 }
+ − 575
+ − 576
+ − 577 void tHome_change_field_button_pressed(void)
+ − 578 {
+ − 579 tHome_tick_count_field = 0;
576
+ − 580 tHome_tick_count_o2sens = 0;
38
+ − 581 if(settingsGetPointer()->design == 7)
+ − 582 t7_change_field();
+ − 583 }
+ − 584
+ − 585
361
+ − 586 void tHome_change_customview_button_pressed(uint8_t action)
38
+ − 587 {
+ − 588 tHome_tick_count_cview = 0;
576
+ − 589 tHome_tick_count_o2sens = 0;
+ − 590
38
+ − 591 if(settingsGetPointer()->design == 7)
361
+ − 592 t7_change_customview(action);
38
+ − 593 else
+ − 594 if(settingsGetPointer()->design == 3)
386
+ − 595 t3_change_customview(action);
38
+ − 596 else
+ − 597 if(settingsGetPointer()->design == 5)
386
+ − 598 t5_change_customview(action);
38
+ − 599 else
+ − 600 if(settingsGetPointer()->design == 6)
386
+ − 601 t6_change_customview(action);
38
+ − 602 }
+ − 603
505
+ − 604 uint8_t tHome_getNumberOfAvailableCVs(const uint8_t* pcv_list)
+ − 605 {
+ − 606 uint8_t cnt = 0;
+ − 607
+ − 608 while((pcv_list[cnt] != CVIEW_END) && (pcv_list[cnt] != CVIEW_T3_END))
+ − 609 {
+ − 610 cnt++;
+ − 611 if (cnt > 100) /* just in case an invalid list has been provided... */
+ − 612 {
+ − 613 break;
+ − 614 }
+ − 615 }
+ − 616 cnt--; /* do not count end token */
+ − 617 return cnt;
+ − 618 }
38
+ − 619
+ − 620 void tHome_tick(void)
+ − 621 {
+ − 622 uint16_t field = settingsGetPointer()->tX_userselectedLeftLowerCornerTimeout;
+ − 623 uint16_t cview = settingsGetPointer()->tX_customViewTimeout;
+ − 624
+ − 625 if(field)
+ − 626 {
+ − 627 tHome_tick_count_field++;
+ − 628 if(tHome_tick_count_field > (field * 10))
+ − 629 {
+ − 630 tHome_tick_count_field = 0;
+ − 631 if(settingsGetPointer()->design == 7)
+ − 632 {
+ − 633 t7_set_field_to_primary();
+ − 634 }
+ − 635 }
+ − 636 }
+ − 637
+ − 638 if(cview)
+ − 639 {
+ − 640 tHome_tick_count_cview++;
+ − 641 if(tHome_tick_count_cview > (cview *10))
+ − 642 {
+ − 643 tHome_tick_count_cview = 0;
805
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
diff
changeset
+ − 644 if (settingsGetPointer()->design == 7 && !t7_isTimerRunning(false)) {
38
+ − 645 t7_set_customview_to_primary();
+ − 646 }
541
+ − 647 if(settingsGetPointer()->design == 3)
+ − 648 {
+ − 649 t3_set_customview_to_primary();
+ − 650 }
38
+ − 651 }
+ − 652 }
576
+ − 653
810
+ − 654 if((stateUsed->mode == MODE_SURFACE) && (!t7_customview_disabled(CVIEW_sensors)))
576
+ − 655 {
+ − 656 tHome_tick_count_o2sens++;
+ − 657 if(tHome_tick_count_o2sens > AUTORETURN_O2SENS)
+ − 658 {
+ − 659 tHome_tick_count_o2sens = 0;
810
+ − 660 if((stateUsed->chargeStatus == CHARGER_off)
+ − 661 || (stateUsed->lifeData.ppO2Sensor_bar[0] != 0.0)
+ − 662 || (stateUsed->lifeData.ppO2Sensor_bar[1] != 0.0)
+ − 663 || (stateUsed->lifeData.ppO2Sensor_bar[2] != 0.0))
+ − 664 {
+ − 665 t7_select_customview(CVIEW_sensors);
+ − 666 }
576
+ − 667 }
+ − 668 }
805
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
diff
changeset
+ − 669
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
diff
changeset
+ − 670 t7_tick();
38
+ − 671 }
+ − 672
+ − 673
+ − 674 uint32_t tHome_DateCode(RTC_DateTypeDef *dateInput)
+ − 675 {
+ − 676 uint32_t answer = 0;
+ − 677
+ − 678 answer = 0;
+ − 679 answer += (dateInput->Year & 0x7F)<< 9;
+ − 680 answer += (dateInput->Month & 0x0F)<< 5;
+ − 681 answer += (dateInput->Date & 0x1F);
+ − 682
+ − 683 return answer;
+ − 684 }
+ − 685
+ − 686
+ − 687 uint8_t tHome_gas_writer(uint8_t oxygen_percentage, uint8_t helium_percentage, char *text)
+ − 688 {
+ − 689 if(oxygen_percentage == 100)
+ − 690 return (uint8_t) snprintf(text,10,"Oxy");
+ − 691 else if((oxygen_percentage == 21) && (!helium_percentage))
+ − 692 return (uint8_t) snprintf(text,10,"Air");
+ − 693 else if(!helium_percentage)
+ − 694 return (uint8_t) snprintf(text,10,"NX%02i",oxygen_percentage);
+ − 695 else if((oxygen_percentage + helium_percentage) == 100)
+ − 696 return (uint8_t) snprintf(text,10,"HX%02i",oxygen_percentage);
+ − 697 else
+ − 698 return (uint8_t) snprintf(text,10,"%02i/%02i",oxygen_percentage,helium_percentage);
+ − 699 }
+ − 700
+ − 701 uint8_t tHome_show_lost_connection_count(GFX_DrawCfgScreen *ScreenToWriteOn)
+ − 702 {
208
+ − 703 static uint8_t LastKnowRTEState = SPI_RX_STATE_INVALID;
+ − 704
99
+ − 705 if(!SPI_MIN_ERROR_SHOW) return 0;
172
+ − 706 if(DataEX_lost_connection_count()>=SPI_MIN_ERROR_SHOW && SPI_SHOW_SYNC_STATS){
38
+ − 707
99
+ − 708 char text[64];
38
+ − 709
82
+ − 710 SDataExchangeSlaveToMaster* dataIn=get_dataInPointer();
208
+ − 711 SDataReceiveFromMaster* pDataOut = dataOutGetPointer();
82
+ − 712
493
b560e474e319
Added possibility to switch between "classic" bigfont views and a selection with a new information combination
Ideenmodellierer
diff
changeset
+ − 713 snprintf(text,32,"spi err:\002 %ld/%ld",DataEX_lost_connection_count(),get_num_SPI_CALLBACKS());
99
+ − 714 Gfx_write_label_var(ScreenToWriteOn, 100,300, 0,&FontT24,CLUT_ButtonSymbols,text);
82
+ − 715
104
+ − 716 // 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]);
+ − 717 // Gfx_write_label_var(ScreenToWriteOn, 350,550, 0,&FontT24,CLUT_ButtonSymbols,text);
82
+ − 718
208
+ − 719 //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]);
+ − 720
+ − 721 /* data shifted => ignore received data */
+ − 722 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))
+ − 723 {
+ − 724 dataIn->header.checkCode[SPI_HEADER_INDEX_RX_STATE] = LastKnowRTEState;
+ − 725 }
+ − 726 else
+ − 727 {
+ − 728 LastKnowRTEState =dataIn->header.checkCode[SPI_HEADER_INDEX_RX_STATE];
+ − 729 }
+ − 730 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
+ − 731 Gfx_write_label_var(ScreenToWriteOn, 600,800, 0,&FontT24,CLUT_ButtonSymbols,text);
+ − 732 }
82
+ − 733
99
+ − 734
+ − 735
+ − 736 // snprintf(text,32,"cpt:\002%i",get_num_SPI_CALLBACKS());
+ − 737 // Gfx_write_label_var(ScreenToWriteOn, 600,800, 90,&FontT24,CLUT_ButtonSymbols,text);
82
+ − 738
+ − 739 // snprintf(text,10,"i2c:\002%i",get_DataEX_Error_place());
+ − 740 // Gfx_write_label_var(ScreenToWriteOn, 600,800, 90,&FontT24,CLUT_ButtonSymbols,text);
38
+ − 741
+ − 742 return DataEX_lost_connection_count();
+ − 743 }