diff Small_CPU/Src/scheduler.c @ 230:3973208c4a20 div-fixes-4-1

cleanup: make return void when never used The schedule_update_timer_helper() function returned a value that is never used. In fact, its only called with constants -1 and 0, so there is still some unused functionality here. In all: trivial cleanup. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Wed, 03 Apr 2019 14:16:59 +0200
parents e524a824d8f2
children f6961efb3794
line wrap: on
line diff
--- a/Small_CPU/Src/scheduler.c	Tue Apr 02 15:11:42 2019 +0200
+++ b/Small_CPU/Src/scheduler.c	Wed Apr 03 14:16:59 2019 +0200
@@ -82,15 +82,12 @@
 void copyTimeData(void);
 void copyCompassData(void);
 void copyCompassDataDuringCalibration(int16_t dx, int16_t dy, int16_t dz);
-//void copyBatteryData(void); now in header
 void copyAmbientLightData(void);
 void copyTissueData(void);
 void copyVpmCrushingData(void);
 void copyDeviceData(void);
 void copyPICdata(void);
-uint16_t schedule_update_timer_helper(int8_t thisSeconds);
-
-
+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);
@@ -316,17 +313,11 @@
 	return (10 * multiplesOf16) + inStupidTime;
 }
 
-
-uint32_t minCounterDebug = 0;
-
 uint32_t schedule_time_compare_helper(RTC_TimeTypeDef timeNow, RTC_DateTypeDef dateNow, RTC_TimeTypeDef timeLast, RTC_DateTypeDef dateLast)
 {
 	uint32_t nowInSeconds;
 	uint32_t lastInSeconds;
 	uint32_t resultDiff;
-	
-	if(timeNow.Minutes != timeLast.Minutes)
-		minCounterDebug++;
 
 	nowInSeconds  = (uint32_t)RtcBugFixChsw(timeNow.Hours) * 3600;
 	nowInSeconds += (uint32_t)RtcBugFixChsw(timeNow.Minutes) * 60;
@@ -335,16 +326,6 @@
 	lastInSeconds  = (uint32_t)RtcBugFixChsw(timeLast.Hours) * 3600;
 	lastInSeconds += (uint32_t)RtcBugFixChsw(timeLast.Minutes) * 60;
 	lastInSeconds += (uint32_t)RtcBugFixChsw(timeLast.Seconds);
-
-/*
-		nowInSeconds  = (uint32_t)timeNow.Hours * 3600;
-	nowInSeconds += (uint32_t)timeNow.Minutes * 60;
-	nowInSeconds += (uint32_t)timeNow.Seconds;
-
-	lastInSeconds  = (uint32_t)timeLast.Hours * 3600;
-	lastInSeconds += (uint32_t)timeLast.Minutes * 60;
-	lastInSeconds += (uint32_t)timeLast.Seconds;
-*/
 	
 	if(dateNow.Date != dateLast.Date)
 	{
@@ -372,25 +353,25 @@
   */
 extern RTC_HandleTypeDef RTCHandle;
 
-uint16_t schedule_update_timer_helper(int8_t thisSeconds)
+static void schedule_update_timer_helper(int8_t thisSeconds)
 {
 	static RTC_TimeTypeDef sTimeLast;
 	static RTC_DateTypeDef sDateLast;
 	RTC_TimeTypeDef sTimeNow;
 	RTC_DateTypeDef sDateNow;
 	uint32_t secondsPast;
-	uint32_t tempNewValue = 0;
 
 	HAL_RTC_GetTime(&RTCHandle, &sTimeNow, RTC_FORMAT_BCD);
 	HAL_RTC_GetDate(&RTCHandle, &sDateNow, RTC_FORMAT_BCD);
 
-	if(thisSeconds != 0) // otherwise just store sTimeLast, sDateLast and return 0
+	if(thisSeconds != 0) // otherwise just store sTimeLast, sDateLast
 	{
-		secondsPast = schedule_time_compare_helper(sTimeNow, sDateNow, sTimeLast, sDateLast);
-
 		if(thisSeconds > 0) // use this value instead, good for pre-loading sTimeLast and sDateLast
 		{
 			secondsPast	= thisSeconds;
+		} else {
+			// thisSeconds < 0 and not <= !
+			secondsPast = schedule_time_compare_helper(sTimeNow, sDateNow, sTimeLast, sDateLast);
 		}
 
 		if(global.seconds_since_last_dive)
@@ -401,7 +382,7 @@
 			}
 			else
 			{
-				tempNewValue = ((uint32_t)global.seconds_since_last_dive) + secondsPast;
+				uint32_t tempNewValue = ((uint32_t)global.seconds_since_last_dive) + secondsPast;
 				if(tempNewValue > 777900) // a bit more than nine days [seconds]
 					global.seconds_since_last_dive = 0;
 				else
@@ -412,13 +393,8 @@
 		
 	sTimeLast = sTimeNow;
 	sDateLast = sDateNow;
-	
-	return tempNewValue;
 }
 
-
-
-
 /**
   ******************************************************************************
 * @brief   schedule_check_resync. 
@@ -827,9 +803,6 @@
 			if(global.seconds_since_last_dive)
 			{
 				schedule_update_timer_helper(-1);
-//				global.seconds_since_last_dive++;
-//				if(global.seconds_since_last_dive > 777900) // a bit more than nine days [seconds]
-//					global.seconds_since_last_dive = 0;
 			}
 
 			if(global.accidentRemainingSeconds)
@@ -946,9 +919,6 @@
 	if(global.seconds_since_last_dive)
 	{
 				schedule_update_timer_helper(-1);
-//		global.seconds_since_last_dive += 60;
-//				if(global.seconds_since_last_dive > 777900) // a bit more than nine days [seconds]
-//					global.seconds_since_last_dive = 0;
 	}
 
 	scheduleUpdateLifeData(0);
@@ -1013,9 +983,6 @@
 		if(global.seconds_since_last_dive)
 		{
 			schedule_update_timer_helper(-1);
-//			global.seconds_since_last_dive += 2;
-//				if(global.seconds_since_last_dive > 777900) // a bit more than nine days [seconds]
-//					global.seconds_since_last_dive = 0;
 		}
 
 		if(global.accidentRemainingSeconds)