Rev 13 | Rev 16 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 13 | Rev 15 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | #include "main.h" |
1 | #include "main.h" |
| 2 | #include "nmea.h" |
2 | #include "libNMEA/nmea.h" |
| 3 | #include <cstring> |
3 | #include <cstring> |
| 4 | #include "libOLED/stm32_halDisplay.H" |
4 | #include "libOLED/stm32_halDisplay.H" |
| 5 | #include "libOLED/fontclass.H" |
5 | #include "libOLED/fontclass.H" |
| 6 | #include "libOLED/displayDial.H" |
6 | #include "libOLED/displayDial.H" |
| 7 | 7 | ||
| 8 | #include "libBMP280/bmp280.h" |
8 | #include "libBMP280/bmp280.h" |
| 9 | 9 | ||
| 10 | #include "libSmallPrintf/small_printf.h" |
10 | #include "libSmallPrintf/small_printf.h" |
| - | 11 | ||
| - | 12 | #if defined USB_DEVICE |
|
| 11 | #include "usbd_cdc_if.h" |
13 | #include "usbd_cdc_if.h" |
| - | 14 | #endif |
|
| 12 | 15 | ||
| 13 | namespace |
16 | namespace |
| 14 | { |
17 | { |
| 15 | int const WIDTH = 128; |
18 | int const WIDTH = 128; |
| 16 | int const HEIGHT = 64; |
19 | int const HEIGHT = 64; |
| Line 18... | Line 21... | ||
| 18 | 21 | ||
| 19 | } |
22 | } |
| 20 | 23 | ||
| 21 | float speedMPH = 0.0; |
24 | float speedMPH = 0.0; |
| 22 | float speedAVG = 0.0; |
25 | float speedAVG = 0.0; |
| - | 26 | int speedTimer = 0; |
|
| - | 27 | float speedDist = 0.0; |
|
| - | 28 | ||
| - | 29 | ||
| 23 | int heading = 0; |
30 | int heading = 0; |
| 24 | Location loc; |
31 | Location loc; |
| 25 | 32 | ||
| 26 | uint32_t lastTick = 0; |
33 | uint32_t lastTick = 0; |
| 27 | int32_t temp32 = 0; |
34 | int32_t temp32 = 0; |
| Line 64... | Line 71... | ||
| 64 | { |
71 | { |
| 65 | 72 | ||
| 66 | display1.clearDisplay (); |
73 | display1.clearDisplay (); |
| 67 | dial.draw_scale (0, 360, 8, 1, 45); |
74 | dial.draw_scale (0, 360, 8, 1, 45); |
| 68 | 75 | ||
| 69 | bool stat = updateLocation (&loc); |
76 | bool stat = updateLocation (&loc, &uc1); |
| 70 | if (loc.good) |
77 | if (loc.good) |
| 71 | { |
78 | { |
| 72 | heading = loc.heading; |
79 | heading = loc.heading; |
| 73 | 80 | ||
| 74 | loc.good = false; |
81 | loc.good = false; |
| 75 | } |
82 | } |
| 76 | if (loc.valid == 'V') |
83 | if (loc.valid == 'V') |
| 77 | memset (loc.time, '-', 6); |
84 | memset (loc.time, '-', 6); |
| 78 | 85 | ||
| - | 86 | ||
| - | 87 | ||
| 79 | // print out the GMT time at the top of the screen |
88 | // print out the GMT time at the top of the screen |
| 80 | display1.gotoxy (0, 0); |
89 | display1.gotoxy (0, 0); |
| 81 | display1.printString (small_font, &loc.time[0], 2, WHITE); |
90 | display1.printString (small_font, &loc.time[0], 2, WHITE); |
| 82 | display1.printString (small_font, ":", 1, WHITE); |
91 | display1.printString (small_font, ":", 1, WHITE); |
| 83 | display1.printString (small_font, &loc.time[2], 2, WHITE); |
92 | display1.printString (small_font, &loc.time[2], 2, WHITE); |
| Line 108... | Line 117... | ||
| 108 | display1.gotoxy (0, 40); |
117 | display1.gotoxy (0, 40); |
| 109 | display1.fontDigits (large_font, 4, 1, speedAVG * 10); |
118 | display1.fontDigits (large_font, 4, 1, speedAVG * 10); |
| 110 | 119 | ||
| 111 | struct bmp280_uncomp_data ucomp_data; |
120 | struct bmp280_uncomp_data ucomp_data; |
| 112 | 121 | ||
| 113 | if (HAL_GetTick () - lastTick > 1000) |
122 | if (HAL_GetTick () - lastTick > 5000) |
| 114 | { |
123 | { |
| 115 | lastTick = HAL_GetTick (); |
124 | lastTick = HAL_GetTick (); |
| 116 | /* Reading the raw data from sensor */ |
125 | /* Reading the raw data from sensor */ |
| 117 | rslt = bmp280_get_uncomp_data (&ucomp_data, bmp); |
126 | rslt = bmp280_get_uncomp_data (&ucomp_data, bmp); |
| 118 | 127 | ||
| Line 123... | Line 132... | ||
| 123 | bmp); |
132 | bmp); |
| 124 | 133 | ||
| 125 | rslt = bmp280_get_comp_pres_32bit (&pres32, ucomp_data.uncomp_press, |
134 | rslt = bmp280_get_comp_pres_32bit (&pres32, ucomp_data.uncomp_press, |
| 126 | bmp); |
135 | bmp); |
| 127 | 136 | ||
| - | 137 | #if defined USB_DEVICE |
|
| - | 138 | ||
| 128 | // compile a logger message over USB |
139 | // compile a logger message over USB |
| 129 | char buffer[100]; |
140 | char buffer[100]; |
| 130 | int cnt = small_sprintf(buffer,"$TP,%ld,%ld",temp32,pres32); |
141 | int cnt = small_sprintf(buffer,"$TP,%ld,%ld",temp32,pres32); |
| 131 | uint8_t sum=0; |
142 | uint8_t sum=0; |
| 132 | for(int i=1; i<cnt; i++) |
143 | for(int i=1; i<cnt; i++) |
| 133 | sum += buffer[i]; |
144 | sum += buffer[i]; |
| 134 | cnt+= small_sprintf(buffer+cnt,"*%02X\n",sum); |
145 | cnt+= small_sprintf(buffer+cnt,"*%02X\n",sum); |
| 135 | 146 | ||
| 136 | CDC_Transmit_FS(reinterpret_cast<uint8_t*>(&buffer[0]),cnt); |
147 | CDC_Transmit_FS(reinterpret_cast<uint8_t*>(&buffer[0]),cnt); |
| 137 | 148 | #endif |
|
| 138 | 149 | ||
| 139 | } |
150 | } |
| 140 | } |
151 | } |
| 141 | display1.gotoxy (0, 56); |
152 | display1.gotoxy (0, 56); |
| 142 | display1.printString (small_font, "T", 2, WHITE); |
153 | display1.printString (small_font, "T", 2, WHITE); |