Optimaze with new mbed os for study

Dependencies:   TS_DISCO_F746NG BSP_DISCO_F746NG Graphics

Committer:
karpent
Date:
Fri Nov 04 17:10:50 2016 +0000
Revision:
1:5e49b46de1b0
Parent:
0:d8b9955d2b36
Child:
2:8db224cc1fcb
Graphics folder published as a library, minor comments update.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
karpent 1:5e49b46de1b0 1 /*
karpent 1:5e49b46de1b0 2 RadarDemo.h - Simple radar simulator demo, example of graphic commands usage to create 2D graphics.
karpent 1:5e49b46de1b0 3
karpent 1:5e49b46de1b0 4 Copyright(c) 2016 karpent at gmail.com, MIT License
karpent 1:5e49b46de1b0 5
karpent 1:5e49b46de1b0 6 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"),
karpent 1:5e49b46de1b0 7 to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
karpent 1:5e49b46de1b0 8 and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
karpent 1:5e49b46de1b0 9
karpent 1:5e49b46de1b0 10 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
karpent 1:5e49b46de1b0 11
karpent 1:5e49b46de1b0 12 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
karpent 1:5e49b46de1b0 13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
karpent 1:5e49b46de1b0 14 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
karpent 1:5e49b46de1b0 15 THE USE OR OTHER DEALINGS IN THE SOFTWARE.
karpent 1:5e49b46de1b0 16 */
karpent 1:5e49b46de1b0 17
karpent 1:5e49b46de1b0 18 /**
karpent 1:5e49b46de1b0 19 * Usage example:
karpent 1:5e49b46de1b0 20 *
karpent 1:5e49b46de1b0 21 @verbatim
karpent 1:5e49b46de1b0 22 #include "RK043FN48H.h"
karpent 1:5e49b46de1b0 23 #include "RadarDemo.h"
karpent 1:5e49b46de1b0 24
karpent 1:5e49b46de1b0 25 RK043FN48H display;
karpent 1:5e49b46de1b0 26
karpent 1:5e49b46de1b0 27 int main()
karpent 1:5e49b46de1b0 28 {
karpent 1:5e49b46de1b0 29 RadarDemo demo(&display);
karpent 1:5e49b46de1b0 30 demo.Initialize();
karpent 1:5e49b46de1b0 31
karpent 1:5e49b46de1b0 32 while(demo.IsRunning()) {
karpent 1:5e49b46de1b0 33 demo.Render();
karpent 1:5e49b46de1b0 34 wait(0.04f);
karpent 1:5e49b46de1b0 35 }
karpent 1:5e49b46de1b0 36 }
karpent 1:5e49b46de1b0 37 @endverbatim
karpent 1:5e49b46de1b0 38 */
karpent 0:d8b9955d2b36 39
karpent 0:d8b9955d2b36 40 #pragma once
karpent 0:d8b9955d2b36 41
karpent 0:d8b9955d2b36 42 #include "Radar.h"
karpent 0:d8b9955d2b36 43
karpent 0:d8b9955d2b36 44 /// <summary>
karpent 0:d8b9955d2b36 45 /// Radar display demo class.
karpent 0:d8b9955d2b36 46 /// </summary>
karpent 1:5e49b46de1b0 47 /// <seealso cref="Radar" />
karpent 0:d8b9955d2b36 48 class RadarDemo : public Radar
karpent 0:d8b9955d2b36 49 {
karpent 0:d8b9955d2b36 50 public:
karpent 0:d8b9955d2b36 51 /// <summary>
karpent 0:d8b9955d2b36 52 /// The radar scan period in milisecons.
karpent 0:d8b9955d2b36 53 /// </summary>
karpent 0:d8b9955d2b36 54 uint32_t scanPeriod;
karpent 0:d8b9955d2b36 55
karpent 0:d8b9955d2b36 56 /// <summary>
karpent 0:d8b9955d2b36 57 /// Duration time of the demo in milisecons.
karpent 0:d8b9955d2b36 58 /// Set <c>demoTime</c> to 0 if you do not need the time limit.
karpent 0:d8b9955d2b36 59 /// Set for 0
karpent 0:d8b9955d2b36 60 /// </summary>
karpent 0:d8b9955d2b36 61 uint32_t demoTime;
karpent 0:d8b9955d2b36 62
karpent 0:d8b9955d2b36 63 /// <summary>
karpent 0:d8b9955d2b36 64 /// Class constructor.
karpent 0:d8b9955d2b36 65 /// </summary>
karpent 0:d8b9955d2b36 66 /// <param name="display">The display.</param>
karpent 0:d8b9955d2b36 67 RadarDemo(Display* display);
karpent 0:d8b9955d2b36 68
karpent 0:d8b9955d2b36 69 /// <summary>
karpent 0:d8b9955d2b36 70 /// Class destructor.
karpent 0:d8b9955d2b36 71 /// </summary>
karpent 0:d8b9955d2b36 72 ~RadarDemo();
karpent 0:d8b9955d2b36 73
karpent 0:d8b9955d2b36 74 /// <summary>
karpent 0:d8b9955d2b36 75 /// Initializes radar demo instance. Generates sample data for the demo.
karpent 0:d8b9955d2b36 76 /// </summary>
karpent 0:d8b9955d2b36 77 void Initialize();
karpent 0:d8b9955d2b36 78
karpent 0:d8b9955d2b36 79 /// <summary>
karpent 0:d8b9955d2b36 80 /// Renders single frame of radar imaging.
karpent 0:d8b9955d2b36 81 /// </summary>
karpent 0:d8b9955d2b36 82 void Render();
karpent 0:d8b9955d2b36 83
karpent 0:d8b9955d2b36 84 /// <summary>
karpent 0:d8b9955d2b36 85 /// Determines whether this instance is running.
karpent 0:d8b9955d2b36 86 /// </summary>
karpent 0:d8b9955d2b36 87 /// <returns>
karpent 0:d8b9955d2b36 88 /// <c>true</c> if this instance is running; otherwise, <c>false</c>.
karpent 0:d8b9955d2b36 89 /// </returns>
karpent 0:d8b9955d2b36 90 bool IsRunning();
karpent 0:d8b9955d2b36 91
karpent 1:5e49b46de1b0 92 /// <summary>
karpent 1:5e49b46de1b0 93 /// Check if background needs redraw while range or center location changes.
karpent 1:5e49b46de1b0 94 /// </summary>
karpent 0:d8b9955d2b36 95 bool NeedsRedraw();
karpent 0:d8b9955d2b36 96
karpent 1:5e49b46de1b0 97 /// <summary>
karpent 1:5e49b46de1b0 98 /// Sets the display state for NEEDS REDRAW.
karpent 1:5e49b46de1b0 99 /// </summary>
karpent 0:d8b9955d2b36 100 void UnvalidateBackground();
karpent 0:d8b9955d2b36 101
karpent 0:d8b9955d2b36 102 /// <summary>
karpent 0:d8b9955d2b36 103 /// Generate sample targets.
karpent 0:d8b9955d2b36 104 /// </summary>
karpent 0:d8b9955d2b36 105 /// <param name="count">The number of targets to create.</param>
karpent 0:d8b9955d2b36 106 void AddSampleTargets(int count);
karpent 0:d8b9955d2b36 107
karpent 0:d8b9955d2b36 108 #ifndef _SDL_timer_h
karpent 0:d8b9955d2b36 109 Timer t;
karpent 0:d8b9955d2b36 110 #endif
karpent 0:d8b9955d2b36 111
karpent 0:d8b9955d2b36 112 private:
karpent 0:d8b9955d2b36 113 uint32_t lastScanTime;
karpent 0:d8b9955d2b36 114 uint32_t runningTime;
karpent 0:d8b9955d2b36 115 float currentBeamAngle;
karpent 0:d8b9955d2b36 116 float lastBeamAngle;
karpent 0:d8b9955d2b36 117
karpent 0:d8b9955d2b36 118 bool _needsRedraw;
karpent 0:d8b9955d2b36 119 };
karpent 0:d8b9955d2b36 120