Subversion Repositories libOLED

Rev

Rev 14 | Rev 16 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14 Rev 15
Line 9... Line 9...
9
#include "libOLED/displayclass.H"
9
#include "libOLED/displayclass.H"
10
#include "libOLED/fontclass.H"
10
#include "libOLED/fontclass.H"
11
#include "libOLED/displayDial.H"
11
#include "libOLED/displayDial.H"
12
 
12
 
13
static ap_math math;
13
static ap_math math;
14
// this is the number of degrees between top centre of scale and
-
 
15
// left or right hand end of scale : 90 degrees produces a semicircle.
-
 
16
 
14
 
17
displayDial_t::displayDial_t(display_t &display, uint8_t x, uint8_t y, uint8_t siz, int16_t angle_low, int16_t angle_high) : m_display(display), m_xo(x), m_yo(y), m_siz(siz), m_angleRange(angle_high - angle_low), m_angleLow(angle_low)
15
displayDial_t::displayDial_t(display_t &display, uint8_t x, uint8_t y, uint8_t siz, int16_t angle_low, int16_t angle_high) : m_display(display), m_xo(x), m_yo(y), m_siz(siz), m_angleRange(angle_high - angle_low), m_angleLow(angle_low)
18
{
16
{
19
}
17
}
20
 
18
 
21
displayDial_t::displayDial_t(display_t &display, uint8_t x, uint8_t y, uint8_t siz, uint16_t angle_) : m_display(display), m_xo(x), m_yo(y), m_siz(siz), m_angleRange(2 * angle_), m_angleLow(-angle_)
19
displayDial_t::displayDial_t(display_t &display, uint8_t x, uint8_t y, uint8_t siz, uint16_t angle_) : m_display(display), m_xo(x), m_yo(y), m_siz(siz), m_angleRange(2 * angle_), m_angleLow(-angle_)
22
{
20
{
23
}
-
 
24
 
21
 
25
/* position is integer from 0 to SINE_STEPS */
22
/* position is integer from 0 to SINE_STEPS */
26
void displayDial_t::draw_needle(int16_t position)
23
void displayDial_t::draw_needle(int16_t position)
27
{
24
{
28
  // int ang = math.SINE_SCALING * ((position - (math.SINE_STEPS / 2)) * m_a1) / (math.SINE_STEPS / 2);
25
  // int ang = math.SINE_SCALING * ((position - (math.SINE_STEPS / 2)) * m_a1) / (math.SINE_STEPS / 2);
29
  int ang = (math.SINE_SCALING * position * m_angleRange) / math.SINE_STEPS + m_angleLow * math.SINE_SCALING;
26
  int ang = (math.SINE_SCALING * position * m_angleRange) / math.SINE_STEPS + m_angleLow * math.SINE_SCALING;
30
  int si = math.ap_sin(ang);
27
  int si = math.ap_sin(ang);
31
  int co = math.ap_cos(ang);
28
  int co = math.ap_cos(ang);
32
 
29
 
33
  /* calculate a shift for a second side of the needle */
30
  /* calculate an orthogonal XY shift for a second side of the needle */
34
  int xl = math.ap_sin(ang - math.SINE_STEPS);
31
  int xl = math.ap_sin(ang - math.SINE_STEPS);
35
  int yl = math.ap_cos(ang - math.SINE_STEPS);
32
  int yl = math.ap_cos(ang - math.SINE_STEPS);
36
 
33
 
37
  int si2 = m_siz + 2;
34
  int si2 = m_siz + 2;
38
  int si3 = 2 * m_siz / 3;
35
  int si3 = 2 * m_siz / 3;
Line 98... Line 95...
98
    ang += step;
95
    ang += step;
99
    t += d;
96
    t += d;
100
  }
97
  }
101
}
98
}
102
 
99
 
-
 
100
// this only works for a fullsize display. 
103
void displayDial_t::draw_limits()
101
void displayDial_t::draw_limits()
104
{
102
{
105
  m_display.fontSigDigits(small_font, 0, 56, 0, 10, m_low, WHITE);
103
  m_display.fontSigDigits(small_font, 0, 56, 0, 10, m_low, WHITE);
106
  m_display.fontSigDigits(small_font, 120, 56, 1, 10, m_high, WHITE);
104
  m_display.fontSigDigits(small_font, 120, 56, 1, 10, m_high, WHITE);
107
}
105
}