Optimaze with new mbed os for study
Dependencies: TS_DISCO_F746NG BSP_DISCO_F746NG Graphics
RadarDemo/RadarTimer.cpp
- Committer:
- karpent
- Date:
- 2016-11-05
- Revision:
- 3:732f7144ec81
- Child:
- 4:66f13188c26b
File content as of revision 3:732f7144ec81:
#include "RadarTimer.h" #include "Commons.h" RadarTimer::RadarTimer() { } RadarTimer::RadarTimer(uint32_t scanPeriod) { SetScanPeriod(scanPeriod); } void RadarTimer::SetScanPeriod(uint32_t scanPeriod) { _scanPeriod = scanPeriod * 1000; } void RadarTimer::Start() { #ifndef _SDL_timer_h start(); #endif } uint32_t RadarTimer::GetRunningTime() { #ifdef _SDL_timer_h return SDL_GetTicks(); #else return read_ms(); #endif } void RadarTimer::RegisterScan() { // Lock scan time _runningTime = GetRunningTime(); // Reset scan time after one full turn if (_runningTime >= (_lastScanTime + _scanPeriod)) { _lastScanTime = _runningTime; } } float RadarTimer::GetBeamAngle() { float angle = 2 * M_PI * (GetRunningTime() - _lastScanTime) / (float)_scanPeriod; if(angle >= (2 * M_PI)) { angle -= 2 * M_PI; } return angle; }