Rev 5 | Rev 13 | 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 |
||
75 | cc_display(uint8_t dialIndex, uint8_t intensity) |
||
76 | { |
||
77 | |||
78 | if (dialIndex < 0 && dialIndex > MAX_DISPLAYS) |
||
79 | return -1; |
||
80 | stm32_halDisplay_t &display = displays[dialIndex]; |
||
81 | display.clearDisplay(BLACK); |
||
82 | |||
83 | display.dim(intensity == 2 ? 255 : 0); |
||
84 | |||
85 | if (intensity > 0) |
||
86 | { |
||
87 | |||
88 | dispXY.drawAxes(); |
||
11 | mjames | 89 | |
2 | mjames | 90 | char buff1[10]; |
11 | mjames | 91 | char buff2[20]; |
2 | mjames | 92 | char buff[10]; |
93 | |||
94 | small_sprintf(buff, "%2d.%01d", timing / 10, timing % 10); |
||
95 | |||
96 | small_sprintf(buff1, "%4ld.%02ld mb", press / 100, press % 100); |
||
97 | |||
11 | mjames | 98 | small_sprintf(buff2, "%2ldC %4d rpm", temp / 100, rpm); |
2 | mjames | 99 | |
11 | mjames | 100 | dispXY.plotPoint(rpm, press / 100, buff, buff1, buff2); |
101 | } |
||
2 | mjames | 102 | display.display(); |
103 | |||
104 | return 0; |
||
105 | } |
||
106 | |||
107 | void cc_feed_env(uint32_t pressVal, int32_t tempVal) |
||
108 | { |
||
109 | press = pressVal; |
||
110 | temp = tempVal; |
||
111 | } |
||
112 | |||
113 | void cc_feed_timing(int timing_) |
||
114 | { |
||
115 | timing = timing_; |
||
116 | } |
||
117 | |||
118 | void cc_feed_rpm(int rpm_) |
||
119 | { |
||
120 | rpm = rpm_; |
||
121 | } |
||
122 | #if defined __cplusplus |
||
123 | } |
||
124 | #endif |