Mercurial > public > ostc4
comparison Small_CPU/Src/scheduler.c @ 188:ddc21166d25b
Merged in janlmulder/ostc4/cleanup-2 (pull request #5)
Trivial cleanup
author | heinrichsweikamp <bitbucket@heinrichsweikamp.com> |
---|---|
date | Fri, 15 Mar 2019 12:55:58 +0000 |
parents | f11f0bf6ef2d |
children | b95741467355 |
comparison
equal
deleted
inserted
replaced
185:1bb24fd3fc92 | 188:ddc21166d25b |
---|---|
456 * @date 22-April-2014 | 456 * @date 22-April-2014 |
457 ****************************************************************************** | 457 ****************************************************************************** |
458 */ | 458 */ |
459 void scheduleDiveMode(void) | 459 void scheduleDiveMode(void) |
460 { | 460 { |
461 // uint32_t tickstart = 0; | |
462 uint32_t ticksdiff = 0; | 461 uint32_t ticksdiff = 0; |
463 uint32_t lasttick = 0; | 462 uint32_t lasttick = 0; |
464 | 463 |
465 uint32_t turbo_seconds = 0; | |
466 uint8_t counterAscentRate = 0; | 464 uint8_t counterAscentRate = 0; |
467 float lastPressure_bar = 0.0f; | 465 float lastPressure_bar = 0.0f; |
468 global.dataSendToMaster.mode = MODE_DIVE; | 466 global.dataSendToMaster.mode = MODE_DIVE; |
469 global.deviceDataSendToMaster.mode = MODE_DIVE; | 467 global.deviceDataSendToMaster.mode = MODE_DIVE; |
470 //uint16_t counterSecondsShallowDepth = 0; | 468 //uint16_t counterSecondsShallowDepth = 0; |
496 if(ticksdiff >= Scheduler.counterPressure100msec * 100 + 20) | 494 if(ticksdiff >= Scheduler.counterPressure100msec * 100 + 20) |
497 { | 495 { |
498 global.check_sync_not_running++; | 496 global.check_sync_not_running++; |
499 pressure_update(); | 497 pressure_update(); |
500 scheduleUpdateDeviceData(); | 498 scheduleUpdateDeviceData(); |
499 #ifdef DEMOMODE | |
501 if(global.demo_mode) | 500 if(global.demo_mode) |
502 { | 501 { |
503 turbo_seconds = demo_modify_temperature_and_pressure(global.lifeData.dive_time_seconds, Scheduler.counterPressure100msec, global.ceiling_from_main_CPU_mbar); | 502 int turbo_seconds = demo_modify_temperature_and_pressure(global.lifeData.dive_time_seconds, Scheduler.counterPressure100msec, global.ceiling_from_main_CPU_mbar); |
504 if(turbo_seconds) | 503 if(turbo_seconds) |
505 { | 504 { |
506 global.lifeData.dive_time_seconds += turbo_seconds; | 505 global.lifeData.dive_time_seconds += turbo_seconds; |
507 decom_tissues_exposure((int)(turbo_seconds), &global.lifeData); | 506 decom_tissues_exposure((int)(turbo_seconds), &global.lifeData); |
508 copyTissueData(); | 507 copyTissueData(); |
509 } | 508 } |
510 if((global.lifeData.counterSecondsShallowDepth > 1) && (global.lifeData.counterSecondsShallowDepth < (global.settings.timeoutDiveReachedZeroDepth - 10))) | 509 if((global.lifeData.counterSecondsShallowDepth > 1) && (global.lifeData.counterSecondsShallowDepth < (global.settings.timeoutDiveReachedZeroDepth - 10))) |
511 global.lifeData.counterSecondsShallowDepth = (global.settings.timeoutDiveReachedZeroDepth - 10); | 510 global.lifeData.counterSecondsShallowDepth = (global.settings.timeoutDiveReachedZeroDepth - 10); |
512 } | 511 } |
513 | 512 #endif |
514 | 513 |
515 //Calc ascentrate every two second (20 * 100 ms) | 514 //Calc ascentrate every two second (20 * 100 ms) |
516 counterAscentRate++; | 515 counterAscentRate++; |
517 if(counterAscentRate == 20) | 516 if(counterAscentRate == 20) |
518 { | 517 { |
1541 return 0; | 1540 return 0; |
1542 } | 1541 } |
1543 } | 1542 } |
1544 | 1543 |
1545 | 1544 |
1546 //save time diffenrence | 1545 //save time difference |
1547 uint32_t time_elapsed_ms(uint32_t ticksstart,uint32_t ticksnow) | 1546 uint32_t time_elapsed_ms(uint32_t ticksstart,uint32_t ticksnow) |
1548 { | 1547 { |
1549 if(ticksstart <= ticksnow) | 1548 if(ticksstart <= ticksnow) |
1550 { | 1549 { |
1551 return ticksnow - ticksstart; | 1550 return ticksnow - ticksstart; |