Mercurial > public > ostc4
comparison Discovery/Src/tMenuEditSetpoint.c @ 773:2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
author | heinrichsweikamp |
---|---|
date | Wed, 10 May 2023 16:24:57 +0200 |
parents | 1b995079c045 |
children | 46c6d2380d4e |
comparison
equal
deleted
inserted
replaced
772:b7e43b28bee1 | 773:2c243233c999 |
---|---|
25 /// You should have received a copy of the GNU General Public License | 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/>. | 26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. |
27 ////////////////////////////////////////////////////////////////////////////// | 27 ////////////////////////////////////////////////////////////////////////////// |
28 | 28 |
29 /* Includes ------------------------------------------------------------------*/ | 29 /* Includes ------------------------------------------------------------------*/ |
30 #include <stdbool.h> | |
31 | |
30 #include "tMenuEditSetpoint.h" | 32 #include "tMenuEditSetpoint.h" |
31 | 33 |
32 #include "check_warning.h" | 34 #include "check_warning.h" |
33 #include "gfx_fonts.h" | 35 #include "gfx_fonts.h" |
34 #include "tMenuEdit.h" | 36 #include "tMenuEdit.h" |
52 static uint8_t OnAction_SP_DM_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 54 static uint8_t OnAction_SP_DM_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
53 static uint8_t OnAction_SP_DM_Sensor2 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 55 static uint8_t OnAction_SP_DM_Sensor2 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
54 static uint8_t OnAction_SP_DM_Sensor3 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 56 static uint8_t OnAction_SP_DM_Sensor3 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
55 | 57 |
56 /* Exported functions --------------------------------------------------------*/ | 58 /* Exported functions --------------------------------------------------------*/ |
59 | |
60 void checkSwitchToLoop(void) | |
61 { | |
62 if(!isLoopMode(stateUsedWrite->diveSettings.diveMode)) { | |
63 stateUsedWrite->diveSettings.diveMode = settingsGetPointer()->dive_mode; | |
64 | |
65 unblock_diluent_page(); | |
66 } | |
67 } | |
68 | |
57 | 69 |
58 void openEdit_Setpoint(uint8_t line) | 70 void openEdit_Setpoint(uint8_t line) |
59 { | 71 { |
60 uint8_t useSensorSubMenu = 0; | 72 uint8_t useSensorSubMenu = 0; |
61 char text[20]; | 73 char text[20]; |
119 } | 131 } |
120 } | 132 } |
121 | 133 |
122 setActualGas_DM(&stateUsedWrite->lifeData,actualGasID,setpointCbar); | 134 setActualGas_DM(&stateUsedWrite->lifeData,actualGasID,setpointCbar); |
123 | 135 |
124 if(!isLoopMode(stateUsedWrite->diveSettings.diveMode)) | 136 checkSwitchToLoop(); |
125 { | |
126 stateUsedWrite->diveSettings.diveMode = settingsGetPointer()->dive_mode; | |
127 unblock_diluent_page(); | |
128 } | |
129 | 137 |
130 clear_warning_fallback(); | 138 clear_warning_fallback(); |
131 | 139 |
132 if(!useSensorSubMenu) | 140 if(!useSensorSubMenu) |
133 { | 141 { |
327 } | 335 } |
328 | 336 |
329 return EXIT_TO_MENU; | 337 return EXIT_TO_MENU; |
330 } | 338 } |
331 | 339 |
332 void openEdit_DiveSelectBetterSetpoint(void) | 340 void openEdit_DiveSelectBetterSetpoint(bool useLastDiluent) |
333 { | 341 { |
334 uint8_t spId; | 342 uint8_t spId; |
335 uint8_t depth; | 343 uint8_t depth; |
336 | 344 |
337 if(stateUsedWrite->diveSettings.diveMode != DIVEMODE_PSCR) /* no setpoints in PSCR mode */ | 345 if(stateUsedWrite->diveSettings.diveMode != DIVEMODE_PSCR) /* no setpoints in PSCR mode */ |
349 } | 357 } |
350 | 358 |
351 // new setpoint | 359 // new setpoint |
352 stateUsedWrite->diveSettings.setpoint[spId].note.ub.first = 1; | 360 stateUsedWrite->diveSettings.setpoint[spId].note.ub.first = 1; |
353 | 361 |
362 uint8_t gasId; | |
363 if (useLastDiluent) { | |
364 gasId = stateUsed->lifeData.lastDiluent_GasIdInSettings; | |
365 } else { | |
366 gasId = stateUsed->lifeData.actualGas.GasIdInSettings; | |
367 } | |
368 | |
354 // change in lifeData | 369 // change in lifeData |
355 setActualGas_DM(&stateUsedWrite->lifeData, stateUsedWrite->lifeData.actualGas.GasIdInSettings, stateUsedWrite->diveSettings.setpoint[spId].setpoint_cbar); | 370 setActualGas_DM(&stateUsedWrite->lifeData, gasId, stateUsedWrite->diveSettings.setpoint[spId].setpoint_cbar); |
356 } | 371 } |
357 } | 372 } |
373 | |
358 | 374 |
359 static uint8_t OnAction_SP_DM_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 375 static uint8_t OnAction_SP_DM_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
360 { | 376 { |
361 if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 1) | 377 if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 1) |
362 { | 378 { |