Brief history... About a month ago; I upgraded from Arduino 1.6.4 to 1.8.4 I had trouble with it, so I copied all my sketches to a backup folder. Then deleted 1.6.4, followed by installing 1.8.4
I have several sketches for the GPS, oled display. I went on a cruise back in the beginning of Sept. So I uploaded the boat sketch to my Trinket. Last week, I decided to copy my GPS Speedometer sketch back to the Trinket.
The fonts are not the same as before(larger). No big deal, I figured out how to change the fonts, move the data around to fit the screen.
I can't figure out why the sketch no-longer displays the number of satellites. Was there a change in the Library/header files?
/*
Motorcycle (GPS) Speedometer
*/
#include <TinyWireM.h>
#include <USI_TWI_Master.h>
#include <Wire.h>
#include <NeoGPS_cfg.h>
#include <NMEAGPS_cfg.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeSerif9pt7b.h>
#include <Fonts/FreeSansBold18pt7b.h>
#include <Adafruit_GFX.h>
#include <SPI.h>
#include <NeoSWSerial.h>
NeoSWSerial gps_port(4, 3); // ASSIGNS PINS 3, 4 FOR GPS RX/TX
#include "NMEAGPS.h"
static NMEAGPS gps; // This parses the GPS characters
// If using software SPI (the default case):
#define OLED_MOSI 9
#define OLED_CLK 10
#define OLED_DC 11
#define OLED_CS 12
#define OLED_RESET 13
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
void setup() {
// connect at 115200 so we can read the GPS fast enough and echo without dropping chars
gps_port.begin(9600);
// request RMC and GGA only
gps_port.println( F("$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28") );
display.begin(SSD1306_SWITCHCAPVCC);
display.clearDisplay();
display.setFont(&FreeSerif9pt7b);
//display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(27, 22);
display.println( F("Mini-GPS"));
display.display(); // SEND SPLASH SCREEN
delay(2000); // WAIT 2 SECONDS
display.clearDisplay();
display.setFont(&FreeSerif9pt7b);
//display.setTextSize(0.8);
display.setCursor(55, 12);
display.print( F("By"));
display.setTextSize(0.8);
display.setCursor(15, 26);
display.print( F("Nick Sebring"));
display.display(); // SEND SPLASH SCREEN
delay(5000); // WAIT 10 SECONDS
// Insert text when no GPS signal received... ***********************
//display.clearDisplay();
//display.setCursor(2, 50);
//display.print( F("Serching satellites."));
//display.display(); // SEND SPLASH SCREEN
}
void loop() // run over and over again
{
while (gps_port.available()) {
if (gps.decode( gps_port.read() ) == NMEAGPS::DECODE_COMPLETED) {
if (gps.nmeaMessage == NMEAGPS::NMEA_RMC) {
// If your device emits a GGA then an RMC each second,
// change the above GGA to RMC. Or if you don't get all
// the attributes (e.g., alt, heading, speed and satellites)
// try changing the above test. NMEAorder.ino can be
// used to determine which one is last (should be used above).
// BTW, this is the safest place to do any time-consuming work,
// like updating the display. Doing it elsewhere will cause GPS
// characters to be lost, and some fix data won't be available/valid.
// And if you take too long here, you could still lose characters.
display.clearDisplay(); //CLEAR THE OLED BUFFER, THUS CLEARING THE SCREEN: GOT IT!
const gps_fix & fix = gps.fix();
// construct data to be sent to the OLED *****************************
display.setFont(); //reset font to default
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.print( F("Sat: "));
if (fix.valid.satellites) {
display.setCursor(60, 20);
display.println( fix.satellites );
}
if (fix.valid.date && fix.valid.time) {
display.setCursor(95, 0);
NeoGPS::clock_t seconds = (NeoGPS::clock_t) fix.dateTime; // convert pieces to seconds
// Calculate DST changeover times just once per year
static NeoGPS::clock_t springTime, fallTime;
static NeoGPS::time_t changeover;
if ((springTime == 0) || (changeover.year != fix.dateTime.year)) {
changeover.year = fix.dateTime.year;
changeover.month = 3;
changeover.date = 14; // latest 2nd Sunday
changeover.hours = 2;
changeover.minutes = 0;
changeover.seconds = 0;
changeover.set_day();
// Step back to the 2nd Sunday, if day != SUNDAY
changeover.date -= (changeover.day - NeoGPS::time_t::SUNDAY);
springTime = (NeoGPS::clock_t) changeover;
changeover.month = 11;
changeover.date = 7; // latest 1st Sunday
changeover.set_day();
// Step back to the 1st Sunday, if day != SUNDAY
changeover.date -= (changeover.day - NeoGPS::time_t::SUNDAY);
fallTime = (NeoGPS::clock_t) changeover;
}
NeoGPS::clock_t tz = 5; // THIS IS WHERE YOU PUT IN YOUR LOCAL TIME ZONE
if ((springTime <= seconds) && (seconds < fallTime))
tz--;
seconds -= tz * 60 * 60; // offset seconds to local timezone, including DST
NeoGPS::time_t localTime( seconds ); // convert seconds back to pieces // convert seconds back to pieces
if (localTime.hours < 10) {
display.print( '0' );
}
display.print( localTime.hours ); display.print( ':' ); // use pieces
if (localTime.minutes < 10) {
display.print( '0' );
}
display.print( localTime.minutes);
}
if (fix.valid.speed) {
display.setFont(&FreeSansBold18pt7b);
display.setTextSize(1);
display.setCursor(38, 30);
display.println( fix.speed_mph(), 0);
}
// display.setTextSize(1);
// display.setCursor(10, 57);
// if (fix.valid.location) {
// display.print(fix.latitude(), 4);
// display.print( F(", ") );
// display.print(fix.longitude(), 4);
}
display.display();
}
}
}
Admins: should I just tack this on to my previous thread (Adafruit Ultimate GPS, SSD1306 0.96" 128x64 OLED, Arduino Uno sketch problems - Project Guidance - Arduino Forum)? Or is this ok?