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