Mercurial > public > ostc4
comparison Discovery/Src/tMenuEditSystem.c @ 844:e04d7dd199fb Evo_2_23
Added option to adjust pressure to diveO2 reference:
The DiveO2 internal pressure sensor is more prezise (on surface) than the pressure sensor of the OSTC which is focusing on measurement of pressure under water (different scale). The offset of the OSTC sensor may now be compensated using the maintainance menu. During the implementation the menu has been restructured. Befor it was based on the confirmation dialog, in the new version it is a stand alone menu.
author | Ideenmodellierer |
---|---|
date | Sun, 21 Jan 2024 22:18:51 +0100 |
parents | dd7ce655db26 |
children | 48b6a3b1f3f8 |
comparison
equal
deleted
inserted
replaced
843:2cab242c9a4a | 844:e04d7dd199fb |
---|---|
50 void openEdit_DateTime(void); | 50 void openEdit_DateTime(void); |
51 void openEdit_Language(void); | 51 void openEdit_Language(void); |
52 void openEdit_Design(void); | 52 void openEdit_Design(void); |
53 void openEdit_Information(void); | 53 void openEdit_Information(void); |
54 void openEdit_Reset(void); | 54 void openEdit_Reset(void); |
55 void openEdit_Maintenance(void); | |
55 //void openEdit_ShowDebugInfo(void); | 56 //void openEdit_ShowDebugInfo(void); |
56 //void openEdit_Salinity(void); | 57 //void openEdit_Salinity(void); |
57 | 58 |
58 /* Announced function prototypes -----------------------------------------------*/ | 59 /* Announced function prototypes -----------------------------------------------*/ |
59 uint8_t OnAction_Date (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 60 uint8_t OnAction_Date (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
76 uint8_t OnAction_Colorscheme (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 77 uint8_t OnAction_Colorscheme (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
77 uint8_t OnAction_DebugInfo (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 78 uint8_t OnAction_DebugInfo (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
78 | 79 |
79 uint8_t OnAction_Exit (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 80 uint8_t OnAction_Exit (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
80 uint8_t OnAction_Confirm (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 81 uint8_t OnAction_Confirm (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
82 uint8_t OnAction_Maintenance (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
81 uint8_t OnAction_RebootRTE (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 83 uint8_t OnAction_RebootRTE (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
82 uint8_t OnAction_ResetDeco (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 84 uint8_t OnAction_ResetDeco (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
83 uint8_t OnAction_ResetAll (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 85 uint8_t OnAction_ResetAll (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
84 uint8_t OnAction_ResetLogbook (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 86 uint8_t OnAction_ResetLogbook (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
85 uint8_t OnAction_RebootMainCPU (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 87 uint8_t OnAction_RebootMainCPU (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
86 uint8_t OnAction_Nothing (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 88 uint8_t OnAction_Nothing (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
87 uint8_t OnAction_LogbookOffset(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 89 uint8_t OnAction_LogbookOffset(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
88 uint8_t OnAction_SetFactoryDefaults(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 90 uint8_t OnAction_SetFactoryDefaults(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
89 uint8_t OnAction_SetBatteryCharge(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 91 uint8_t OnAction_SetBatteryCharge(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
92 uint8_t OnAction_AdjustSurfacePressure (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
90 #ifdef ENABLE_ANALYSE_SAMPLES | 93 #ifdef ENABLE_ANALYSE_SAMPLES |
91 uint8_t OnAction_RecoverSampleIdx(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 94 uint8_t OnAction_RecoverSampleIdx(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
92 #endif | 95 #endif |
93 #ifdef SCREENTEST | 96 #ifdef SCREENTEST |
94 uint8_t OnAction_ScreenTest (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 97 uint8_t OnAction_ScreenTest (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
1073 | 1076 |
1074 setEvent(StMSYS5_LogbookOffset, (uint32_t)OnAction_LogbookOffset); | 1077 setEvent(StMSYS5_LogbookOffset, (uint32_t)OnAction_LogbookOffset); |
1075 setEvent(StMSYS5_ResetAll, (uint32_t)OnAction_Confirm); | 1078 setEvent(StMSYS5_ResetAll, (uint32_t)OnAction_Confirm); |
1076 setEvent(StMSYS5_ResetDeco, (uint32_t)OnAction_Confirm); | 1079 setEvent(StMSYS5_ResetDeco, (uint32_t)OnAction_Confirm); |
1077 setEvent(StMSYS5_Reboot, (uint32_t)OnAction_Confirm); | 1080 setEvent(StMSYS5_Reboot, (uint32_t)OnAction_Confirm); |
1078 setEvent(StMSYS5_Maintenance, (uint32_t)OnAction_Confirm); | 1081 setEvent(StMSYS5_Maintenance, (uint32_t)OnAction_Maintenance); |
1079 #ifndef RESETLOGBLOCK | 1082 #ifndef RESETLOGBLOCK |
1080 setEvent(StMSYS5_ResetLogbook, (uint32_t)OnAction_Confirm); | 1083 setEvent(StMSYS5_ResetLogbook, (uint32_t)OnAction_Confirm); |
1081 #else | 1084 #else |
1082 setEvent(StMSYS5_ResetLogbook, (uint32_t)OnAction_Nothing); | 1085 setEvent(StMSYS5_ResetLogbook, (uint32_t)OnAction_Nothing); |
1083 #endif | 1086 #endif |
1148 text[1] = TXT2BYTE_ResetLogbook; | 1151 text[1] = TXT2BYTE_ResetLogbook; |
1149 write_field_button(editIdOfCaller, 30, 800, ME_Y_LINE2, &FontT48, text); | 1152 write_field_button(editIdOfCaller, 30, 800, ME_Y_LINE2, &FontT48, text); |
1150 setEvent(StMSYS5_Exit, (uint32_t)OnAction_Exit); | 1153 setEvent(StMSYS5_Exit, (uint32_t)OnAction_Exit); |
1151 setEvent(editIdOfCaller, (uint32_t)OnAction_ResetLogbook); | 1154 setEvent(editIdOfCaller, (uint32_t)OnAction_ResetLogbook); |
1152 break; | 1155 break; |
1153 | 1156 } |
1154 case StMSYS5_Maintenance: | 1157 |
1155 case StMSYS5_SetBattCharge: | 1158 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); |
1156 case StMSYS5_SetSampleIndx: | 1159 } |
1160 | |
1161 void openEdit_Maintenance(void) | |
1162 { | |
1163 char text[32]; | |
1164 unsigned char index = 0; | |
1165 SSettings *pSettings = settingsGetPointer(); | |
1166 SSensorDataDiveO2* pDiveO2Data = NULL; | |
1167 | |
1168 resetMenuEdit(CLUT_MenuPageSystem); | |
1169 | |
1170 text[0] = '\001'; | |
1171 text[1] = TXT_2BYTE; | |
1172 text[2] = TXT2BYTE_Maintenance; | |
1173 text[3] = 0; | |
1174 write_topline(text); | |
1175 | |
1176 text[0] = TXT_2BYTE; | |
1177 text[1] = TXT2BYTE_SetFactoryDefaults; | |
1178 text[2] = 0; | |
1179 write_field_button(StMSYS5_SetFactoryBC, 30, 800, ME_Y_LINE1, &FontT48, text); | |
1180 | |
1181 | |
1182 if(stateRealGetPointer()->lifeData.battery_charge <= 0) | |
1183 { | |
1157 text[0] = TXT_2BYTE; | 1184 text[0] = TXT_2BYTE; |
1158 text[1] = TXT2BYTE_SetFactoryDefaults; | 1185 text[1] = TXT2BYTE_SetBatteryCharge; |
1159 text[2] = 0; | 1186 text[2] = 0; |
1160 write_field_button(StMSYS5_SetFactoryBC, 30, 800, ME_Y_LINE2, &FontT48, text); | 1187 snprintf(&text[2],10,": %u%%",pSettings->lastKnownBatteryPercentage); |
1188 write_field_button(StMSYS5_SetBattCharge, 30, 800, ME_Y_LINE2, &FontT48, text); | |
1189 } | |
1190 | |
1191 if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_DIGITAL)) | |
1192 { | |
1193 for (index = 0; index < 3; index++) | |
1194 { | |
1195 if(pSettings->ext_sensor_map[index] == SENSOR_DIGO2M) | |
1196 { | |
1197 pDiveO2Data = (SSensorDataDiveO2*)stateRealGetPointer()->lifeData.extIf_sensor_data[index]; | |
1198 if(pDiveO2Data->pressure != 0) | |
1199 { | |
1200 snprintf(text,32,"%c%c (%1.3lf => %1.3f)\016\016Bar",TXT_2BYTE,TXT2BYTE_AdjustAmbPressure,(float)(pDiveO2Data->pressure/1000000.0), | |
1201 stateRealGetPointer()->lifeData.pressure_surface_bar); | |
1202 | |
1203 write_field_button(StMSYS5_AdjustSurfPres, 30, 800, ME_Y_LINE4, &FontT48, text); | |
1204 } | |
1205 break; | |
1206 } | |
1207 } | |
1208 } | |
1161 | 1209 |
1162 #ifdef ENABLE_ANALYSE_SAMPLES | 1210 #ifdef ENABLE_ANALYSE_SAMPLES |
1163 text[0] = TXT_2BYTE; | 1211 text[0] = TXT_2BYTE; |
1164 text[1] = TXT2BYTE_SetSampleIndex; | 1212 text[1] = TXT2BYTE_SetSampleIndex; |
1165 text[2] = 0; | 1213 text[2] = 0; |
1166 write_field_button(StMSYS5_SetSampleIndx, 30, 800, ME_Y_LINE3, &FontT48, text); | 1214 write_field_button(StMSYS5_SetSampleIndx, 30, 800, ME_Y_LINE4, &FontT48, text); |
1167 #endif | 1215 #endif |
1168 | 1216 |
1169 | 1217 setEvent(StMSYS5_SetFactoryBC, (uint32_t)OnAction_SetFactoryDefaults); |
1170 if(stateRealGetPointer()->lifeData.battery_charge <= 0) | 1218 if(stateRealGetPointer()->lifeData.battery_charge <= 0) |
1171 { | 1219 { |
1172 text[0] = TXT_2BYTE; | 1220 setEvent(StMSYS5_SetBattCharge, (uint32_t)OnAction_SetBatteryCharge); |
1173 text[1] = TXT2BYTE_SetBatteryCharge; | 1221 } |
1174 text[2] = 0; | 1222 if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_DIGITAL)) |
1175 snprintf(&text[2],10,": %u%%",settingsGetPointer()->lastKnownBatteryPercentage); | 1223 { |
1224 if(pDiveO2Data != NULL) | |
1225 { | |
1226 setEvent(StMSYS5_AdjustSurfPres, (uint32_t)OnAction_AdjustSurfacePressure); | |
1227 } | |
1228 } | |
1176 #ifdef ENABLE_ANALYSE_SAMPLES | 1229 #ifdef ENABLE_ANALYSE_SAMPLES |
1177 write_field_button(StMSYS5_SetBattCharge, 30, 800, ME_Y_LINE4, &FontT48, text); | 1230 setEvent(StMSYS5_SetSampleIndx, (uint32_t)OnAction_RecoverSampleIdx); |
1178 #else | |
1179 write_field_button(StMSYS5_SetBattCharge, 30, 800, ME_Y_LINE3, &FontT48, text); | |
1180 #endif | 1231 #endif |
1181 | 1232 |
1182 setEvent(StMSYS5_Exit, (uint32_t)OnAction_Exit); | 1233 |
1183 setEvent(StMSYS5_SetFactoryBC, (uint32_t)OnAction_SetFactoryDefaults); | 1234 text[0] = TXT_2BYTE; |
1184 #ifdef ENABLE_ANALYSE_SAMPLES | 1235 text[1] = TXT2BYTE_WarnBatteryLow; |
1185 setEvent(StMSYS5_SetSampleIndx, (uint32_t)OnAction_RecoverSampleIdx); | 1236 text[2] = 0; |
1186 #endif | 1237 snprintf(&text[2],10,": %01.2fV",stateRealGetPointer()->lifeData.battery_voltage); |
1187 setEvent(StMSYS5_SetBattCharge, (uint32_t)OnAction_SetBatteryCharge); | 1238 write_label_var( 30, 800, ME_Y_LINE5, &FontT42, text); |
1188 } | 1239 |
1189 else | 1240 snprintf(&text[0],30,"Code: %X",getLicence()); |
1190 { | 1241 write_label_var( 30, 800, ME_Y_LINE6, &FontT42, text); |
1191 setEvent(StMSYS5_Exit, (uint32_t)OnAction_Exit); | |
1192 setEvent(StMSYS5_SetFactoryBC, (uint32_t)OnAction_SetFactoryDefaults); | |
1193 #ifdef ENABLE_ANALYSE_SAMPLES | |
1194 setEvent(StMSYS5_SetSampleIndx, (uint32_t)OnAction_RecoverSampleIdx); | |
1195 #endif | |
1196 } | |
1197 // write_field_button(StMSYS5_ScreenTest, 30, 800, ME_Y_LINE3, &FontT48, "Screen Test"); | |
1198 // setEvent(StMSYS5_ScreenTest, (uint32_t)OnAction_ScreenTest); | |
1199 | |
1200 text[0] = TXT_2BYTE; | |
1201 text[1] = TXT2BYTE_WarnBatteryLow; | |
1202 text[2] = 0; | |
1203 snprintf(&text[2],10,": %01.2fV",stateRealGetPointer()->lifeData.battery_voltage); | |
1204 write_label_var( 30, 800, ME_Y_LINE5, &FontT42, text); | |
1205 | |
1206 snprintf(&text[0],30,"Code: %X",getLicence()); | |
1207 write_label_var( 30, 800, ME_Y_LINE6, &FontT42, text); | |
1208 break; | |
1209 | |
1210 } | |
1211 | 1242 |
1212 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | 1243 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); |
1213 } | 1244 } |
1214 | 1245 |
1215 uint8_t OnAction_LogbookOffset(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 1246 uint8_t OnAction_LogbookOffset(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
1261 { | 1292 { |
1262 openEdit_ResetConfirmation(editId); | 1293 openEdit_ResetConfirmation(editId); |
1263 return UNSPECIFIC_RETURN; | 1294 return UNSPECIFIC_RETURN; |
1264 } | 1295 } |
1265 | 1296 |
1297 uint8_t OnAction_Maintenance (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
1298 { | |
1299 openEdit_Maintenance(); | |
1300 return UNSPECIFIC_RETURN; | |
1301 } | |
1302 | |
1266 uint8_t OnAction_RebootRTE (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 1303 uint8_t OnAction_RebootRTE (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
1267 { | 1304 { |
1268 MX_SmallCPU_Reset_To_Standard(); | 1305 MX_SmallCPU_Reset_To_Standard(); |
1269 return EXIT_TO_MENU; | 1306 return EXIT_TO_MENU; |
1270 } | 1307 } |
1332 { | 1369 { |
1333 setBatteryPercentage(settingsGetPointer()->lastKnownBatteryPercentage); | 1370 setBatteryPercentage(settingsGetPointer()->lastKnownBatteryPercentage); |
1334 // setBatteryPercentage(100); | 1371 // setBatteryPercentage(100); |
1335 return EXIT_TO_MENU; | 1372 return EXIT_TO_MENU; |
1336 } | 1373 } |
1374 | |
1375 uint8_t OnAction_AdjustSurfacePressure (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
1376 { | |
1377 SSensorDataDiveO2* pDiveO2Data; | |
1378 const SDiveState* pDiveState = stateRealGetPointer(); | |
1379 SSettings* pSettings = settingsGetPointer(); | |
1380 uint8_t index = 0; | |
1381 int8_t newOffset = 0; | |
1382 | |
1383 char text[32]; | |
1384 | |
1385 float orgpressure_surface; | |
1386 | |
1387 for (index = 0; index < 3; index++) | |
1388 { | |
1389 if(settingsGetPointer()->ext_sensor_map[index] == SENSOR_DIGO2M) | |
1390 { | |
1391 pDiveO2Data = (SSensorDataDiveO2*)stateRealGetPointer()->lifeData.extIf_sensor_data[index]; | |
1392 orgpressure_surface = pDiveState->lifeData.pressure_surface_bar - (settingsGetPointer()->offsetPressure_mbar / 1000.0); | |
1393 newOffset = ((pDiveO2Data->pressure/1000) - (orgpressure_surface * 1000)); | |
1394 | |
1395 if((pDiveState->lifeData.pressure_surface_bar * 1000 + newOffset) != (pDiveO2Data->pressure/1000)) /* there might be a rounding difference => compensate */ | |
1396 { | |
1397 newOffset += (pDiveO2Data->pressure/1000) - (pDiveState->lifeData.pressure_surface_bar * 1000 + newOffset); | |
1398 } | |
1399 | |
1400 pSettings->offsetPressure_mbar = newOffset; | |
1401 snprintf(text,32,"%c%c (%1.3lf => %1.3f)\016\016Bar",TXT_2BYTE,TXT2BYTE_AdjustAmbPressure,(float)(pDiveO2Data->pressure/1000000.0), | |
1402 pDiveState->lifeData.pressure_surface_bar + pSettings->offsetPressure_mbar / 1000.0); | |
1403 tMenuEdit_newButtonText(StMSYS5_AdjustSurfPres,text); | |
1404 break; | |
1405 } | |
1406 } | |
1407 | |
1408 return UNSPECIFIC_RETURN; | |
1409 } | |
1410 | |
1337 | 1411 |
1338 #ifdef SCREENTEST | 1412 #ifdef SCREENTEST |
1339 uint8_t OnAction_ScreenTest (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 1413 uint8_t OnAction_ScreenTest (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
1340 { | 1414 { |
1341 static uint8_t FrameCount = 1; // 0 is invisible frame | 1415 static uint8_t FrameCount = 1; // 0 is invisible frame |