comparison Discovery/Src/tMenuEditSetpoint.c @ 662:1b995079c045 Betatest

PSCR Mode
author heinrichs weikamp
date Tue, 14 Dec 2021 15:36:10 +0100
parents f6212495f34f
children 2c243233c999
comparison
equal deleted inserted replaced
661:87bee7cc77b3 662:1b995079c045
56 /* Exported functions --------------------------------------------------------*/ 56 /* Exported functions --------------------------------------------------------*/
57 57
58 void openEdit_Setpoint(uint8_t line) 58 void openEdit_Setpoint(uint8_t line)
59 { 59 {
60 uint8_t useSensorSubMenu = 0; 60 uint8_t useSensorSubMenu = 0;
61 char text[20];
62 uint8_t sensorActive[3];
61 63
62 /* dive mode */ 64 /* dive mode */
63 if(actual_menu_content != MENU_SURFACE) 65 if(actual_menu_content != MENU_SURFACE)
64 { 66 {
65 uint8_t setpointCbar, actualGasID; 67 uint8_t setpointCbar, actualGasID;
66 setpointCbar = 100; 68 setpointCbar = 100;
67 69
68 // actualGasID 70 // actualGasID
69 if(stateUsedWrite->diveSettings.diveMode != DIVEMODE_CCR) 71 if(!isLoopMode(stateUsedWrite->diveSettings.diveMode))
70 { 72 {
71 actualGasID = stateUsedWrite->lifeData.lastDiluent_GasIdInSettings; 73 actualGasID = stateUsedWrite->lifeData.lastDiluent_GasIdInSettings;
72 if((actualGasID <= NUM_OFFSET_DILUENT) || (actualGasID > NUM_GASES + NUM_OFFSET_DILUENT)) 74 if((actualGasID <= NUM_OFFSET_DILUENT) || (actualGasID > NUM_GASES + NUM_OFFSET_DILUENT))
73 actualGasID = NUM_OFFSET_DILUENT + 1; 75 actualGasID = NUM_OFFSET_DILUENT + 1;
74 } 76 }
75 else 77 else
76 actualGasID = stateUsedWrite->lifeData.actualGas.GasIdInSettings; 78 actualGasID = stateUsedWrite->lifeData.actualGas.GasIdInSettings;
77 79
78 // setpointCbar, CCR_Mode and sensor menu 80 // setpointCbar, CCR_Mode and sensor menu
79 if(line < 6) 81 if((line < 6) && (stateUsedWrite->diveSettings.diveMode != DIVEMODE_PSCR)) /* setpoints inactive in PSCR mode */
80 { 82 {
81 setpointCbar = stateUsedWrite->diveSettings.setpoint[line].setpoint_cbar; 83 setpointCbar = stateUsedWrite->diveSettings.setpoint[line].setpoint_cbar;
82 stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint; 84 stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint;
83 85
84 // BetterSetpoint warning only once 86 // BetterSetpoint warning only once
94 stateUsedWrite->diveSettings.setpoint[i].note.ub.active = 0; 96 stateUsedWrite->diveSettings.setpoint[i].note.ub.active = 0;
95 } 97 }
96 stateUsedWrite->diveSettings.setpoint[line].note.ub.first = 1; 98 stateUsedWrite->diveSettings.setpoint[line].note.ub.first = 1;
97 } 99 }
98 } 100 }
99 else 101 else /* menu item not pointing to setpoint selection => use sensor or ppo2 simulation */
100 { 102 {
101 if(stateUsedWrite->diveSettings.CCR_Mode != CCRMODE_Sensors) 103 if((stateUsedWrite->diveSettings.diveMode == DIVEMODE_PSCR) && (line == 2))
102 { 104 {
103 /* setpoint_cbar will be written by updateSetpointStateUsed() in main.c loop */ 105 stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_Simulation;
104 setpointCbar = 255; 106 }
105 stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_Sensors; 107 else /* => use sensor */
106 } 108 {
107 else 109 if(stateUsedWrite->diveSettings.CCR_Mode != CCRMODE_Sensors)
108 { 110 {
109 useSensorSubMenu = 1; 111 /* setpoint_cbar will be written by updateSetpointStateUsed() in main.c loop */
110 } 112 setpointCbar = 255;
113 stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_Sensors;
114 }
115 else
116 {
117 useSensorSubMenu = 1;
118 }
119 }
111 } 120 }
112 121
113 setActualGas_DM(&stateUsedWrite->lifeData,actualGasID,setpointCbar); 122 setActualGas_DM(&stateUsedWrite->lifeData,actualGasID,setpointCbar);
114 123
115 if(stateUsedWrite->diveSettings.diveMode != DIVEMODE_CCR) 124 if(!isLoopMode(stateUsedWrite->diveSettings.diveMode))
116 { 125 {
117 stateUsedWrite->diveSettings.diveMode = DIVEMODE_CCR; 126 stateUsedWrite->diveSettings.diveMode = settingsGetPointer()->dive_mode;
118 unblock_diluent_page(); 127 unblock_diluent_page();
119 } 128 }
120 129
121 clear_warning_fallback(); 130 clear_warning_fallback();
122 131
126 } 135 }
127 else // entire sub menu during dive to select sensors active 136 else // entire sub menu during dive to select sensors active
128 { 137 {
129 set_globalState_Menu_Line(line); 138 set_globalState_Menu_Line(line);
130 resetMenuEdit(CLUT_MenuPageGasSP); 139 resetMenuEdit(CLUT_MenuPageGasSP);
131
132 char text[20];
133 uint8_t sensorActive[3];
134 140
135 text[0] = '\001'; 141 text[0] = '\001';
136 text[1] = TXT_o2Sensors; 142 text[1] = TXT_o2Sensors;
137 text[2] = 0; 143 text[2] = 0;
138 write_topline(text); 144 write_topline(text);
143 sensorActive[0] = 0; 149 sensorActive[0] = 0;
144 } 150 }
145 else 151 else
146 { 152 {
147 snprintf (text,20,"Sensor 1 (%01.2f)", stateUsed->lifeData.ppO2Sensor_bar[0] ); 153 snprintf (text,20,"Sensor 1 (%01.2f)", stateUsed->lifeData.ppO2Sensor_bar[0] );
154 sensorActive[0] = 1;
148 } 155 }
149 write_label_var( 96, 600, ME_Y_LINE1, &FontT48, text); 156 write_label_var( 96, 600, ME_Y_LINE1, &FontT48, text);
150 if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 2) 157 if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 2)
151 { 158 {
152 snprintf (text,20,"Sensor 2"); 159 snprintf (text,20,"Sensor 2");
153 sensorActive[1] = 0; 160 sensorActive[1] = 0;
154 } 161 }
155 else 162 else
156 { 163 {
157 snprintf (text,20,"Sensor 2 (%01.2f)", stateUsed->lifeData.ppO2Sensor_bar[1] ); 164 snprintf (text,20,"Sensor 2 (%01.2f)", stateUsed->lifeData.ppO2Sensor_bar[1] );
165 sensorActive[1] = 1;
158 } 166 }
159 write_label_var( 96, 600, ME_Y_LINE2, &FontT48, text); 167 write_label_var( 96, 600, ME_Y_LINE2, &FontT48, text);
160 if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 4) 168 if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 4)
161 { 169 {
162 snprintf (text,20,"Sensor 3"); 170 snprintf (text,20,"Sensor 3");
163 sensorActive[2] = 0; 171 sensorActive[2] = 0;
164 } 172 }
165 else 173 else
166 { 174 {
167 snprintf (text,20,"Sensor 3 (%01.2f)", stateUsed->lifeData.ppO2Sensor_bar[2] ); 175 snprintf (text,20,"Sensor 3 (%01.2f)", stateUsed->lifeData.ppO2Sensor_bar[2] );
176 sensorActive[2] = 1;
168 } 177 }
169 write_label_var( 96, 600, ME_Y_LINE3, &FontT48, text); 178 write_label_var( 96, 600, ME_Y_LINE3, &FontT48, text);
170
171 sensorActive[0] = 1;
172 sensorActive[1] = 1;
173 sensorActive[2] = 1;
174 179
175 write_field_on_off(StMSP_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", sensorActive[0]); 180 write_field_on_off(StMSP_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", sensorActive[0]);
176 write_field_on_off(StMSP_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]); 181 write_field_on_off(StMSP_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]);
177 write_field_on_off(StMSP_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", sensorActive[2]); 182 write_field_on_off(StMSP_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", sensorActive[2]);
178 183
327 void openEdit_DiveSelectBetterSetpoint(void) 332 void openEdit_DiveSelectBetterSetpoint(void)
328 { 333 {
329 uint8_t spId; 334 uint8_t spId;
330 uint8_t depth; 335 uint8_t depth;
331 336
332 spId = actualBetterSetpointId(); 337 if(stateUsedWrite->diveSettings.diveMode != DIVEMODE_PSCR) /* no setpoints in PSCR mode */
333 338 {
334 depth = stateUsedWrite->diveSettings.setpoint[spId].depth_meter; 339 spId = actualBetterSetpointId();
335 340
336 // BetterSetpoint warning only once -> clear active 341 depth = stateUsedWrite->diveSettings.setpoint[spId].depth_meter;
337 for(int i=0; i<=NUM_GASES; i++) 342
338 { 343 // BetterSetpoint warning only once -> clear active
339 stateUsedWrite->diveSettings.setpoint[i].note.ub.first = 0; 344 for(int i=0; i<=NUM_GASES; i++)
340 if(stateUsedWrite->diveSettings.setpoint[i].depth_meter <= depth) 345 {
341 stateUsedWrite->diveSettings.setpoint[i].note.ub.active = 0; 346 stateUsedWrite->diveSettings.setpoint[i].note.ub.first = 0;
342 } 347 if(stateUsedWrite->diveSettings.setpoint[i].depth_meter <= depth)
343 348 stateUsedWrite->diveSettings.setpoint[i].note.ub.active = 0;
344 // new setpoint 349 }
345 stateUsedWrite->diveSettings.setpoint[spId].note.ub.first = 1; 350
346 351 // new setpoint
347 // change in lifeData 352 stateUsedWrite->diveSettings.setpoint[spId].note.ub.first = 1;
348 setActualGas_DM(&stateUsedWrite->lifeData, stateUsedWrite->lifeData.actualGas.GasIdInSettings, stateUsedWrite->diveSettings.setpoint[spId].setpoint_cbar); 353
354 // change in lifeData
355 setActualGas_DM(&stateUsedWrite->lifeData, stateUsedWrite->lifeData.actualGas.GasIdInSettings, stateUsedWrite->diveSettings.setpoint[spId].setpoint_cbar);
356 }
349 } 357 }
350 358
351 static uint8_t OnAction_SP_DM_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 359 static uint8_t OnAction_SP_DM_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
352 { 360 {
353 if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 1) 361 if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 1)