Subversion Repositories dashGPS

Rev

Rev 8 | Rev 10 | 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. int heading = 0;
  17. Location loc;
  18.  
  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.  
  31. displayDial_t dial (display1, 96, 32, 32, 180);
  32.  
  33. extern "C" void
  34. cc_init ()
  35. {
  36.   display1.init ();
  37.   display1.clearDisplay ();
  38.  
  39.   dial.draw_scale (0, 360, 8, 1, 45);
  40.  
  41.   display1.display ();
  42.  
  43.   memset(loc.time,'-',6 );
  44. }
  45.  
  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.  
  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.  
  98. }
  99.