Rev 11 | Rev 14 | 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 | uint32_t press; // pressure millibar * 100 |
||
28 | int32_t temp; // temperature * 10 |
||
11 | mjames | 29 | int rpm; // user pressed button |
2 | mjames | 30 | |
31 | int timing; // timing value . |
||
32 | } |
||
33 | |||
34 | uint8_t displayBuffer[MAX_DISPLAYS][dataSize(WIDTH, HEIGHT)]; |
||
35 | |||
36 | stm32_halDisplay_t displays[MAX_DISPLAYS] = |
||
37 | { |
||
38 | stm32_halDisplay_t(WIDTH, HEIGHT, DISPLAY_RAMWIDTH, displayBuffer[0], |
||
39 | &hspi1, |
||
40 | SPI1_CD_GPIO_Port, |
||
41 | SPI1_CD_Pin, |
||
42 | SPI1_RESET_GPIO_Port, |
||
43 | SPI1_RESET_Pin, |
||
44 | SPI1_NSS_GPIO_Port, |
||
45 | SPI1_NSS_Pin), |
||
46 | }; |
||
47 | // display from 0 to 1000 rpm , and 0 to 1000mB |
||
48 | displayXY_t dispXY(displays[0], 500, 6000, 1050, 0); |
||
49 | |||
50 | // set up sine tables |
||
51 | ap_math m; |
||
52 | |||
53 | #if defined __cplusplus |
||
54 | extern "C" |
||
55 | { |
||
56 | #endif |
||
57 | |||
58 | void |
||
59 | cc_init() |
||
60 | { |
||
61 | for (auto i = 0; i < MAX_DISPLAYS; i++) |
||
62 | { |
||
63 | display_t &display = displays[i]; |
||
64 | if (i == 0) |
||
65 | display.reset(); |
||
66 | display.init(); |
||
67 | display.clearDisplay(BLACK); |
||
68 | display.gotoxy(8, 32); |
||
5 | mjames | 69 | display.printString(large_font, "mikeJ", 5, BLACK); |
2 | mjames | 70 | display.display(); |
71 | } |
||
72 | } |
||
73 | |||
74 | int |
||
13 | mjames | 75 | cc_display(uint8_t dialIndex, uint8_t intensity, uint8_t do_reset) |
2 | mjames | 76 | { |
77 | |||
78 | if (dialIndex < 0 && dialIndex > MAX_DISPLAYS) |
||
79 | return -1; |
||
80 | stm32_halDisplay_t &display = displays[dialIndex]; |
||
13 | mjames | 81 | if(do_reset) |
82 | { |
||
83 | |||
84 | display.reset(); |
||
85 | display.init(); |
||
86 | } |
||
87 | |||
88 | |||
2 | mjames | 89 | display.clearDisplay(BLACK); |
90 | |||
91 | display.dim(intensity == 2 ? 255 : 0); |
||
92 | |||
93 | if (intensity > 0) |
||
94 | { |
||
95 | |||
96 | dispXY.drawAxes(); |
||
11 | mjames | 97 | |
2 | mjames | 98 | char buff1[10]; |
11 | mjames | 99 | char buff2[20]; |
2 | mjames | 100 | char buff[10]; |
101 | |||
102 | small_sprintf(buff, "%2d.%01d", timing / 10, timing % 10); |
||
103 | |||
104 | small_sprintf(buff1, "%4ld.%02ld mb", press / 100, press % 100); |
||
105 | |||
11 | mjames | 106 | small_sprintf(buff2, "%2ldC %4d rpm", temp / 100, rpm); |
2 | mjames | 107 | |
11 | mjames | 108 | dispXY.plotPoint(rpm, press / 100, buff, buff1, buff2); |
109 | } |
||
2 | mjames | 110 | display.display(); |
111 | |||
112 | return 0; |
||
113 | } |
||
114 | |||
115 | void cc_feed_env(uint32_t pressVal, int32_t tempVal) |
||
116 | { |
||
117 | press = pressVal; |
||
118 | temp = tempVal; |
||
119 | } |
||
120 | |||
121 | void cc_feed_timing(int timing_) |
||
122 | { |
||
123 | timing = timing_; |
||
124 | } |
||
125 | |||
126 | void cc_feed_rpm(int rpm_) |
||
127 | { |
||
128 | rpm = rpm_; |
||
129 | } |
||
130 | #if defined __cplusplus |
||
131 | } |
||
132 | #endif |