Rev 4 | Rev 6 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4 | Rev 5 | ||
|---|---|---|---|
| Line 5... | Line 5... | ||
| 5 | * Author: mike |
5 | * Author: mike |
| 6 | */ |
6 | */ |
| 7 | 7 | ||
| 8 | #include "main.h" |
8 | #include "main.h" |
| 9 | #include "display.h" |
9 | #include "display.h" |
| - | 10 | #include "timing.h" |
|
| 10 | #include <cstring> |
11 | #include <cstring> |
| 11 | #include "libOLED/stm32_halDisplay.H" |
12 | #include "libOLED/stm32_halDisplay.H" |
| 12 | #include "libOLED/fontclass.H" |
13 | #include "libOLED/fontclass.H" |
| 13 | #include "libOLED/displayDial.H" |
14 | #include "libOLED/displayDial.H" |
| 14 | #include "libOLED/displayXY.H" |
15 | #include "libOLED/displayXY.H" |
| Line 23... | Line 24... | ||
| 23 | int const HEIGHT = 64; |
24 | int const HEIGHT = 64; |
| 24 | int const DISPLAY_RAMWIDTH = 132; |
25 | int const DISPLAY_RAMWIDTH = 132; |
| 25 | 26 | ||
| 26 | int x = 500; |
27 | int x = 500; |
| 27 | int y = 20; |
28 | int y = 20; |
| 28 | int ph= 0; |
29 | int ph = 0; |
| - | 30 | ||
| - | 31 | ||
| 29 | } |
32 | } |
| 30 | 33 | ||
| 31 | uint8_t displayBuffer[2][dataSize(WIDTH, HEIGHT)]; |
34 | uint8_t displayBuffer[2][dataSize(WIDTH, HEIGHT)]; |
| 32 | 35 | ||
| 33 | stm32_halDisplay_t displays[MAX_DISPLAYS] = |
36 | stm32_halDisplay_t displays[MAX_DISPLAYS] = |
| Line 39... | Line 42... | ||
| 39 | SPI_RESET_GPIO_Port, |
42 | SPI_RESET_GPIO_Port, |
| 40 | SPI_RESET_Pin, |
43 | SPI_RESET_Pin, |
| 41 | SPI_NSS1_GPIO_Port, |
44 | SPI_NSS1_GPIO_Port, |
| 42 | SPI_NSS1_Pin), |
45 | SPI_NSS1_Pin), |
| 43 | }; |
46 | }; |
| 44 | // display from 0 to 1000 rpm , and 0 to 100kPa |
47 | // display from 0 to 1000 rpm , and 0 to 1000mB |
| 45 | displayXY_t dispXY(displays[0], 500, 6000, 100, 0); |
48 | displayXY_t dispXY(displays[0], 500, 6000, 1000, 0); |
| 46 | 49 | ||
| 47 | // set up sine tables |
50 | // set up sine tables |
| 48 | ap_math m; |
51 | ap_math m; |
| 49 | 52 | ||
| 50 | #if defined __cplusplus |
53 | #if defined __cplusplus |
| Line 78... | Line 81... | ||
| 78 | return -1; |
81 | return -1; |
| 79 | stm32_halDisplay_t &display = displays[dialIndex]; |
82 | stm32_halDisplay_t &display = displays[dialIndex]; |
| 80 | display.clearDisplay(BLACK); |
83 | display.clearDisplay(BLACK); |
| 81 | dispXY.drawAxes(); |
84 | dispXY.drawAxes(); |
| 82 | x += 50; |
85 | x += 50; |
| 83 | y = m.ap_sin((ph+x)/2 )/10 + 50; |
86 | y = m.ap_sin(ph + (x / 20)) + 1000-256; // wobbling about 1000 mB down to about 490mB |
| 84 | 87 | ||
| 85 | if (x > 6000) |
88 | if (x > 6000) |
| 86 | { |
89 | { |
| 87 | ph += 200; |
90 | ph += 200; |
| 88 | if(ph> 360*m.SINE_SCALING) |
91 | if (ph > 360 * m.SINE_SCALING) |
| 89 | ph-=360*m.SINE_SCALING; |
92 | ph -= 360 * m.SINE_SCALING; |
| 90 | 93 | ||
| 91 | x = 500; |
94 | x = 500; |
| 92 | } |
95 | } |
| 93 | display.dim(false); |
96 | display.dim(false); |
| 94 | char buff[10]; |
97 | char buff[10]; |
| 95 | char buff1[10]; |
98 | char buff1[10]; |
| 96 | char buff2[10]; |
99 | char buff2[10]; |
| 97 | small_sprintf(buff1, "x=%4d", x); |
100 | small_sprintf(buff1, "x=%4d", x); |
| 98 | small_sprintf(buff2, "y=%4d", y); |
101 | small_sprintf(buff2, "y=%4d", y); |
| - | 102 | int tim = timing(x,1000-y); |
|
| 99 | small_sprintf(buff, "123\xb0"); |
103 | small_sprintf(buff, "%2d.%1d\xb0",tim/10, tim%10 ); |
| 100 | 104 | ||
| 101 | dispXY.plotPoint(x, y, buff, buff1, buff2); |
105 | dispXY.plotPoint(x, y, buff, buff1, buff2); |
| 102 | display.dim(true); |
106 | display.dim(true); |
| 103 | display.display(); |
107 | display.display(); |
| 104 | 108 | ||