Subversion Repositories libOLED

Rev

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