Example of using "Canvas" form "Graphics" library to display 3D graphics.
Dependencies: BSP_DISCO_F746NG Graphics mbed
HardwareAccess/Angle.h@3:aca7fe2d44b3, 2016-11-11 (annotated)
- Committer:
- karpent
- Date:
- Fri Nov 11 17:06:53 2016 +0000
- Revision:
- 3:aca7fe2d44b3
- Parent:
- 2:ef3093a7a43e
New 3d models added
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
karpent | 0:8acbce46eede | 1 | /* |
karpent | 1:4a5e329e617b | 2 | Angle.h - Calculate rotation angle |
karpent | 0:8acbce46eede | 3 | |
karpent | 1:4a5e329e617b | 4 | Copyright(c) 2016 karpent at gmail.com, MIT License |
karpent | 0:8acbce46eede | 5 | |
karpent | 1:4a5e329e617b | 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:4a5e329e617b | 7 | to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, |
karpent | 1:4a5e329e617b | 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 | 0:8acbce46eede | 9 | |
karpent | 1:4a5e329e617b | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
karpent | 0:8acbce46eede | 11 | |
karpent | 1:4a5e329e617b | 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:4a5e329e617b | 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:4a5e329e617b | 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:4a5e329e617b | 15 | THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
karpent | 0:8acbce46eede | 16 | */ |
karpent | 0:8acbce46eede | 17 | |
karpent | 0:8acbce46eede | 18 | #pragma once |
karpent | 0:8acbce46eede | 19 | |
karpent | 0:8acbce46eede | 20 | typedef enum EAngleDirection { |
karpent | 2:ef3093a7a43e | 21 | DirectionLeft = 0, |
karpent | 2:ef3093a7a43e | 22 | DirectionRight = 1 |
karpent | 0:8acbce46eede | 23 | } AngleDirection; |
karpent | 0:8acbce46eede | 24 | |
karpent | 0:8acbce46eede | 25 | |
karpent | 2:ef3093a7a43e | 26 | typedef enum EAngleType { |
karpent | 2:ef3093a7a43e | 27 | AngleFixed = 0, |
karpent | 2:ef3093a7a43e | 28 | AngleSham = 1, |
karpent | 2:ef3093a7a43e | 29 | AngleReal = 2 |
karpent | 2:ef3093a7a43e | 30 | } AngleType; |
karpent | 2:ef3093a7a43e | 31 | |
karpent | 0:8acbce46eede | 32 | /** |
karpent | 0:8acbce46eede | 33 | * @brief Calculate rotation angle. |
karpent | 1:4a5e329e617b | 34 | * Use method GetAngle() to get simulated rotation angle. |
karpent | 1:4a5e329e617b | 35 | * Use method ReadAngle() if you have additional hadware attached to the board, |
karpent | 1:4a5e329e617b | 36 | * it reads the rotation angle from a potentiometer. |
karpent | 0:8acbce46eede | 37 | */ |
karpent | 0:8acbce46eede | 38 | class Angle |
karpent | 0:8acbce46eede | 39 | { |
karpent | 1:4a5e329e617b | 40 | public: |
karpent | 0:8acbce46eede | 41 | |
karpent | 0:8acbce46eede | 42 | Angle(); |
karpent | 2:ef3093a7a43e | 43 | |
karpent | 2:ef3093a7a43e | 44 | void SetAngle(AngleType type, float initialValue, AngleDirection direction, float delta); |
karpent | 0:8acbce46eede | 45 | |
karpent | 1:4a5e329e617b | 46 | /// <summary> |
karpent | 1:4a5e329e617b | 47 | /// Gets the simulated angle value in degrees. |
karpent | 1:4a5e329e617b | 48 | /// </summary> |
karpent | 1:4a5e329e617b | 49 | /// <returns>Angle value in degrees.</returns> |
karpent | 0:8acbce46eede | 50 | float GetAngle(); |
karpent | 2:ef3093a7a43e | 51 | |
karpent | 2:ef3093a7a43e | 52 | void ChangeDirection() { |
karpent | 2:ef3093a7a43e | 53 | _direction = _direction == DirectionLeft ? DirectionRight : DirectionLeft; |
karpent | 2:ef3093a7a43e | 54 | }; |
karpent | 2:ef3093a7a43e | 55 | |
karpent | 2:ef3093a7a43e | 56 | protected: |
karpent | 0:8acbce46eede | 57 | |
karpent | 1:4a5e329e617b | 58 | /// <summary> |
karpent | 1:4a5e329e617b | 59 | /// Reads the rotation angle from a potentiometer attached to pin A0 |
karpent | 1:4a5e329e617b | 60 | /// </summary> |
karpent | 1:4a5e329e617b | 61 | /// <returns>Angle value in degrees.</returns> |
karpent | 0:8acbce46eede | 62 | float ReadAngle(); |
karpent | 2:ef3093a7a43e | 63 | |
karpent | 2:ef3093a7a43e | 64 | private: |
karpent | 0:8acbce46eede | 65 | |
karpent | 2:ef3093a7a43e | 66 | AngleDirection _direction; |
karpent | 2:ef3093a7a43e | 67 | |
karpent | 2:ef3093a7a43e | 68 | AngleType _type; |
karpent | 2:ef3093a7a43e | 69 | |
karpent | 1:4a5e329e617b | 70 | /// <summary> |
karpent | 2:ef3093a7a43e | 71 | /// Actual rotation angle value in degrees, range: 0 - 360 |
karpent | 1:4a5e329e617b | 72 | /// </summary> |
karpent | 2:ef3093a7a43e | 73 | float _angle; |
karpent | 0:8acbce46eede | 74 | |
karpent | 1:4a5e329e617b | 75 | float _delta; |
karpent | 0:8acbce46eede | 76 | }; |