Optimaze with new mbed os for study
Dependencies: TS_DISCO_F746NG BSP_DISCO_F746NG Graphics
Diff: RadarDemo/RadarTimer.cpp
- Revision:
- 4:66f13188c26b
- Parent:
- 3:732f7144ec81
diff -r 732f7144ec81 -r 66f13188c26b RadarDemo/RadarTimer.cpp --- a/RadarDemo/RadarTimer.cpp Sat Nov 05 15:36:59 2016 +0000 +++ b/RadarDemo/RadarTimer.cpp Sat Nov 05 20:24:59 2016 +0000 @@ -1,14 +1,21 @@ +// +// RadarTimer.cpp - Radar time subsystem simulator. +// + #include "RadarTimer.h" #include "Commons.h" RadarTimer::RadarTimer() { - + // Set 10seconds as default value for scan period; + _scanPeriod = 10000; + _lastScanTime = 0; } RadarTimer::RadarTimer(uint32_t scanPeriod) { SetScanPeriod(scanPeriod); + _lastScanTime = 0; } @@ -20,10 +27,12 @@ void RadarTimer::Start() { #ifndef _SDL_timer_h - start(); + start(); #endif + _lastScanTime = GetRunningTime(); } + uint32_t RadarTimer::GetRunningTime() { #ifdef _SDL_timer_h @@ -36,9 +45,9 @@ void RadarTimer::RegisterScan() { - // Lock scan time + // Lock scan time _runningTime = GetRunningTime(); - + // Reset scan time after one full turn if (_runningTime >= (_lastScanTime + _scanPeriod)) { _lastScanTime = _runningTime; @@ -52,6 +61,6 @@ if(angle >= (2 * M_PI)) { angle -= 2 * M_PI; } - + return angle; } \ No newline at end of file