Optimaze with new mbed os for study
Dependencies: TS_DISCO_F746NG BSP_DISCO_F746NG Graphics
RadarDemo/RadarDemo.h@5:64cafb3c6e7b, 2019-08-23 (annotated)
- Committer:
- ngtkien
- Date:
- Fri Aug 23 16:59:22 2019 +0000
- Revision:
- 5:64cafb3c6e7b
- Parent:
- 4:66f13188c26b
KienNgo optimaze
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:d8b9955d2b36 | 42 | #include "Radar.h" |
karpent | 3:732f7144ec81 | 43 | #include "RadarTimer.h" |
karpent | 4:66f13188c26b | 44 | #include "TouchScreen.h" |
karpent | 4:66f13188c26b | 45 | |
karpent | 4:66f13188c26b | 46 | typedef enum EUserInputType |
karpent | 4:66f13188c26b | 47 | { |
karpent | 4:66f13188c26b | 48 | None = 0, |
karpent | 4:66f13188c26b | 49 | SingleTouch =1, |
karpent | 4:66f13188c26b | 50 | MultiplyTouch = 2, |
karpent | 4:66f13188c26b | 51 | ButtonPressed = 3 |
karpent | 4:66f13188c26b | 52 | } UserInputType; |
karpent | 4:66f13188c26b | 53 | |
karpent | 0:d8b9955d2b36 | 54 | |
karpent | 0:d8b9955d2b36 | 55 | /// <summary> |
karpent | 0:d8b9955d2b36 | 56 | /// Radar display demo class. |
karpent | 0:d8b9955d2b36 | 57 | /// </summary> |
karpent | 1:5e49b46de1b0 | 58 | /// <seealso cref="Radar" /> |
karpent | 0:d8b9955d2b36 | 59 | class RadarDemo : public Radar |
karpent | 0:d8b9955d2b36 | 60 | { |
karpent | 0:d8b9955d2b36 | 61 | public: |
karpent | 0:d8b9955d2b36 | 62 | |
karpent | 0:d8b9955d2b36 | 63 | /// <summary> |
karpent | 0:d8b9955d2b36 | 64 | /// Duration time of the demo in milisecons. |
karpent | 0:d8b9955d2b36 | 65 | /// Set <c>demoTime</c> to 0 if you do not need the time limit. |
karpent | 2:8db224cc1fcb | 66 | /// Set for 0 |
karpent | 0:d8b9955d2b36 | 67 | /// </summary> |
karpent | 0:d8b9955d2b36 | 68 | uint32_t demoTime; |
karpent | 0:d8b9955d2b36 | 69 | |
karpent | 0:d8b9955d2b36 | 70 | /// <summary> |
karpent | 0:d8b9955d2b36 | 71 | /// Class constructor. |
karpent | 0:d8b9955d2b36 | 72 | /// </summary> |
karpent | 0:d8b9955d2b36 | 73 | /// <param name="display">The display.</param> |
karpent | 0:d8b9955d2b36 | 74 | RadarDemo(Display* display); |
karpent | 0:d8b9955d2b36 | 75 | |
karpent | 0:d8b9955d2b36 | 76 | /// <summary> |
karpent | 0:d8b9955d2b36 | 77 | /// Class destructor. |
karpent | 0:d8b9955d2b36 | 78 | /// </summary> |
karpent | 0:d8b9955d2b36 | 79 | ~RadarDemo(); |
karpent | 0:d8b9955d2b36 | 80 | |
karpent | 0:d8b9955d2b36 | 81 | /// <summary> |
karpent | 0:d8b9955d2b36 | 82 | /// Initializes radar demo instance. Generates sample data for the demo. |
karpent | 0:d8b9955d2b36 | 83 | /// </summary> |
karpent | 0:d8b9955d2b36 | 84 | void Initialize(); |
karpent | 0:d8b9955d2b36 | 85 | |
karpent | 0:d8b9955d2b36 | 86 | /// <summary> |
karpent | 0:d8b9955d2b36 | 87 | /// Renders single frame of radar imaging. |
karpent | 0:d8b9955d2b36 | 88 | /// </summary> |
karpent | 0:d8b9955d2b36 | 89 | void Render(); |
karpent | 0:d8b9955d2b36 | 90 | |
karpent | 0:d8b9955d2b36 | 91 | /// <summary> |
karpent | 0:d8b9955d2b36 | 92 | /// Determines whether this instance is running. |
karpent | 0:d8b9955d2b36 | 93 | /// </summary> |
karpent | 0:d8b9955d2b36 | 94 | /// <returns> |
karpent | 0:d8b9955d2b36 | 95 | /// <c>true</c> if this instance is running; otherwise, <c>false</c>. |
karpent | 0:d8b9955d2b36 | 96 | /// </returns> |
karpent | 0:d8b9955d2b36 | 97 | bool IsRunning(); |
karpent | 2:8db224cc1fcb | 98 | |
karpent | 1:5e49b46de1b0 | 99 | /// <summary> |
karpent | 1:5e49b46de1b0 | 100 | /// Check if background needs redraw while range or center location changes. |
karpent | 1:5e49b46de1b0 | 101 | /// </summary> |
karpent | 0:d8b9955d2b36 | 102 | bool NeedsRedraw(); |
karpent | 2:8db224cc1fcb | 103 | |
karpent | 1:5e49b46de1b0 | 104 | /// <summary> |
karpent | 2:8db224cc1fcb | 105 | /// @brief Force background redraw. |
karpent | 1:5e49b46de1b0 | 106 | /// Sets the display state for NEEDS REDRAW. |
karpent | 1:5e49b46de1b0 | 107 | /// </summary> |
karpent | 0:d8b9955d2b36 | 108 | void UnvalidateBackground(); |
karpent | 0:d8b9955d2b36 | 109 | |
karpent | 0:d8b9955d2b36 | 110 | /// <summary> |
karpent | 0:d8b9955d2b36 | 111 | /// Generate sample targets. |
karpent | 0:d8b9955d2b36 | 112 | /// </summary> |
karpent | 0:d8b9955d2b36 | 113 | /// <param name="count">The number of targets to create.</param> |
karpent | 0:d8b9955d2b36 | 114 | void AddSampleTargets(int count); |
karpent | 2:8db224cc1fcb | 115 | |
karpent | 2:8db224cc1fcb | 116 | /// <summary> |
karpent | 4:66f13188c26b | 117 | /// Detect a touch type on the screen in given area. |
karpent | 2:8db224cc1fcb | 118 | /// </summary> |
karpent | 2:8db224cc1fcb | 119 | /// <param name="screen">The screen window coordinates.</param> |
karpent | 4:66f13188c26b | 120 | UserInputType CheckUserInput(Window screen); |
karpent | 3:732f7144ec81 | 121 | |
karpent | 3:732f7144ec81 | 122 | RadarTimer timer; |
karpent | 0:d8b9955d2b36 | 123 | |
karpent | 0:d8b9955d2b36 | 124 | private: |
karpent | 3:732f7144ec81 | 125 | |
karpent | 0:d8b9955d2b36 | 126 | float currentBeamAngle; |
karpent | 0:d8b9955d2b36 | 127 | float lastBeamAngle; |
karpent | 2:8db224cc1fcb | 128 | |
karpent | 0:d8b9955d2b36 | 129 | bool _needsRedraw; |
karpent | 4:66f13188c26b | 130 | |
karpent | 4:66f13188c26b | 131 | TouchScreen* _ts; |
karpent | 4:66f13188c26b | 132 | uint32_t _buttonPressTime; |
karpent | 4:66f13188c26b | 133 | bool TouchScreenDisabled(); |
karpent | 4:66f13188c26b | 134 | void SetTouchScreenTimeout(); |
karpent | 4:66f13188c26b | 135 | |
karpent | 0:d8b9955d2b36 | 136 | }; |
karpent | 0:d8b9955d2b36 | 137 |