Rev 8 | Rev 10 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 8 | Rev 9 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | #include "main.h" |
1 | #include "main.h" |
| - | 2 | #include "nmea.h" |
|
| - | 3 | #include <cstring> |
|
| 2 | #include "libOLED/stm32_halDisplay.H" |
4 | #include "libOLED/stm32_halDisplay.H" |
| 3 | #include "libOLED/fontclass.H" |
5 | #include "libOLED/fontclass.H" |
| 4 | #include "libOLED/displayDial.H" |
6 | #include "libOLED/displayDial.H" |
| 5 | 7 | ||
| 6 | namespace |
8 | namespace |
| Line 9... | Line 11... | ||
| 9 | int const HEIGHT = 64; |
11 | int const HEIGHT = 64; |
| 10 | int const DISPLAY_RAMWIDTH = 132; |
12 | int const DISPLAY_RAMWIDTH = 132; |
| 11 | 13 | ||
| 12 | } |
14 | } |
| 13 | 15 | ||
| - | 16 | int heading = 0; |
|
| - | 17 | Location loc; |
|
| - | 18 | ||
| 14 | uint8_t displayBuffer[dataSize (WIDTH, HEIGHT)]; |
19 | uint8_t displayBuffer[dataSize (WIDTH, HEIGHT)]; |
| 15 | 20 | ||
| 16 | stm32_halDisplay_t display1 (WIDTH, HEIGHT, DISPLAY_RAMWIDTH, displayBuffer, |
21 | stm32_halDisplay_t display1 (WIDTH, HEIGHT, DISPLAY_RAMWIDTH, displayBuffer, |
| 17 | &hspi1, |
22 | &hspi1, |
| 18 | 23 | ||
| Line 21... | Line 26... | ||
| 21 | SPI_RESET_GPIO_Port, |
26 | SPI_RESET_GPIO_Port, |
| 22 | SPI_RESET_Pin, |
27 | SPI_RESET_Pin, |
| 23 | SPI_NSS1_GPIO_Port, |
28 | SPI_NSS1_GPIO_Port, |
| 24 | SPI_NSS1_Pin); |
29 | SPI_NSS1_Pin); |
| 25 | 30 | ||
| 26 | - | ||
| 27 | displayDial_t dial (64, 64, 64); |
31 | displayDial_t dial (display1, 96, 32, 32, 180); |
| 28 | int cnt = 0; |
- | |
| 29 | - | ||
| 30 | 32 | ||
| 31 | extern "C" void |
33 | extern "C" void |
| 32 | cc_init () |
34 | cc_init () |
| 33 | { |
35 | { |
| 34 | display1.init(); |
36 | display1.init (); |
| 35 | display1.clearDisplay (); |
37 | display1.clearDisplay (); |
| 36 | 38 | ||
| 37 | dial.draw_scale (display1, 0 , 10 , 4, 15 ,2); |
39 | dial.draw_scale (0, 360, 8, 1, 45); |
| 38 | 40 | ||
| 39 | display1.display (); |
41 | display1.display (); |
| - | 42 | ||
| - | 43 | memset(loc.time,'-',6 ); |
|
| 40 | } |
44 | } |
| 41 | 45 | ||
| 42 | 46 | ||
| - | 47 | ||
| - | 48 | char fontBuf[] = "01234567"; |
|
| 43 | extern "C" void |
49 | extern "C" void |
| 44 | cc_run() |
50 | cc_run () |
| 45 | { |
51 | { |
| 46 | if(cnt==0) |
- | |
| 47 | display1.clearDisplay(); |
- | |
| 48 | 52 | ||
| - | 53 | display1.clearDisplay (); |
|
| - | 54 | dial.draw_scale (0, 360, 8, 1, 45); |
|
| - | 55 | ||
| - | 56 | bool stat = updateLocation (&loc); |
|
| - | 57 | if (loc.good) |
|
| - | 58 | { |
|
| - | 59 | heading = loc.heading; |
|
| - | 60 | ||
| - | 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 | ||
| 49 | display1.gotoxy(0,8); |
83 | display1.gotoxy (0, 8); |
| 50 | display1.printString(small_font,"ABCDabcd",8,WHITE); |
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 (); |
|
| 51 | 97 | ||
| 52 | display1.gotoxy(0,16); |
- | |
| 53 | display1.printScaledString(small_font,"ABCD1234",8,128 |
- | |
| 54 | ,WHITE); |
- | |
| 55 | - | ||
| 56 | display1.gotoxy(0,48); |
- | |
| 57 | display1.printScaledString(large_font,"ABCD1234",8,256 |
- | |
| 58 | ,WHITE); |
- | |
| 59 | display1.drawLine(96,cnt,127,cnt,WHITE); |
- | |
| 60 | display1.display(); |
- | |
| 61 | cnt++; |
- | |
| 62 | cnt%=64; |
- | |
| 63 | } |
98 | } |