Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_DISCO_F746NG Graphics mbed TS_DISCO_F746NG
RadarTimer.cpp
00001 // 00002 // RadarTimer.cpp - Radar time subsystem simulator. 00003 // 00004 00005 #include "RadarTimer.h" 00006 #include "Commons.h" 00007 00008 RadarTimer::RadarTimer() 00009 { 00010 // Set 10seconds as default value for scan period; 00011 _scanPeriod = 10000; 00012 _lastScanTime = 0; 00013 } 00014 00015 RadarTimer::RadarTimer(uint32_t scanPeriod) 00016 { 00017 SetScanPeriod(scanPeriod); 00018 _lastScanTime = 0; 00019 } 00020 00021 00022 void RadarTimer::SetScanPeriod(uint32_t scanPeriod) 00023 { 00024 _scanPeriod = scanPeriod * 1000; 00025 } 00026 00027 void RadarTimer::Start() 00028 { 00029 #ifndef _SDL_timer_h 00030 start(); 00031 #endif 00032 _lastScanTime = GetRunningTime(); 00033 } 00034 00035 00036 uint32_t RadarTimer::GetRunningTime() 00037 { 00038 #ifdef _SDL_timer_h 00039 return SDL_GetTicks(); 00040 #else 00041 return read_ms(); 00042 #endif 00043 } 00044 00045 00046 void RadarTimer::RegisterScan() 00047 { 00048 // Lock scan time 00049 _runningTime = GetRunningTime(); 00050 00051 // Reset scan time after one full turn 00052 if (_runningTime >= (_lastScanTime + _scanPeriod)) { 00053 _lastScanTime = _runningTime; 00054 } 00055 } 00056 00057 00058 float RadarTimer::GetBeamAngle() 00059 { 00060 float angle = 2 * M_PI * (GetRunningTime() - _lastScanTime) / (float)_scanPeriod; 00061 if(angle >= (2 * M_PI)) { 00062 angle -= 2 * M_PI; 00063 } 00064 00065 return angle; 00066 }
Generated on Wed Jul 13 2022 08:01:03 by
