Rev 4 | Rev 7 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4 | Rev 5 | ||
---|---|---|---|
Line 14... | Line 14... | ||
14 | static ap_math math; |
14 | static ap_math math; |
15 | // this is the number of degrees between top centre of scale and |
15 | // this is the number of degrees between top centre of scale and |
16 | // left or right hand end of scale : 90 degrees produces a semicircle. |
16 | // left or right hand end of scale : 90 degrees produces a semicircle. |
17 | 17 | ||
18 | 18 | ||
19 | displayDial_t::displayDial_t(uint8_t x, uint8_t y, uint8_t siz) : m_xo(x),m_yo(y),m_siz(siz),m_a1(90) |
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_a1(angle_) |
20 | { |
20 | { |
21 | 21 | ||
22 | } |
22 | } |
23 | 23 | ||
24 | /* position is integer from 0 to SINE_STEPS */ |
24 | /* position is integer from 0 to SINE_STEPS */ |
25 | void |
25 | void |
26 | displayDial_t::draw_needle (display_t & display, uint16_t position) |
26 | displayDial_t::draw_needle (int16_t position) |
27 | { |
27 | { |
28 | int ang = math.SINE_SCALING * ((position - (math.SINE_STEPS/2)) * m_a1) / (math.SINE_STEPS/2); |
28 | int ang = math.SINE_SCALING * ((position - (math.SINE_STEPS/2)) * m_a1) / (math.SINE_STEPS/2); |
29 | 29 | ||
30 | int si = math.ap_sin (ang); |
30 | int si = math.ap_sin (ang); |
31 | int co = math.ap_cos (ang); |
31 | int co = math.ap_cos (ang); |
Line 42... | Line 42... | ||
42 | xs = -xl; |
42 | xs = -xl; |
43 | ys = -yl; |
43 | ys = -yl; |
44 | int step; |
44 | int step; |
45 | for(step =0; step < 3; step++) |
45 | for(step =0; step < 3; step++) |
46 | { |
46 | { |
47 | display.drawLine (math.AP_SCALE(si*si2-xs) + m_xo, m_yo - math.AP_SCALE(co * si2 - ys), |
47 | m_display.drawLine (math.AP_SCALE(si*si2-xs) + m_xo, m_yo - math.AP_SCALE(co * si2 - ys), |
48 | 48 | ||
49 | math.AP_SCALE(si*si3-xs) + m_xo,m_yo - math.AP_SCALE(co * si3 - ys), INVERT); |
49 | math.AP_SCALE(si*si3-xs) + m_xo,m_yo - math.AP_SCALE(co * si3 - ys), INVERT); |
50 | xs+=xl; |
50 | xs+=xl; |
51 | ys+=yl; |
51 | ys+=yl; |
52 | } |
52 | } |
53 | } |
53 | } |
54 | 54 | ||
55 | 55 | ||
56 | void displayDial_t::draw_scale (display_t & display, int16_t low, int16_t high, uint8_t width, uint8_t num_step,int16_t scale) |
56 | void displayDial_t::draw_scale ( int16_t low, int16_t high, uint8_t width, uint8_t num_step,int16_t scale) |
57 | { |
57 | { |
58 | int sz; |
58 | |
59 | int ang; |
59 | int ang; |
60 | int sc_low = low/scale; |
60 | int sc_low = low/scale; |
61 | int sc_high = high/scale; |
61 | int sc_high = high/scale; |
62 | int step = 256 * m_a1 * 2 / (4 * (sc_high - sc_low)); |
62 | int step = 256 * m_a1 * 2 / (4 * (sc_high - sc_low)); |
63 | int t; |
63 | int t; |
Line 83... | Line 83... | ||
83 | case -2: |
83 | case -2: |
84 | len = width / 2; |
84 | len = width / 2; |
85 | break; |
85 | break; |
86 | } |
86 | } |
87 | 87 | ||
88 | display.drawLine (math.AP_SCALE((m_siz)*si) + m_xo, m_yo - math.AP_SCALE((m_siz) * co), |
88 | m_display.drawLine (math.AP_SCALE((m_siz)*si) + m_xo, m_yo - math.AP_SCALE((m_siz) * co), |
89 | math.AP_SCALE((m_siz-len)*si) + m_xo, |
89 | math.AP_SCALE((m_siz-len)*si) + m_xo, |
90 | m_yo - math.AP_SCALE((m_siz - len) * co), WHITE); |
90 | m_yo - math.AP_SCALE((m_siz - len) * co), WHITE); |
91 | ang += step; |
91 | ang += step; |
92 | } |
92 | } |
93 | 93 |