# HG changeset patch # User Jan Mulder # Date 1558339527 -7200 # Node ID a09b1855d656154de7f72cc08445ce1e6ba8b302 # Parent 5ca177d2df5dcb83652ac1286f81a76efa427684 cleanup, RTE: factor out scheduleCheck_pressure_reached_dive_mode_level The detection of the start of dive mode is conceptually simple (when the pressure sensor reaches a certain threshold, we are diving). This said, there are multiple implementations over the entire code base to answer the question: are we diving? This commit factors out scheduleCheck_pressure_reached_dive_mode_level used only in the RTE, in favor of is_ambient_pressure_close_to_surface, which is used in both RTE and CPU1 firmware. I had a little hope that is would fix the 1 second difference between the initial stopwatch and the divetime, but it does not. Signed-off-by: Jan Mulder diff -r 5ca177d2df5d -r a09b1855d656 Small_CPU/Src/scheduler.c --- a/Small_CPU/Src/scheduler.c Fri May 17 21:19:04 2019 +0200 +++ b/Small_CPU/Src/scheduler.c Mon May 20 10:05:27 2019 +0200 @@ -85,7 +85,6 @@ static void schedule_update_timer_helper(int8_t thisSeconds); uint32_t time_elapsed_ms(uint32_t ticksstart,uint32_t ticksnow); -_Bool scheduleCheck_pressure_reached_dive_mode_level(void); void scheduleSetDate(SDeviceLine *line); /* Exported functions --------------------------------------------------------*/ @@ -771,7 +770,7 @@ copyPressureData(); Scheduler.counterPressure100msec++; - if(scheduleCheck_pressure_reached_dive_mode_level()) + if (!is_ambient_pressure_close_to_surface(&global.lifeData)) global.mode = MODE_DIVE; } @@ -1029,7 +1028,7 @@ } } - if(scheduleCheck_pressure_reached_dive_mode_level()) + if (!is_ambient_pressure_close_to_surface(&global.lifeData)) global.mode = MODE_BOOT; scheduleUpdateLifeData(2000); @@ -1046,27 +1045,6 @@ /* Private functions ---------------------------------------------------------*/ - -/** - ****************************************************************************** - * @brief scheduleCheck_pressure_reached_dive_mode_level - * @author heinrichs weikamp gmbh - * @version V0.0.1 from inline code - * @date 09-Sept-2015 - ****************************************************************************** - */ -_Bool scheduleCheck_pressure_reached_dive_mode_level(void) -{ - if(get_pressure_mbar() > 1160) - return 1; - else - if((global.mode == MODE_SURFACE) && (get_pressure_mbar() > (get_surface_mbar() + 100)) && (get_surface_mbar() > 880)) - return 1; - else - return 0; -} - - /** ****************************************************************************** * @brief scheduleUpdateLifeData / calculates tissues