comparison 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
comparison
equal deleted inserted replaced
229:2c0b502b0a72 230:3973208c4a20
80 void copyPressureData(void); 80 void copyPressureData(void);
81 void copyCnsAndOtuData(void); 81 void copyCnsAndOtuData(void);
82 void copyTimeData(void); 82 void copyTimeData(void);
83 void copyCompassData(void); 83 void copyCompassData(void);
84 void copyCompassDataDuringCalibration(int16_t dx, int16_t dy, int16_t dz); 84 void copyCompassDataDuringCalibration(int16_t dx, int16_t dy, int16_t dz);
85 //void copyBatteryData(void); now in header
86 void copyAmbientLightData(void); 85 void copyAmbientLightData(void);
87 void copyTissueData(void); 86 void copyTissueData(void);
88 void copyVpmCrushingData(void); 87 void copyVpmCrushingData(void);
89 void copyDeviceData(void); 88 void copyDeviceData(void);
90 void copyPICdata(void); 89 void copyPICdata(void);
91 uint16_t schedule_update_timer_helper(int8_t thisSeconds); 90 static void schedule_update_timer_helper(int8_t thisSeconds);
92
93
94 uint32_t time_elapsed_ms(uint32_t ticksstart,uint32_t ticksnow); 91 uint32_t time_elapsed_ms(uint32_t ticksstart,uint32_t ticksnow);
95 92
96 _Bool scheduleCheck_pressure_reached_dive_mode_level(void); 93 _Bool scheduleCheck_pressure_reached_dive_mode_level(void);
97 void scheduleSetDate(SDeviceLine *line); 94 void scheduleSetDate(SDeviceLine *line);
98 95
314 inStupidTime -= multiplesOf16 * 16; 311 inStupidTime -= multiplesOf16 * 16;
315 312
316 return (10 * multiplesOf16) + inStupidTime; 313 return (10 * multiplesOf16) + inStupidTime;
317 } 314 }
318 315
319
320 uint32_t minCounterDebug = 0;
321
322 uint32_t schedule_time_compare_helper(RTC_TimeTypeDef timeNow, RTC_DateTypeDef dateNow, RTC_TimeTypeDef timeLast, RTC_DateTypeDef dateLast) 316 uint32_t schedule_time_compare_helper(RTC_TimeTypeDef timeNow, RTC_DateTypeDef dateNow, RTC_TimeTypeDef timeLast, RTC_DateTypeDef dateLast)
323 { 317 {
324 uint32_t nowInSeconds; 318 uint32_t nowInSeconds;
325 uint32_t lastInSeconds; 319 uint32_t lastInSeconds;
326 uint32_t resultDiff; 320 uint32_t resultDiff;
327
328 if(timeNow.Minutes != timeLast.Minutes)
329 minCounterDebug++;
330 321
331 nowInSeconds = (uint32_t)RtcBugFixChsw(timeNow.Hours) * 3600; 322 nowInSeconds = (uint32_t)RtcBugFixChsw(timeNow.Hours) * 3600;
332 nowInSeconds += (uint32_t)RtcBugFixChsw(timeNow.Minutes) * 60; 323 nowInSeconds += (uint32_t)RtcBugFixChsw(timeNow.Minutes) * 60;
333 nowInSeconds += (uint32_t)RtcBugFixChsw(timeNow.Seconds); 324 nowInSeconds += (uint32_t)RtcBugFixChsw(timeNow.Seconds);
334 325
335 lastInSeconds = (uint32_t)RtcBugFixChsw(timeLast.Hours) * 3600; 326 lastInSeconds = (uint32_t)RtcBugFixChsw(timeLast.Hours) * 3600;
336 lastInSeconds += (uint32_t)RtcBugFixChsw(timeLast.Minutes) * 60; 327 lastInSeconds += (uint32_t)RtcBugFixChsw(timeLast.Minutes) * 60;
337 lastInSeconds += (uint32_t)RtcBugFixChsw(timeLast.Seconds); 328 lastInSeconds += (uint32_t)RtcBugFixChsw(timeLast.Seconds);
338
339 /*
340 nowInSeconds = (uint32_t)timeNow.Hours * 3600;
341 nowInSeconds += (uint32_t)timeNow.Minutes * 60;
342 nowInSeconds += (uint32_t)timeNow.Seconds;
343
344 lastInSeconds = (uint32_t)timeLast.Hours * 3600;
345 lastInSeconds += (uint32_t)timeLast.Minutes * 60;
346 lastInSeconds += (uint32_t)timeLast.Seconds;
347 */
348 329
349 if(dateNow.Date != dateLast.Date) 330 if(dateNow.Date != dateLast.Date)
350 { 331 {
351 resultDiff = 86400 + nowInSeconds - lastInSeconds; 332 resultDiff = 86400 + nowInSeconds - lastInSeconds;
352 } 333 }
370 use >= 1 for manual control 351 use >= 1 for manual control
371 ****************************************************************************** 352 ******************************************************************************
372 */ 353 */
373 extern RTC_HandleTypeDef RTCHandle; 354 extern RTC_HandleTypeDef RTCHandle;
374 355
375 uint16_t schedule_update_timer_helper(int8_t thisSeconds) 356 static void schedule_update_timer_helper(int8_t thisSeconds)
376 { 357 {
377 static RTC_TimeTypeDef sTimeLast; 358 static RTC_TimeTypeDef sTimeLast;
378 static RTC_DateTypeDef sDateLast; 359 static RTC_DateTypeDef sDateLast;
379 RTC_TimeTypeDef sTimeNow; 360 RTC_TimeTypeDef sTimeNow;
380 RTC_DateTypeDef sDateNow; 361 RTC_DateTypeDef sDateNow;
381 uint32_t secondsPast; 362 uint32_t secondsPast;
382 uint32_t tempNewValue = 0;
383 363
384 HAL_RTC_GetTime(&RTCHandle, &sTimeNow, RTC_FORMAT_BCD); 364 HAL_RTC_GetTime(&RTCHandle, &sTimeNow, RTC_FORMAT_BCD);
385 HAL_RTC_GetDate(&RTCHandle, &sDateNow, RTC_FORMAT_BCD); 365 HAL_RTC_GetDate(&RTCHandle, &sDateNow, RTC_FORMAT_BCD);
386 366
387 if(thisSeconds != 0) // otherwise just store sTimeLast, sDateLast and return 0 367 if(thisSeconds != 0) // otherwise just store sTimeLast, sDateLast
388 { 368 {
389 secondsPast = schedule_time_compare_helper(sTimeNow, sDateNow, sTimeLast, sDateLast);
390
391 if(thisSeconds > 0) // use this value instead, good for pre-loading sTimeLast and sDateLast 369 if(thisSeconds > 0) // use this value instead, good for pre-loading sTimeLast and sDateLast
392 { 370 {
393 secondsPast = thisSeconds; 371 secondsPast = thisSeconds;
372 } else {
373 // thisSeconds < 0 and not <= !
374 secondsPast = schedule_time_compare_helper(sTimeNow, sDateNow, sTimeLast, sDateLast);
394 } 375 }
395 376
396 if(global.seconds_since_last_dive) 377 if(global.seconds_since_last_dive)
397 { 378 {
398 if(secondsPast >= 777900) 379 if(secondsPast >= 777900)
399 { 380 {
400 global.seconds_since_last_dive = 0; 381 global.seconds_since_last_dive = 0;
401 } 382 }
402 else 383 else
403 { 384 {
404 tempNewValue = ((uint32_t)global.seconds_since_last_dive) + secondsPast; 385 uint32_t tempNewValue = ((uint32_t)global.seconds_since_last_dive) + secondsPast;
405 if(tempNewValue > 777900) // a bit more than nine days [seconds] 386 if(tempNewValue > 777900) // a bit more than nine days [seconds]
406 global.seconds_since_last_dive = 0; 387 global.seconds_since_last_dive = 0;
407 else 388 else
408 global.seconds_since_last_dive = (long)tempNewValue; 389 global.seconds_since_last_dive = (long)tempNewValue;
409 } 390 }
410 } 391 }
411 } 392 }
412 393
413 sTimeLast = sTimeNow; 394 sTimeLast = sTimeNow;
414 sDateLast = sDateNow; 395 sDateLast = sDateNow;
415 396 }
416 return tempNewValue;
417 }
418
419
420
421 397
422 /** 398 /**
423 ****************************************************************************** 399 ******************************************************************************
424 * @brief schedule_check_resync. 400 * @brief schedule_check_resync.
425 * @author heinrichs weikamp gmbh 401 * @author heinrichs weikamp gmbh
825 } 801 }
826 802
827 if(global.seconds_since_last_dive) 803 if(global.seconds_since_last_dive)
828 { 804 {
829 schedule_update_timer_helper(-1); 805 schedule_update_timer_helper(-1);
830 // global.seconds_since_last_dive++;
831 // if(global.seconds_since_last_dive > 777900) // a bit more than nine days [seconds]
832 // global.seconds_since_last_dive = 0;
833 } 806 }
834 807
835 if(global.accidentRemainingSeconds) 808 if(global.accidentRemainingSeconds)
836 { 809 {
837 global.accidentRemainingSeconds--; 810 global.accidentRemainingSeconds--;
944 compass_init(0,7); // back to normal mode 917 compass_init(0,7); // back to normal mode
945 918
946 if(global.seconds_since_last_dive) 919 if(global.seconds_since_last_dive)
947 { 920 {
948 schedule_update_timer_helper(-1); 921 schedule_update_timer_helper(-1);
949 // global.seconds_since_last_dive += 60;
950 // if(global.seconds_since_last_dive > 777900) // a bit more than nine days [seconds]
951 // global.seconds_since_last_dive = 0;
952 } 922 }
953 923
954 scheduleUpdateLifeData(0); 924 scheduleUpdateLifeData(0);
955 global.mode = MODE_SURFACE; 925 global.mode = MODE_SURFACE;
956 } 926 }
1011 update_surface_pressure(2); 981 update_surface_pressure(2);
1012 982
1013 if(global.seconds_since_last_dive) 983 if(global.seconds_since_last_dive)
1014 { 984 {
1015 schedule_update_timer_helper(-1); 985 schedule_update_timer_helper(-1);
1016 // global.seconds_since_last_dive += 2;
1017 // if(global.seconds_since_last_dive > 777900) // a bit more than nine days [seconds]
1018 // global.seconds_since_last_dive = 0;
1019 } 986 }
1020 987
1021 if(global.accidentRemainingSeconds) 988 if(global.accidentRemainingSeconds)
1022 { 989 {
1023 if(global.accidentRemainingSeconds > 2) 990 if(global.accidentRemainingSeconds > 2)