comparison Discovery/Src/tMenuEditGasOC.c @ 288:ba229a012ac7 div-fixes-6

cleanup: no useless checks for simulator state and some more in the style of commit 74a8296a2318. And in addition more cleanup like removing commented and unused code, and making things static. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Mon, 29 Apr 2019 19:43:05 +0200
parents e1d66bc78f9a
children 3f09b283d993
comparison
equal deleted inserted replaced
287:ba9d99a2e310 288:ba229a012ac7
146 } 146 }
147 147
148 148
149 void openEdit_DiveGasSelect_Subroutine(uint8_t line, uint8_t ccr) 149 void openEdit_DiveGasSelect_Subroutine(uint8_t line, uint8_t ccr)
150 { 150 {
151 SDiveState * pState;
152 uint8_t setpoint; 151 uint8_t setpoint;
153 152
154 if(actual_menu_content == MENU_DIVE_REAL) 153 editGasPage.pGasLine = stateUsed->diveSettings.gas;
155 {
156 pState = stateRealGetPointerWrite();
157 editGasPage.pGasLine = pState->diveSettings.gas;
158 }
159 else
160 {
161 pState = stateSimGetPointerWrite();
162 editGasPage.pGasLine = pState->diveSettings.gas;
163 }
164 154
165 if(ccr) 155 if(ccr)
166 { 156 {
167 editGasPage.gasID = line + NUM_OFFSET_DILUENT; 157 editGasPage.gasID = line + NUM_OFFSET_DILUENT;
168 setpoint = pState->lifeData.actualGas.setPoint_cbar; 158 setpoint = stateUsed->lifeData.actualGas.setPoint_cbar;
169 } 159 }
170 else 160 else
171 { 161 {
172 editGasPage.gasID = line; 162 editGasPage.gasID = line;
173 setpoint = 0; 163 setpoint = 0;
176 for(int i=0;i<(1+ (2*NUM_GASES));i++) 166 for(int i=0;i<(1+ (2*NUM_GASES));i++)
177 editGasPage.pGasLine[i].note.ub.first = 0; 167 editGasPage.pGasLine[i].note.ub.first = 0;
178 168
179 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1; 169 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1;
180 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 1; 170 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 1;
181 setActualGas_DM(&pState->lifeData,editGasPage.gasID,setpoint); 171 setActualGas_DM(&stateUsedWrite->lifeData,editGasPage.gasID,setpoint);
182 } 172 }
183 173
184 /* extra gas and gas on/off option */ 174 /* extra gas and gas on/off option */
185 void openEdit_SpecialDiveGasMenu(uint8_t ccr) 175 void openEdit_SpecialDiveGasMenu(uint8_t ccr)
186 { 176 {
187 char text[32]; 177 char text[32];
188 uint8_t oxygen, helium, gasOffset, textpointer, lineCount, ptrGas; 178 uint8_t oxygen, helium, gasOffset, textpointer, lineCount, ptrGas;
189 SDiveState * pState; 179 //SDiveState * pState;
190 180
191 if(actual_menu_content == MENU_DIVE_REAL) 181 editGasPage.pGasLine = stateUsed->diveSettings.gas;
192 {
193 pState = stateRealGetPointerWrite();
194 editGasPage.pGasLine = pState->diveSettings.gas;
195 }
196 else
197 {
198 pState = stateSimGetPointerWrite();
199 editGasPage.pGasLine = pState->diveSettings.gas;
200 }
201 if(ccr) 182 if(ccr)
202 { 183 {
203 editGasPage.setpoint = pState->lifeData.actualGas.setPoint_cbar; 184 editGasPage.setpoint = stateUsed->lifeData.actualGas.setPoint_cbar;
204 } 185 }
205 editGasPage.ccr = ccr; 186 editGasPage.ccr = ccr;
206 187
207 set_globalState_Menu_Line(6); 188 set_globalState_Menu_Line(6);
208 189
320 if(newHelium > 95) 301 if(newHelium > 95)
321 newHelium = 95; 302 newHelium = 95;
322 if((newOxygen + newHelium) > 100) 303 if((newOxygen + newHelium) > 100)
323 newOxygen = 100 - newHelium; 304 newOxygen = 100 - newHelium;
324 305
325 SDiveState * pDiveState = 0; 306 //SDiveState * pDiveState = 0;
326 307
327 for(int i=1;i<=(2*NUM_GASES);i++) 308 for(int i=1;i<=(2*NUM_GASES);i++)
328 editGasPage.pGasLine[i].note.ub.first = 0; 309 editGasPage.pGasLine[i].note.ub.first = 0;
329 310
330 if(actual_menu_content == MENU_DIVE_REAL) 311 setActualGas_ExtraGas(&stateUsedWrite->lifeData, newOxygen, newHelium, 0);
331 pDiveState = stateRealGetPointerWrite();
332 else
333 pDiveState = stateSimGetPointerWrite();
334
335 setActualGas_ExtraGas(&pDiveState->lifeData, newOxygen, newHelium, 0);
336 tMEGas_check_switch_to_bailout(); 312 tMEGas_check_switch_to_bailout();
337 return EXIT_TO_HOME; 313 return EXIT_TO_HOME;
338 } 314 }
339 if(action == ACTION_BUTTON_NEXT) 315 if(action == ACTION_BUTTON_NEXT)
340 { 316 {
355 } 331 }
356 332
357 333
358 void tMEGas_check_switch_to_bailout(void) 334 void tMEGas_check_switch_to_bailout(void)
359 { 335 {
360 SDiveState *pState; 336 if(stateUsed->diveSettings.diveMode == DIVEMODE_CCR)
361 337 {
362 if(actual_menu_content == MENU_DIVE_REAL) 338 stateUsedWrite->diveSettings.diveMode = DIVEMODE_OC;
363 pState = stateRealGetPointerWrite();
364 else
365 pState = stateSimGetPointerWrite();
366
367 if(pState->diveSettings.diveMode == DIVEMODE_CCR)
368 {
369 pState->diveSettings.diveMode = DIVEMODE_OC;
370 block_diluent_page(); 339 block_diluent_page();
371 } 340 }
372 } 341 }
373 342
374 343