comparison Small_CPU/Src/scheduler.c @ 338:b6a59e93cc91 PressureMeasure_Improvment

Added function to avoid divemode activation during Landing: Divemode is activated in case of 100mBar difference surface to abiente pressure. This might happen during landing => Added (in sleep mode only) a check for this scenario and increased dive mode activation limit
author ideenmodellierer
date Sat, 17 Aug 2019 18:57:15 +0200
parents b4c578caaafb
children 73325a78c907
comparison
equal deleted inserted replaced
337:38367bb982b8 338:b6a59e93cc91
41 #include "stm32f4xx_hal_rtc_ex.h" 41 #include "stm32f4xx_hal_rtc_ex.h"
42 #include "decom.h" 42 #include "decom.h"
43 #include "tm_stm32f4_otp.h" 43 #include "tm_stm32f4_otp.h"
44 44
45 45
46 #define INVALID_PREASURE_VALUE (100.0F) 46 #define INVALID_PREASURE_VALUE (100.0f)
47 #define START_DIVE_MOUNTAIN_MODE_BAR (0.88f)
48 #define START_DIVE_IMMEDIATLY_BAR (1.16f)
47 49
48 /* Private types -------------------------------------------------------------*/ 50 /* Private types -------------------------------------------------------------*/
49 const SGas Air = {79,0,0,0,0}; 51 const SGas Air = {79,0,0,0,0};
50 52
51 /* Exported variables --------------------------------------------------------*/ 53 /* Exported variables --------------------------------------------------------*/
277 } 279 }
278 280
279 /* for simulation / testing */ 281 /* for simulation / testing */
280 global.ceiling_from_main_CPU_mbar = global.dataSendToSlave.data.ambient_pressure_mbar_ceiling; 282 global.ceiling_from_main_CPU_mbar = global.dataSendToSlave.data.ambient_pressure_mbar_ceiling;
281 283
284 /* Set pressure and temperature offsets */
285 pressure_set_offset (global.dataSendToSlave.data.offsetPressureSensor_mbar, global.dataSendToSlave.data.offsetTemperatureSensor_centiDegree);
286
287
282 /* for device data updates */ 288 /* for device data updates */
283 deviceDataFlashValid = 0; 289 deviceDataFlashValid = 0;
284 memcpy(&DeviceDataFlash, &global.dataSendToSlave.data.DeviceData, sizeof(SDevice)); 290 memcpy(&DeviceDataFlash, &global.dataSendToSlave.data.DeviceData, sizeof(SDevice));
285 deviceDataFlashValid = 1; 291 deviceDataFlashValid = 1;
286 292
851 if(global.I2C_SystemStatus == HAL_OK) 857 if(global.I2C_SystemStatus == HAL_OK)
852 { 858 {
853 init_pressure(); 859 init_pressure();
854 if(is_init_pressure_done()) /* Init surface data with initial measurement */ 860 if(is_init_pressure_done()) /* Init surface data with initial measurement */
855 { 861 {
856 init_surface_ring(); 862 init_surface_ring(0);
857 } 863 }
858 864
859 if(!battery_gas_gauge_CheckConfigOK()) 865 if(!battery_gas_gauge_CheckConfigOK())
860 { 866 {
861 init_battery_gas_gauge(); 867 init_battery_gas_gauge();
1043 global.accidentRemainingSeconds = 0; 1049 global.accidentRemainingSeconds = 0;
1044 global.accidentFlag = 0; 1050 global.accidentFlag = 0;
1045 } 1051 }
1046 } 1052 }
1047 1053
1048 if (!is_ambient_pressure_close_to_surface(&global.lifeData)) 1054 if (((!is_ambient_pressure_close_to_surface(&global.lifeData)) && (global.lifeData.pressure_surface_bar > START_DIVE_MOUNTAIN_MODE_BAR ))
1055 || (global.lifeData.pressure_ambient_bar > START_DIVE_IMMEDIATLY_BAR))
1056 {
1049 global.mode = MODE_BOOT; 1057 global.mode = MODE_BOOT;
1050 1058 }
1051 scheduleUpdateLifeData(2000); 1059 scheduleUpdateLifeData(2000);
1052 } 1060 }
1053 while(global.mode == MODE_SLEEP); 1061 while(global.mode == MODE_SLEEP);
1054 /* new section for system after Standby */ 1062 /* new section for system after Standby */
1055 scheduleUpdateLifeData(-1); 1063 scheduleUpdateLifeData(-1);
1581 { 1589 {
1582 if(lifeData->pressure_ambient_bar == INVALID_PREASURE_VALUE) /* as long as no valid data is available expect we are close to surface */ 1590 if(lifeData->pressure_ambient_bar == INVALID_PREASURE_VALUE) /* as long as no valid data is available expect we are close to surface */
1583 { 1591 {
1584 return true; 1592 return true;
1585 } 1593 }
1586 if (lifeData->pressure_ambient_bar > 1.16) 1594 if (lifeData->pressure_ambient_bar > START_DIVE_IMMEDIATLY_BAR)
1587 return false; 1595 return false;
1588 else if(lifeData->pressure_ambient_bar < (lifeData->pressure_surface_bar + 0.1f)) // hw 161121 now 1 mter, before 0.04f 1596 else if(lifeData->pressure_ambient_bar < (lifeData->pressure_surface_bar + 0.1f)) // hw 161121 now 1 mter, before 0.04f
1589 return true; 1597 return true;
1590 else 1598 else
1591 return false; 1599 return false;