When I first configured this project I used a Mega and never experienced this problem. But now that I have re-configured using a Teensy LC it has become an issue.
I have a OLED display (spi) and an Adafruit ultimate GPS.
After an upload, when I have enable a “u8g2.sendBuffer()” the serial monitor shows ‘0’ sats found for several minutes, then will finally start showing the correct nbr of sats.
If I comment out the " u8g2.sendBuffer();" and upload the same code, the correct nbr of sats is immediately reported. Any ideas?
Further testing shows that if I do not execute the “send buffer” until I show a non-zero nbr of sats, everything seem to work just fine. Originally , I sent a message showing ‘no sats’ until a non-zero showed up. Now I do not send anything to the OLED until I have some sats and it works.
// Date Written: May 5,2019
// Author: Dave Garner
// Base code is from Yvan @ https://Brainy-Bits.com
// Processor: Arduino Mega
// Input Adafruit Ultimate GPS
// Output: 1.5" OLED display
// This code resides in my '36 Chevy Street rod and is used to display the following
// information on a 1.5" OLED display mounted above the interior rear view mirror.
// Direction of travel
// Elevation
// Direction and distance to my home.
#include <U8g2lib.h> // U8g2 Library for Oled https://github.com/olikraus/u8g2
#include <Math.h>
#include <TinyGPS++.h>
TinyGPSPlus gps;
char CSats[3] ="00";
char CAlt[5];
char CDis[5];
char CAngle[4] ="xxx";
long IAlt;
const char *cardinalHeading ;
int StringPixilLength ;
char HomeString[10];
static const double Home_LAT = 38.896565, Home_LON = -121.07689; // test (Aubrun CA)
// static const double Home_LAT = 38.652807, Home_LON = -121.153539; // my home address
// U8g2 Library SPI, Full Frame Buffer mode
// U8G2_SSD1327_MIDAS_128X128_F_4W_SW_SPI (rotation, clock, data, cs, dc [, reset]) // Teensy LC
U8G2_SSD1327_MIDAS_128X128_F_4W_SW_SPI u8g2(U8G2_R0 , 5, 6, 4, 3 , 2) ;
void setup()
{
// Serial.begin(9600);
Serial.println("---- Fire this Baby up! -------");
Serial1.begin(9600);
u8g2.begin();
u8g2.setContrast(200); // 0 to 255
// delay (5000) ;
}
void loop()
{
//---------------------------------------- Grab and format the satellite info -----------------------------
// Serial.print("Serial1.available() "); Serial.println(Serial1.available());
while (Serial1.available())
gps.encode(Serial1.read());
//---------------------------------------- Wait till there are at least 4 sats -----------------------------
sprintf(CSats, "%02lu",gps.satellites.value());
Serial.print("satellites.value--"); Serial.println(CSats);
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_fub14_tr);
u8g2.drawStr(00, 30, CSats);
// u8g2.setFont(u8g2_font_fub25_tr);
// u8g2.drawStr(10, 100, "No Fix!");
// enabling the line below will cause Tinygps to return '0' for a long time (minutes) after an upload and
// then start sending the correct info.
// Disable it and I get the correct nbr of sats immediatly.
u8g2.sendBuffer();
}