Rev 15 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 15 | mjames | 1 | /// |
| 2 | /// Dial drawing library : used to display anything from compass display to arcs of "meter" displays |
||
| 3 | /// |
||
| 4 | mjames | 4 | #pragma once |
| 5 | mjames | 5 | #include <cstdint> |
| 4 | mjames | 6 | |
| 7 | class displayDial_t |
||
| 8 | { |
||
| 9 | public: |
||
| 5 | mjames | 10 | /// \param display the parent display |
| 11 | /// \param x x pos |
||
| 12 | /// \param y y pos |
||
| 13 | /// \param siz = size |
||
| 14 | mjames | 14 | /// \param angle Angle from straight up for lowest (-angle) and highest (angle) reading |
| 15 | displayDial_t(display_t &display, |
||
| 16 | uint8_t x, |
||
| 17 | uint8_t y, |
||
| 18 | uint8_t siz, |
||
| 19 | uint16_t angle = 90); |
||
| 4 | mjames | 20 | |
| 14 | mjames | 21 | /// @brief Construct a display with angle from Angle high to angle low |
| 22 | /// @param display |
||
| 23 | /// @param x |
||
| 24 | /// @param y |
||
| 25 | /// @param siz |
||
| 26 | /// @param angle_high Angle relative to straight up for highest reading |
||
| 27 | /// @param angle_low Angle relative to straight up for lowest reading |
||
| 28 | displayDial_t(display_t &display, |
||
| 29 | uint8_t x, |
||
| 30 | uint8_t y, |
||
| 31 | uint8_t siz, |
||
| 32 | int16_t angle_low, |
||
| 33 | int16_t angle_high); |
||
| 4 | mjames | 34 | |
| 16 | mjames | 35 | /// @brief Put the dial needle on the display |
| 36 | /// @param position values are from 0 .. math.SINE_STEPS |
||
| 14 | mjames | 37 | void draw_needle(int16_t position); |
| 4 | mjames | 38 | |
| 16 | mjames | 39 | /// @brief draw the scale |
| 14 | mjames | 40 | /// \param low low end of range |
| 41 | /// \param high high end of range |
||
| 42 | /// \param width length of long marker |
||
| 43 | /// \param num_step number of ticks |
||
| 44 | /// \param scale |
||
| 45 | void draw_scale(int16_t low, int16_t high, uint8_t width, uint8_t num_step, int16_t scale); |
||
| 4 | mjames | 46 | |
| 16 | mjames | 47 | /// @brief print min/max limits |
| 48 | virtual void draw_limits(){}; |
||
| 14 | mjames | 49 | |
| 16 | mjames | 50 | /// @brief Draw value on display |
| 51 | /// @param val integer value to show with fake decimal point |
||
| 52 | /// @param dp decimal point code |
||
| 53 | virtual void draw_value(int val, int dp){}; |
||
| 54 | |||
| 55 | /// @brief Set units string on display |
||
| 56 | /// @param str Constant string to refer to |
||
| 57 | void set_units(char const *str){m_unitStr = str; }; |
||
| 58 | |||
| 59 | protected: |
||
| 60 | |||
| 61 | void draw_value_items(int val, int dpCode, int wid, int x , int y ); |
||
| 62 | |||
| 63 | |||
| 14 | mjames | 64 | display_t &m_display; |
| 16 | mjames | 65 | uint8_t const m_xo; ///< Position of origin |
| 66 | uint8_t const m_yo; ///< Position of origin |
||
| 67 | uint8_t const m_siz; ///< Display size |
||
| 68 | int16_t const m_angleLow; ///< Angle for lowest value |
||
| 14 | mjames | 69 | int16_t const m_angleRange; ///< Angle range from lowest to highest value |
| 16 | mjames | 70 | int16_t m_low; ///< lower scale limit |
| 71 | int16_t m_high; ///< upper scale limit |
||
| 72 | char const * m_unitStr; ///< Units_string |
||
| 14 | mjames | 73 | }; |
| 16 | mjames | 74 | |
| 75 | ////////////////////////////////////////////////// |
||
| 76 | /// A display using the whole graphics area, 180 degree sweep |
||
| 77 | class displayFullDial_t : public displayDial_t |
||
| 78 | { |
||
| 79 | public: |
||
| 80 | /// @brief Constructor for full-screen display |
||
| 81 | /// @param display The display it is being shown on |
||
| 82 | displayFullDial_t(display_t &display); |
||
| 83 | |||
| 84 | /// @brief draw axes limits |
||
| 85 | virtual void draw_limits() final; |
||
| 86 | |||
| 87 | /// @brief Draw value on display |
||
| 88 | /// @param val integer value to show with fake decimal point |
||
| 89 | /// @param dp decimal point code |
||
| 90 | virtual void draw_value(int val, int dp) final; |
||
| 91 | |||
| 92 | |||
| 93 | }; |
||
| 94 | |||
| 95 | ////////////////////////////////////////////////// |
||
| 96 | /// A display using left hand side of graphics area, 90 degree quadrant |
||
| 97 | class displayLeftQuadrantDial_t : public displayDial_t |
||
| 98 | { |
||
| 99 | public: |
||
| 100 | /// @brief Constructor for left quadrant display |
||
| 101 | /// @param display The display it is being shown on |
||
| 102 | displayLeftQuadrantDial_t(display_t &display); |
||
| 103 | |||
| 104 | /// @brief draw axes limits |
||
| 105 | virtual void draw_limits() final; |
||
| 106 | |||
| 107 | /// @brief Draw value on display |
||
| 108 | /// @param val integer value to show with fake decimal point |
||
| 109 | /// @param dp decimal point code |
||
| 110 | virtual void draw_value(int val, int dp) final; |
||
| 111 | |||
| 112 | |||
| 113 | }; |
||
| 114 | |||
| 115 | ////////////////////////////////////////////////// |
||
| 116 | /// A display using right hand side of graphics area, 90 degree quadrant |
||
| 117 | class displayRightQuadrantDial_t : public displayDial_t |
||
| 118 | { |
||
| 119 | public: |
||
| 120 | /// @brief Constructor for right quadrant display |
||
| 121 | /// @param display The display it is being shown on |
||
| 122 | displayRightQuadrantDial_t(display_t &display); |
||
| 123 | /// @brief draw axes limits |
||
| 124 | virtual void draw_limits() final; |
||
| 125 | |||
| 126 | /// @brief Draw value on display |
||
| 127 | /// @param val integer value to show with fake decimal point |
||
| 128 | /// @param dp decimal point code |
||
| 129 | virtual void draw_value(int val, int dp) final; |
||
| 130 | |||
| 131 | |||
| 132 | }; |