Rev 3 | Rev 11 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | /* |
2 | * display.cpp |
||
3 | * |
||
4 | * Created on: 30 Nov 2020 |
||
5 | * Author: mike |
||
6 | */ |
||
7 | |||
8 | #include "main.h" |
||
9 | #include "display.h" |
||
10 | #include "libIgnTiming/timing.h" |
||
11 | #include <cstring> |
||
12 | #include "libOLED/stm32_halDisplay.H" |
||
13 | #include "libOLED/fontclass.H" |
||
14 | #include "libOLED/displayDial.H" |
||
15 | #include "libOLED/displayXY.H" |
||
16 | #include "libPlx/displayInfo.H" |
||
17 | #include "libOLED/ap_math.h" |
||
18 | #include "libSmallPrintf/small_printf.h" |
||
19 | #include "splash.H" |
||
20 | |||
21 | namespace |
||
22 | { |
||
23 | int const WIDTH = 128; |
||
24 | int const HEIGHT = 64; |
||
25 | int const DISPLAY_RAMWIDTH = 132; |
||
26 | |||
27 | |||
28 | uint32_t press; // pressure millibar * 100 |
||
29 | int32_t temp; // temperature * 10 |
||
30 | int rpm; // user pressed button |
||
31 | |||
32 | int timing; // timing value . |
||
33 | } |
||
34 | |||
35 | uint8_t displayBuffer[MAX_DISPLAYS][dataSize(WIDTH, HEIGHT)]; |
||
36 | |||
37 | stm32_halDisplay_t displays[MAX_DISPLAYS] = |
||
38 | { |
||
39 | stm32_halDisplay_t(WIDTH, HEIGHT, DISPLAY_RAMWIDTH, displayBuffer[0], |
||
40 | &hspi1, |
||
41 | SPI1_CD_GPIO_Port, |
||
42 | SPI1_CD_Pin, |
||
43 | SPI1_RESET_GPIO_Port, |
||
44 | SPI1_RESET_Pin, |
||
45 | SPI1_NSS_GPIO_Port, |
||
46 | SPI1_NSS_Pin), |
||
47 | }; |
||
48 | // display from 0 to 1000 rpm , and 0 to 1000mB |
||
49 | displayXY_t dispXY(displays[0], 500, 6000, 1050, 0); |
||
50 | |||
51 | // set up sine tables |
||
52 | ap_math m; |
||
53 | |||
54 | #if defined __cplusplus |
||
55 | extern "C" |
||
56 | { |
||
57 | #endif |
||
58 | |||
59 | void |
||
60 | cc_init() |
||
61 | { |
||
62 | for (auto i = 0; i < MAX_DISPLAYS; i++) |
||
63 | { |
||
64 | display_t &display = displays[i]; |
||
65 | if (i == 0) |
||
66 | display.reset(); |
||
67 | display.init(); |
||
68 | display.clearDisplay(BLACK); |
||
69 | display.gotoxy(8, 32); |
||
5 | mjames | 70 | display.printString(large_font, "mikeJ", 5, BLACK); |
2 | mjames | 71 | display.display(); |
72 | } |
||
73 | } |
||
74 | |||
75 | int |
||
76 | cc_display(uint8_t dialIndex, uint8_t intensity) |
||
77 | { |
||
78 | |||
79 | if (dialIndex < 0 && dialIndex > MAX_DISPLAYS) |
||
80 | return -1; |
||
81 | stm32_halDisplay_t &display = displays[dialIndex]; |
||
82 | display.clearDisplay(BLACK); |
||
83 | |||
84 | display.dim(intensity == 2 ? 255 : 0); |
||
85 | |||
86 | if (intensity > 0) |
||
87 | { |
||
88 | |||
89 | dispXY.drawAxes(); |
||
90 | |||
91 | char buff1[10]; |
||
92 | char buff2[10]; |
||
93 | char buff[10]; |
||
94 | |||
95 | small_sprintf(buff, "%2d.%01d", timing / 10, timing % 10); |
||
96 | |||
97 | small_sprintf(buff1, "%4ld.%02ld mb", press / 100, press % 100); |
||
98 | |||
99 | small_sprintf(buff2, "%4d rpm", rpm); |
||
100 | |||
101 | dispXY.plotPoint(rpm, press/100, buff, buff1, buff2); |
||
102 | } |
||
103 | display.display(); |
||
104 | |||
105 | return 0; |
||
106 | } |
||
107 | |||
108 | void cc_feed_env(uint32_t pressVal, int32_t tempVal) |
||
109 | { |
||
110 | press = pressVal; |
||
111 | temp = tempVal; |
||
112 | } |
||
113 | |||
114 | void cc_feed_timing(int timing_) |
||
115 | { |
||
116 | timing = timing_; |
||
117 | } |
||
118 | |||
119 | void cc_feed_rpm(int rpm_) |
||
120 | { |
||
121 | rpm = rpm_; |
||
122 | } |
||
123 | #if defined __cplusplus |
||
124 | } |
||
125 | #endif |