Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6 | mjames | 1 | #include "main.h" |
9 | mjames | 2 | #include "nmea.h" |
3 | #include <cstring> |
||
6 | mjames | 4 | #include "libOLED/stm32_halDisplay.H" |
7 | mjames | 5 | #include "libOLED/fontclass.H" |
8 | mjames | 6 | #include "libOLED/displayDial.H" |
7 | mjames | 7 | |
11 | mjames | 8 | #include "libBMP280/bmp280.h" |
9 | |||
6 | mjames | 10 | namespace |
11 | { |
||
12 | int const WIDTH = 128; |
||
13 | int const HEIGHT = 64; |
||
14 | int const DISPLAY_RAMWIDTH = 132; |
||
15 | |||
16 | } |
||
17 | |||
10 | mjames | 18 | float speedMPH = 0.0; |
19 | float speedAVG = 0.0; |
||
9 | mjames | 20 | int heading = 0; |
21 | Location loc; |
||
22 | |||
11 | mjames | 23 | uint32_t lastTick = 0; |
24 | int32_t temp32 = 0; |
||
25 | uint32_t pres32 = 0; |
||
26 | int32_t rslt; |
||
27 | |||
6 | mjames | 28 | uint8_t displayBuffer[dataSize (WIDTH, HEIGHT)]; |
29 | |||
30 | stm32_halDisplay_t display1 (WIDTH, HEIGHT, DISPLAY_RAMWIDTH, displayBuffer, |
||
31 | &hspi1, |
||
32 | |||
33 | SPI_CD_GPIO_Port, |
||
34 | SPI_CD_Pin, |
||
35 | SPI_RESET_GPIO_Port, |
||
36 | SPI_RESET_Pin, |
||
37 | SPI_NSS1_GPIO_Port, |
||
38 | SPI_NSS1_Pin); |
||
39 | |||
9 | mjames | 40 | displayDial_t dial (display1, 96, 32, 32, 180); |
8 | mjames | 41 | |
6 | mjames | 42 | extern "C" void |
43 | cc_init () |
||
44 | { |
||
11 | mjames | 45 | display1.reset (); |
46 | |||
9 | mjames | 47 | display1.init (); |
6 | mjames | 48 | display1.clearDisplay (); |
49 | |||
9 | mjames | 50 | dial.draw_scale (0, 360, 8, 1, 45); |
6 | mjames | 51 | |
52 | display1.display (); |
||
9 | mjames | 53 | |
10 | mjames | 54 | memset (loc.time, '-', 6); |
6 | mjames | 55 | } |
56 | |||
9 | mjames | 57 | char fontBuf[] = "01234567"; |
6 | mjames | 58 | extern "C" void |
11 | mjames | 59 | cc_run (struct bmp280_dev *bmp) |
60 | |||
6 | mjames | 61 | { |
7 | mjames | 62 | |
9 | mjames | 63 | display1.clearDisplay (); |
64 | dial.draw_scale (0, 360, 8, 1, 45); |
||
8 | mjames | 65 | |
9 | mjames | 66 | bool stat = updateLocation (&loc); |
67 | if (loc.good) |
||
68 | { |
||
69 | heading = loc.heading; |
||
8 | mjames | 70 | |
9 | mjames | 71 | loc.good = false; |
11 | mjames | 72 | } |
73 | if (loc.valid == 'V') |
||
74 | memset (loc.time, '-', 6); |
||
9 | mjames | 75 | |
11 | mjames | 76 | // print out the GMT time at the top of the screen |
77 | display1.gotoxy (0, 0); |
||
78 | display1.printString (small_font, &loc.time[0], 2, WHITE); |
||
79 | display1.printString (small_font, ":", 1, WHITE); |
||
80 | display1.printString (small_font, &loc.time[2], 2, WHITE); |
||
9 | mjames | 81 | |
11 | mjames | 82 | display1.printString (small_font, ":", 1, WHITE); |
83 | display1.printString (small_font, &loc.time[4], 2, WHITE); |
||
84 | int dial_ang = heading + 180; |
||
85 | dial.draw_needle (dial_ang); |
||
9 | mjames | 86 | |
11 | mjames | 87 | display1.gotoxy (70, 25); |
88 | if (loc.valid == 'A') |
||
89 | { |
||
90 | display1.fontDigits (large_font, 3, -1, heading); |
||
91 | } |
||
92 | else |
||
93 | display1.printString (large_font, "GPS?", 4, WHITE); |
||
9 | mjames | 94 | |
11 | mjames | 95 | if (loc.valid == 'A') |
96 | speedMPH = loc.speed / 1.815; |
||
9 | mjames | 97 | |
11 | mjames | 98 | display1.gotoxy (0, 8); |
99 | display1.printString (small_font, "Speed", 5, WHITE); |
||
100 | display1.gotoxy (0, 16); |
||
101 | display1.fontDigits (large_font, 4, 1, speedMPH * 10); |
||
9 | mjames | 102 | |
11 | mjames | 103 | display1.gotoxy (0, 32); |
104 | display1.printString (small_font, "Average", 7, WHITE); |
||
105 | display1.gotoxy (0, 40); |
||
106 | display1.fontDigits (large_font, 4, 1, speedAVG * 10); |
||
9 | mjames | 107 | |
11 | mjames | 108 | struct bmp280_uncomp_data ucomp_data; |
9 | mjames | 109 | |
11 | mjames | 110 | if (HAL_GetTick () - lastTick > 1000) |
111 | { |
||
112 | lastTick = HAL_GetTick (); |
||
113 | /* Reading the raw data from sensor */ |
||
114 | rslt = bmp280_get_uncomp_data (&ucomp_data, bmp); |
||
10 | mjames | 115 | |
11 | mjames | 116 | if (rslt == BMP280_OK) |
117 | { |
||
118 | /* Getting the 32 bit compensated temperature */ |
||
119 | rslt = bmp280_get_comp_temp_32bit (&temp32, ucomp_data.uncomp_temp, |
||
120 | bmp); |
||
10 | mjames | 121 | |
11 | mjames | 122 | rslt = bmp280_get_comp_pres_32bit (&pres32, ucomp_data.uncomp_press, |
123 | bmp); |
||
10 | mjames | 124 | |
11 | mjames | 125 | } |
126 | } |
||
127 | display1.gotoxy (0, 56); |
||
128 | display1.printString (small_font, "T", 2, WHITE); |
||
129 | display1.fontDigits (small_font, 4, 1, temp32/10, WHITE); |
||
130 | display1.printString (small_font, " P", 2, WHITE); |
||
131 | display1.fontDigits (small_font, 5, 0, pres32/100, WHITE); |
||
132 | display1.printString (small_font, " ", 1, WHITE); |
||
10 | mjames | 133 | |
11 | mjames | 134 | display1.display (); |
135 | |||
6 | mjames | 136 | } |