fatfenders
New member
Originally I had everything working fine with this code (on the bench) using a MEGA; SPI. But the installation in my street rod required a 4 foot run and I soon found out SPI is not happy with that long of a run (garbled display). (Reading GPS stuff has always worked without a hitch). So for the first time I recently ordered a Teensy 3.5 and physically reconfigured such that the Teensy, the GPS, and the OLED are all together as you can see in the image below. The GPS works fine but all I get is a blank screen:
All 3 are using VSS of 3.3volts. GPS and Display use external power.
DC 9
CS 10
DIN 11
CLK 13
(My skillset is somewhere in between 'ignorant' and 'dangerous').
Thanks for any comments.
All 3 are using VSS of 3.3volts. GPS and Display use external power.
DC 9
CS 10
DIN 11
CLK 13
(My skillset is somewhere in between 'ignorant' and 'dangerous').
Thanks for any comments.
Code:
[ATTACH=CONFIG]16657._xfImport[/ATTACH]// ********************************************************************
// Date Written: May ,2019
// Author: Dave Garner
// Base code is from Yvan @ https://Brainy-Bits.com
// Processor: Teensy 3.5
// Libraries:
// GPS: TinyGPS++
// 1.5" OLED Display: U8g2lib
// Input: Adafruit Ultimate GPS
// Output: 1.5" OLED display
// This code resides in a Teensy 3.5 in my '36 Chevy Street rod and is used to display the following
// information:
// Direction of travel
// Elevation
// Direction and distance from/to my home.
// *********************************************************************
#include <TinyGPS++.h>
TinyGPSPlus gps;
#include <U8g2lib.h> // U8g2 Library for Oled https://github.com/olikraus/u8g2
#include <Math.h>
char CSats[3];
int ISats ;
long IAlt;
char CAlt[5];
char CDis[5];
int IDis ;
char CAngle[4] ="xxx";
const char *cardinalToHome ;
// 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 modes:
Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption
Page Buffer Examples: firstPage/nextPage. Less RAM usage, Slower, but should work with all Arduino boards.
U8x8 Text Only Example: No RAM usage, Fast, but No graphics, 8x8 Text only.
*/
// U8g2 Library Full Frame Buffer mode used in this tutorial
U8G2_SSD1327_MIDAS_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
void setup() {
Serial.begin(11520);
Serial.println("---- start -------");
Serial1.begin(9600);
u8g2.begin();
u8g2.setContrast(200); // 0 to 255
}
void loop() {
delay(500) ;
Serial.println("------------------ Start Formatting My Stuff 1-----------------");
Serial.print("Serial1.available() "); Serial.println(Serial1.available());
while (Serial1.available())
gps.encode(Serial1.read());
ISats = gps.satellites.value() ;
sprintf(CSats, "%02lu",gps.satellites.value());
Serial.print("satellites.value-=-+"); Serial.println(gps.satellites.value());
Serial.println("Compass Heading:");
Serial.println(gps.course.deg());
const char *cardinalHeading = TinyGPSPlus::cardinal(gps.course.deg());
Serial.print ("Cardinal Heading-");
Serial.print (cardinalHeading);
Serial.println ("-");
Serial.println("Latitude:");
Serial.println(gps.location.lat(), 6);
Serial.println("Longitude:");
Serial.println(gps.location.lng(), 6);
Serial.println("Elevation Feet:");
Serial.println(gps.altitude.feet());
IAlt = gps.altitude.feet();
sprintf(CAlt, "%4ld" , IAlt);
Serial.println("");
unsigned long distanceKmToHome =
(unsigned long)TinyGPSPlus::distanceBetween(
gps.location.lat(),
gps.location.lng(),
Home_LAT,
Home_LON) / 1000;
distanceKmToHome = distanceKmToHome * 0.621371;
sprintf(CDis, "%4ld" , distanceKmToHome);
if ( distanceKmToHome == 0) Serial.println("Home!");
else
{
sprintf(CDis, "%4lu" , distanceKmToHome);
Serial.print(" dist home-");
Serial.print(CDis);
Serial.println("-");
double courseToHome =
TinyGPSPlus::courseTo(
gps.location.lat(),
gps.location.lng(),
Home_LAT,
Home_LON);
Serial.print(" Heading to home-");
Serial.print(cardinalHeading);
Serial.println("-");
cardinalToHome = TinyGPSPlus::cardinal(courseToHome);
Serial.print(" cardinalToHome-");
Serial.print(cardinalToHome);
Serial.println("-");
}
if (ISats < 4)
{
Serial.print(" No Fix-");
Serial.println(ISats);
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!");
u8g2.sendBuffer();
}
else
{
Serial.print(" Fix!---");
Serial.println(ISats);
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_fub14_tr);
u8g2.drawStr(00, 30, CSats);
u8g2.setFont(u8g2_font_fub25_tr);
u8g2.drawStr(25, 60, cardinalHeading);
u8g2.drawStr(25, 95, CAlt);
u8g2.setFont(u8g2_font_fub20_tr);
if ( distanceKmToHome == 0) u8g2.drawStr(20, 120, "Home!");
else
{
u8g2.drawStr(00, 120, cardinalToHome);
u8g2.drawStr(60, 120, CDis);
}
u8g2.sendBuffer(); // Update Oled display
}
}
Last edited: