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 | |
6 | mjames | 8 | namespace |
9 | { |
||
10 | int const WIDTH = 128; |
||
11 | int const HEIGHT = 64; |
||
12 | int const DISPLAY_RAMWIDTH = 132; |
||
13 | |||
14 | } |
||
15 | |||
10 | mjames | 16 | float speedMPH = 0.0; |
17 | float speedAVG = 0.0; |
||
9 | mjames | 18 | int heading = 0; |
19 | Location loc; |
||
20 | |||
6 | mjames | 21 | uint8_t displayBuffer[dataSize (WIDTH, HEIGHT)]; |
22 | |||
23 | stm32_halDisplay_t display1 (WIDTH, HEIGHT, DISPLAY_RAMWIDTH, displayBuffer, |
||
24 | &hspi1, |
||
25 | |||
26 | SPI_CD_GPIO_Port, |
||
27 | SPI_CD_Pin, |
||
28 | SPI_RESET_GPIO_Port, |
||
29 | SPI_RESET_Pin, |
||
30 | SPI_NSS1_GPIO_Port, |
||
31 | SPI_NSS1_Pin); |
||
32 | |||
9 | mjames | 33 | displayDial_t dial (display1, 96, 32, 32, 180); |
8 | mjames | 34 | |
6 | mjames | 35 | extern "C" void |
36 | cc_init () |
||
37 | { |
||
9 | mjames | 38 | display1.init (); |
6 | mjames | 39 | display1.clearDisplay (); |
40 | |||
9 | mjames | 41 | dial.draw_scale (0, 360, 8, 1, 45); |
6 | mjames | 42 | |
43 | display1.display (); |
||
9 | mjames | 44 | |
10 | mjames | 45 | memset (loc.time, '-', 6); |
6 | mjames | 46 | } |
47 | |||
9 | mjames | 48 | char fontBuf[] = "01234567"; |
6 | mjames | 49 | extern "C" void |
9 | mjames | 50 | cc_run () |
6 | mjames | 51 | { |
7 | mjames | 52 | |
9 | mjames | 53 | display1.clearDisplay (); |
54 | dial.draw_scale (0, 360, 8, 1, 45); |
||
8 | mjames | 55 | |
9 | mjames | 56 | bool stat = updateLocation (&loc); |
57 | if (loc.good) |
||
58 | { |
||
59 | heading = loc.heading; |
||
8 | mjames | 60 | |
9 | mjames | 61 | loc.good = false; |
10 | mjames | 62 | } |
63 | if(loc.valid=='V') |
||
64 | memset(loc.time,'-',6 ); |
||
9 | mjames | 65 | |
10 | mjames | 66 | // print out the GMT time at the top of the screen |
67 | display1.gotoxy (0, 0); |
||
68 | display1.printString (small_font, &loc.time[0], 2, WHITE); |
||
69 | display1.printString (small_font, ":", 1, WHITE); |
||
70 | display1.printString (small_font, &loc.time[2], 2, WHITE); |
||
9 | mjames | 71 | |
10 | mjames | 72 | display1.printString (small_font, ":", 1, WHITE); |
73 | display1.printString (small_font, &loc.time[4], 2, WHITE); |
||
74 | int dial_ang = heading + 180; |
||
75 | dial.draw_needle (dial_ang); |
||
9 | mjames | 76 | |
10 | mjames | 77 | display1.gotoxy (70, 25); |
78 | if (loc.valid=='A') |
||
79 | { |
||
80 | display1.fontDigits (large_font, 3, -1, heading); |
||
81 | } |
||
82 | else |
||
83 | display1.printString (large_font, "GPS?", 4, WHITE); |
||
9 | mjames | 84 | |
85 | |||
10 | mjames | 86 | if(loc.valid == 'A') |
87 | speedMPH = loc.speed / 1.815; |
||
9 | mjames | 88 | |
10 | mjames | 89 | display1.gotoxy (0, 8); |
90 | display1.printString(small_font,"Speed",5, WHITE); |
||
91 | display1.gotoxy (0, 16); |
||
92 | display1.fontDigits(large_font, 4,1,speedMPH * 10); |
||
9 | mjames | 93 | |
10 | mjames | 94 | display1.gotoxy (0, 32); |
95 | display1.printString(small_font,"Average",7, WHITE); |
||
96 | display1.gotoxy (0, 40); |
||
97 | display1.fontDigits(large_font, 4,1,speedAVG * 10); |
||
9 | mjames | 98 | |
10 | mjames | 99 | |
100 | |||
101 | |||
102 | display1.display (); |
||
103 | |||
6 | mjames | 104 | } |