Mercurial > public > ostc4
diff 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 |
line wrap: on
line diff
--- a/Small_CPU/Src/scheduler.c Sat Aug 17 18:47:08 2019 +0200 +++ b/Small_CPU/Src/scheduler.c Sat Aug 17 18:57:15 2019 +0200 @@ -43,7 +43,9 @@ #include "tm_stm32f4_otp.h" -#define INVALID_PREASURE_VALUE (100.0F) +#define INVALID_PREASURE_VALUE (100.0f) +#define START_DIVE_MOUNTAIN_MODE_BAR (0.88f) +#define START_DIVE_IMMEDIATLY_BAR (1.16f) /* Private types -------------------------------------------------------------*/ const SGas Air = {79,0,0,0,0}; @@ -279,6 +281,10 @@ /* for simulation / testing */ global.ceiling_from_main_CPU_mbar = global.dataSendToSlave.data.ambient_pressure_mbar_ceiling; + /* Set pressure and temperature offsets */ + pressure_set_offset (global.dataSendToSlave.data.offsetPressureSensor_mbar, global.dataSendToSlave.data.offsetTemperatureSensor_centiDegree); + + /* for device data updates */ deviceDataFlashValid = 0; memcpy(&DeviceDataFlash, &global.dataSendToSlave.data.DeviceData, sizeof(SDevice)); @@ -853,7 +859,7 @@ init_pressure(); if(is_init_pressure_done()) /* Init surface data with initial measurement */ { - init_surface_ring(); + init_surface_ring(0); } if(!battery_gas_gauge_CheckConfigOK()) @@ -1045,9 +1051,11 @@ } } - if (!is_ambient_pressure_close_to_surface(&global.lifeData)) + if (((!is_ambient_pressure_close_to_surface(&global.lifeData)) && (global.lifeData.pressure_surface_bar > START_DIVE_MOUNTAIN_MODE_BAR )) + || (global.lifeData.pressure_ambient_bar > START_DIVE_IMMEDIATLY_BAR)) + { global.mode = MODE_BOOT; - + } scheduleUpdateLifeData(2000); } while(global.mode == MODE_SLEEP); @@ -1583,7 +1591,7 @@ { return true; } - if (lifeData->pressure_ambient_bar > 1.16) + if (lifeData->pressure_ambient_bar > START_DIVE_IMMEDIATLY_BAR) return false; else if(lifeData->pressure_ambient_bar < (lifeData->pressure_surface_bar + 0.1f)) // hw 161121 now 1 mter, before 0.04f return true;