Subversion Repositories dashGPS

Rev

Rev 10 | Rev 13 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 10 Rev 11
Line 3... Line 3...
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"
-
 
9
 
8
namespace
10
namespace
9
{
11
{
10
  int const WIDTH = 128;
12
  int const WIDTH = 128;
11
  int const HEIGHT = 64;
13
  int const HEIGHT = 64;
12
  int const DISPLAY_RAMWIDTH = 132;
14
  int const DISPLAY_RAMWIDTH = 132;
Line 16... Line 18...
16
float speedMPH = 0.0;
18
float speedMPH = 0.0;
17
float speedAVG = 0.0;
19
float speedAVG = 0.0;
18
int heading = 0;
20
int heading = 0;
19
Location loc;
21
Location loc;
20
 
22
 
-
 
23
uint32_t lastTick = 0;
-
 
24
int32_t temp32 = 0;
-
 
25
uint32_t pres32 = 0;
-
 
26
int32_t rslt;
-
 
27
 
21
uint8_t displayBuffer[dataSize (WIDTH, HEIGHT)];
28
uint8_t displayBuffer[dataSize (WIDTH, HEIGHT)];
22
 
29
 
23
stm32_halDisplay_t display1 (WIDTH, HEIGHT, DISPLAY_RAMWIDTH, displayBuffer,
30
stm32_halDisplay_t display1 (WIDTH, HEIGHT, DISPLAY_RAMWIDTH, displayBuffer,
24
                             &hspi1,
31
                             &hspi1,
25
 
32
 
Line 33... Line 40...
33
displayDial_t dial (display1, 96, 32, 32, 180);
40
displayDial_t dial (display1, 96, 32, 32, 180);
34
 
41
 
35
extern "C" void
42
extern "C" void
36
cc_init ()
43
cc_init ()
37
{
44
{
-
 
45
  display1.reset ();
-
 
46
 
38
  display1.init ();
47
  display1.init ();
39
  display1.clearDisplay ();
48
  display1.clearDisplay ();
40
 
49
 
41
  dial.draw_scale (0, 360, 8, 1, 45);
50
  dial.draw_scale (0, 360, 8, 1, 45);
42
 
51
 
Line 45... Line 54...
45
  memset (loc.time, '-', 6);
54
  memset (loc.time, '-', 6);
46
}
55
}
47
 
56
 
48
char fontBuf[] = "01234567";
57
char fontBuf[] = "01234567";
49
extern "C" void
58
extern "C" void
50
cc_run ()
59
cc_run (struct bmp280_dev *bmp)
-
 
60
 
51
{
61
{
52
 
62
 
53
  display1.clearDisplay ();
63
  display1.clearDisplay ();
54
  dial.draw_scale (0, 360, 8, 1, 45);
64
  dial.draw_scale (0, 360, 8, 1, 45);
55
 
65
 
Line 57... Line 67...
57
  if (loc.good)
67
  if (loc.good)
58
    {
68
    {
59
      heading = loc.heading;
69
      heading = loc.heading;
60
 
70
 
61
      loc.good = false;
71
      loc.good = false;
62
}
72
    }
63
  if(loc.valid=='V')
73
  if (loc.valid == 'V')
64
  memset(loc.time,'-',6 );
74
    memset (loc.time, '-', 6);
65
 
75
 
66
 // print out the GMT time at the top of the screen
76
  // print out the GMT time at the top of the screen
67
display1.gotoxy (0, 0);
77
  display1.gotoxy (0, 0);
68
display1.printString (small_font, &loc.time[0], 2, WHITE);
78
  display1.printString (small_font, &loc.time[0], 2, WHITE);
69
display1.printString (small_font, ":", 1, WHITE);
79
  display1.printString (small_font, ":", 1, WHITE);
70
display1.printString (small_font, &loc.time[2], 2, WHITE);
80
  display1.printString (small_font, &loc.time[2], 2, WHITE);
71
 
81
 
72
display1.printString (small_font, ":", 1, WHITE);
82
  display1.printString (small_font, ":", 1, WHITE);
73
display1.printString (small_font, &loc.time[4], 2, WHITE);
83
  display1.printString (small_font, &loc.time[4], 2, WHITE);
74
int dial_ang = heading + 180;
84
  int dial_ang = heading + 180;
75
dial.draw_needle (dial_ang);
85
  dial.draw_needle (dial_ang);
76
 
-
 
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);
-
 
84
 
-
 
85
 
-
 
86
if(loc.valid == 'A')
-
 
87
  speedMPH = loc.speed / 1.815;
-
 
88
 
-
 
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);
-
 
93
 
-
 
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);
-
 
98
 
86
 
-
 
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);
-
 
94
 
-
 
95
  if (loc.valid == 'A')
-
 
96
    speedMPH = loc.speed / 1.815;
-
 
97
 
-
 
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);
-
 
102
 
-
 
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);
99
 
107
 
-
 
108
  struct bmp280_uncomp_data ucomp_data;
100
 
109
 
-
 
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);
-
 
115
 
-
 
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);
-
 
121
 
-
 
122
          rslt = bmp280_get_comp_pres_32bit (&pres32, ucomp_data.uncomp_press,
-
 
123
                                             bmp);
-
 
124
 
-
 
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);
101
 
133
 
102
display1.display ();
134
  display1.display ();
103
 
135
 
104
}
136
}