Optimaze with new mbed os for study
Dependencies: TS_DISCO_F746NG BSP_DISCO_F746NG Graphics
Diff: RadarDemo/Radar.h
- Revision:
- 2:8db224cc1fcb
- Parent:
- 1:5e49b46de1b0
diff -r 5e49b46de1b0 -r 8db224cc1fcb RadarDemo/Radar.h --- a/RadarDemo/Radar.h Fri Nov 04 17:10:50 2016 +0000 +++ b/RadarDemo/Radar.h Fri Nov 04 23:07:04 2016 +0000 @@ -24,14 +24,17 @@ using namespace std; -static const uint8_t _maxRangeNumber = 1; -static const uint8_t _minRangeNumber = 0; +//static const uint8_t _maxRangeNumber = 1; +//static const uint8_t _minRangeNumber = 0; #define MAX_RANGE_INDEX 2 -static const float _ranges[MAX_RANGE_INDEX + 1] = { 50, 100, 300 }; // km -static const float _rangeMarkersDelta[MAX_RANGE_INDEX + 1] = { 10, 25, 50 }; // km +static const float _ranges[MAX_RANGE_INDEX + 1] = { 50, 100, 300 }; // km +static const float _rangeMarkersDelta[MAX_RANGE_INDEX + 1] = { 10, 25, 50 }; // km static const int azimuthMarkersCount = 8; +/** + * @brief Simple radar simulator + */ class Radar { public: @@ -46,7 +49,7 @@ /// <summary> - /// Updates the targets in sector for the current time. + /// Updates the targets in sector for the current time. /// Returns true if targets found. /// </summary> /// <param name="startAngle">The start angle.</param> @@ -75,14 +78,13 @@ /// Sets current range number. /// </summary> /// <param name="rangeNumber">The range number.</param> - void SetRange(uint8_t rangeNumber) { - if (rangeNumber <= MAX_RANGE_INDEX) { - _rangeNumber = rangeNumber; + void SetRange(uint8_t rangeNumber); - int localRange = (window.y2 - window.y1) / 2; - _scaleRatio = localRange / GetRange(); - } - }; + /// <summary> + /// Increase or decrease range. + /// </summary> + /// <param name="change">1 for increase range, -1 for decrease range</param> + bool ChangeRange(int change); static int GetCenterX() { return _centerX; @@ -97,31 +99,29 @@ _centerY = y; } - void DrawPlot(Location* plot); - - void DrawRadarBeam(float azimuth); - protected: /// <summary> /// Initializes this instance. /// </summary> void Initialize(); + Display* GetDisplay(); + list<Target> targetsList; + + void DrawPlot(Location* plot); + void DrawRadarBeam(float azimuth); void DrawBorder(); void DrawMarkers(); void DrawTarget(Target* target); - -protected: - Display* GetDisplay(); - list<Target> targetsList; - -private: + void DrawRangeButtons(uint16_t raSize); /// <summary> /// Display window in local coordinates system /// </summary> Window window; +private: + /// <summary> /// Center y position in local coordinate system /// </summary> @@ -141,5 +141,5 @@ // Can be canvas, display or SDL renderer Display* _display; - + }; \ No newline at end of file