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 | |||
9 | mjames | 16 | int heading = 0; |
17 | Location loc; |
||
18 | |||
6 | mjames | 19 | uint8_t displayBuffer[dataSize (WIDTH, HEIGHT)]; |
20 | |||
21 | stm32_halDisplay_t display1 (WIDTH, HEIGHT, DISPLAY_RAMWIDTH, displayBuffer, |
||
22 | &hspi1, |
||
23 | |||
24 | SPI_CD_GPIO_Port, |
||
25 | SPI_CD_Pin, |
||
26 | SPI_RESET_GPIO_Port, |
||
27 | SPI_RESET_Pin, |
||
28 | SPI_NSS1_GPIO_Port, |
||
29 | SPI_NSS1_Pin); |
||
30 | |||
9 | mjames | 31 | displayDial_t dial (display1, 96, 32, 32, 180); |
8 | mjames | 32 | |
6 | mjames | 33 | extern "C" void |
34 | cc_init () |
||
35 | { |
||
9 | mjames | 36 | display1.init (); |
6 | mjames | 37 | display1.clearDisplay (); |
38 | |||
9 | mjames | 39 | dial.draw_scale (0, 360, 8, 1, 45); |
6 | mjames | 40 | |
41 | display1.display (); |
||
9 | mjames | 42 | |
43 | memset(loc.time,'-',6 ); |
||
6 | mjames | 44 | } |
45 | |||
46 | |||
9 | mjames | 47 | |
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; |
62 | } |
||
63 | |||
64 | |||
65 | display1.gotoxy (0, 0); |
||
66 | display1.printString (small_font, &loc.time[0], 2, WHITE); |
||
67 | display1.printString (small_font, ":",1, WHITE); |
||
68 | display1.printString (small_font, &loc.time[2], 2, WHITE); |
||
69 | |||
70 | display1.printString (small_font, ":",1, WHITE); |
||
71 | display1.printString (small_font, &loc.time[4], 2, WHITE); |
||
72 | int dial_ang = heading + 180; |
||
73 | dial.draw_needle (dial_ang); |
||
74 | |||
75 | display1.gotoxy (70, 25); |
||
76 | if (loc.valid) |
||
77 | { |
||
78 | display1.fontDigits (large_font, 3, -1, heading); |
||
79 | } |
||
80 | else |
||
81 | display1.printString (large_font, "GPS?", 4, WHITE); |
||
82 | |||
83 | display1.gotoxy (0, 8); |
||
84 | display1.printString (small_font, fontBuf, 8, WHITE); |
||
85 | |||
86 | display1.gotoxy (0, 16); |
||
87 | display1.printScaledString (small_font, fontBuf, 5, 128, WHITE); |
||
88 | |||
89 | display1.gotoxy (0, 48); |
||
90 | display1.printScaledString (large_font, fontBuf, 5, 256, WHITE); |
||
91 | for (size_t i = 0; i < sizeof(fontBuf); i++) |
||
92 | { |
||
93 | if ((++fontBuf[i]) == 128) |
||
94 | fontBuf[i] = ' '; |
||
95 | } |
||
96 | display1.display (); |
||
97 | |||
6 | mjames | 98 | } |