Rev 46 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 46 | Rev 47 | ||
---|---|---|---|
Line 6... | Line 6... | ||
6 | */ |
6 | */ |
7 | #include "stm32l1xx_hal.h" |
7 | #include "stm32l1xx_hal.h" |
8 | #include "ap_math.h" |
8 | #include "ap_math.h" |
9 | #include "font.h" |
9 | #include "font.h" |
10 | #include "SSD1306.h" |
10 | #include "SSD1306.h" |
- | 11 | #include "dials.h" |
|
11 | 12 | ||
- | 13 | // this is the number of degrees between top centre of scale and |
|
- | 14 | // left or right hand end of scale : 90 degrees produces a semicircle. |
|
12 | static uint16_t a1 = 90; |
15 | static uint16_t a1 = 90; |
13 | static uint8_t xo = 64; |
16 | static uint8_t xo = 64; |
14 | static uint8_t yo = 64; |
17 | static uint8_t yo = 64; |
15 | static uint8_t siz = 32; |
18 | static uint8_t siz = 32; |
16 | 19 | ||
17 | /* percent is integer from 0 to 100 */ |
20 | /* position is integer from 0 to SINE_STEPS */ |
18 | void |
21 | void |
19 | dial_draw_needle (uint16_t percent) |
22 | dial_draw_needle (uint16_t position) |
20 | { |
23 | { |
21 | int ang = SINE_SCALING * ((percent - 50) * a1) / 50; |
24 | int ang = SINE_SCALING * ((position - (SINE_STEPS/2)) * a1) / (SINE_STEPS/2); |
22 | 25 | ||
23 | int si = ap_sin (ang); |
26 | int si = ap_sin (ang); |
24 | int co = ap_cos (ang); |
27 | int co = ap_cos (ang); |
25 | 28 | ||
26 | /* calculate a shift for a second side of the needle */ |
29 | /* calculate a shift for a second side of the needle */ |