Subversion Repositories dashGPS

Rev

Rev 9 | Rev 11 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include "main.h"
  2. #include "nmea.h"
  3. #include <cstring>
  4. #include "libOLED/stm32_halDisplay.H"
  5. #include "libOLED/fontclass.H"
  6. #include "libOLED/displayDial.H"
  7.  
  8. namespace
  9. {
  10.   int const WIDTH = 128;
  11.   int const HEIGHT = 64;
  12.   int const DISPLAY_RAMWIDTH = 132;
  13.  
  14. }
  15.  
  16. float speedMPH = 0.0;
  17. float speedAVG = 0.0;
  18. int heading = 0;
  19. Location loc;
  20.  
  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.  
  33. displayDial_t dial (display1, 96, 32, 32, 180);
  34.  
  35. extern "C" void
  36. cc_init ()
  37. {
  38.   display1.init ();
  39.   display1.clearDisplay ();
  40.  
  41.   dial.draw_scale (0, 360, 8, 1, 45);
  42.  
  43.   display1.display ();
  44.  
  45.   memset (loc.time, '-', 6);
  46. }
  47.  
  48. char fontBuf[] = "01234567";
  49. extern "C" void
  50. cc_run ()
  51. {
  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.   if(loc.valid=='V')
  64.   memset(loc.time,'-',6 );
  65.  
  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);
  71.  
  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);
  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.  
  99.  
  100.  
  101.  
  102. display1.display ();
  103.  
  104. }
  105.