Optimaze with new mbed os for study

Dependencies:   TS_DISCO_F746NG BSP_DISCO_F746NG Graphics

Committer:
karpent
Date:
Sat Nov 05 15:36:59 2016 +0000
Revision:
3:732f7144ec81
Parent:
2:8db224cc1fcb
Child:
4:66f13188c26b
RadarTimer class added

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 2:8db224cc1fcb 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 2:8db224cc1fcb 42 #include "TS_DISCO_F746NG.h"
karpent 0:d8b9955d2b36 43 #include "Radar.h"
karpent 3:732f7144ec81 44 #include "RadarTimer.h"
karpent 0:d8b9955d2b36 45
karpent 0:d8b9955d2b36 46 /// <summary>
karpent 0:d8b9955d2b36 47 /// Radar display demo class.
karpent 0:d8b9955d2b36 48 /// </summary>
karpent 1:5e49b46de1b0 49 /// <seealso cref="Radar" />
karpent 0:d8b9955d2b36 50 class RadarDemo : public Radar
karpent 0:d8b9955d2b36 51 {
karpent 0:d8b9955d2b36 52 public:
karpent 0:d8b9955d2b36 53
karpent 0:d8b9955d2b36 54 /// <summary>
karpent 0:d8b9955d2b36 55 /// Duration time of the demo in milisecons.
karpent 0:d8b9955d2b36 56 /// Set <c>demoTime</c> to 0 if you do not need the time limit.
karpent 2:8db224cc1fcb 57 /// Set for 0
karpent 0:d8b9955d2b36 58 /// </summary>
karpent 0:d8b9955d2b36 59 uint32_t demoTime;
karpent 0:d8b9955d2b36 60
karpent 0:d8b9955d2b36 61 /// <summary>
karpent 0:d8b9955d2b36 62 /// Class constructor.
karpent 0:d8b9955d2b36 63 /// </summary>
karpent 0:d8b9955d2b36 64 /// <param name="display">The display.</param>
karpent 0:d8b9955d2b36 65 RadarDemo(Display* display);
karpent 0:d8b9955d2b36 66
karpent 0:d8b9955d2b36 67 /// <summary>
karpent 0:d8b9955d2b36 68 /// Class destructor.
karpent 0:d8b9955d2b36 69 /// </summary>
karpent 0:d8b9955d2b36 70 ~RadarDemo();
karpent 0:d8b9955d2b36 71
karpent 0:d8b9955d2b36 72 /// <summary>
karpent 0:d8b9955d2b36 73 /// Initializes radar demo instance. Generates sample data for the demo.
karpent 0:d8b9955d2b36 74 /// </summary>
karpent 0:d8b9955d2b36 75 void Initialize();
karpent 0:d8b9955d2b36 76
karpent 0:d8b9955d2b36 77 /// <summary>
karpent 0:d8b9955d2b36 78 /// Renders single frame of radar imaging.
karpent 0:d8b9955d2b36 79 /// </summary>
karpent 0:d8b9955d2b36 80 void Render();
karpent 0:d8b9955d2b36 81
karpent 0:d8b9955d2b36 82 /// <summary>
karpent 0:d8b9955d2b36 83 /// Determines whether this instance is running.
karpent 0:d8b9955d2b36 84 /// </summary>
karpent 0:d8b9955d2b36 85 /// <returns>
karpent 0:d8b9955d2b36 86 /// <c>true</c> if this instance is running; otherwise, <c>false</c>.
karpent 0:d8b9955d2b36 87 /// </returns>
karpent 0:d8b9955d2b36 88 bool IsRunning();
karpent 2:8db224cc1fcb 89
karpent 1:5e49b46de1b0 90 /// <summary>
karpent 1:5e49b46de1b0 91 /// Check if background needs redraw while range or center location changes.
karpent 1:5e49b46de1b0 92 /// </summary>
karpent 0:d8b9955d2b36 93 bool NeedsRedraw();
karpent 2:8db224cc1fcb 94
karpent 1:5e49b46de1b0 95 /// <summary>
karpent 2:8db224cc1fcb 96 /// @brief Force background redraw.
karpent 1:5e49b46de1b0 97 /// Sets the display state for NEEDS REDRAW.
karpent 1:5e49b46de1b0 98 /// </summary>
karpent 0:d8b9955d2b36 99 void UnvalidateBackground();
karpent 0:d8b9955d2b36 100
karpent 0:d8b9955d2b36 101 /// <summary>
karpent 0:d8b9955d2b36 102 /// Generate sample targets.
karpent 0:d8b9955d2b36 103 /// </summary>
karpent 0:d8b9955d2b36 104 /// <param name="count">The number of targets to create.</param>
karpent 0:d8b9955d2b36 105 void AddSampleTargets(int count);
karpent 2:8db224cc1fcb 106
karpent 2:8db224cc1fcb 107 /// <summary>
karpent 2:8db224cc1fcb 108 /// Detect a touch on the screen in given area.
karpent 2:8db224cc1fcb 109 /// Returns true if the touch has been detected.
karpent 2:8db224cc1fcb 110 /// </summary>
karpent 2:8db224cc1fcb 111 /// <param name="screen">The screen window coordinates.</param>
karpent 2:8db224cc1fcb 112 bool DetectTouch(Window screen);
karpent 3:732f7144ec81 113
karpent 3:732f7144ec81 114 RadarTimer timer;
karpent 0:d8b9955d2b36 115
karpent 0:d8b9955d2b36 116 private:
karpent 3:732f7144ec81 117
karpent 0:d8b9955d2b36 118 float currentBeamAngle;
karpent 0:d8b9955d2b36 119 float lastBeamAngle;
karpent 2:8db224cc1fcb 120
karpent 0:d8b9955d2b36 121 bool _needsRedraw;
karpent 2:8db224cc1fcb 122
karpent 2:8db224cc1fcb 123 TS_DISCO_F746NG ts;
karpent 0:d8b9955d2b36 124 };
karpent 0:d8b9955d2b36 125