๐Ÿ“ฃ๐Ÿ“ช ๐Ÿšš Adafruit will not be shipping USPS orders Monday October 14, 2019 ๐Ÿ—“. Expedited USPS orders placed after 11am ET ๐Ÿ•š Friday October 11 will go out Tuesday October 15 ๐Ÿ“ฃ๐Ÿ“ช๐Ÿšš
0

OLED display not working with Ultimate GPS
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

OLED display not working with Ultimate GPS

by Squiddles1227 on Mon Jul 29, 2019 6:41 pm

I've been trying to read data from a GPS and then display it on a Monochrome 0.96" 128x64 OLED graphic display. Everything works fine until I uncomment the three lines of code that send commands to the GPS. The screen will not light up at all. Any help or suggestions would be greatly appreciated.

Code: Select all | TOGGLE FULL SIZE
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_MOSI   9
#define OLED_CLK   10
#define OLED_DC    11
#define OLED_CS    12
#define OLED_RESET 13
#define GPS_RX 7
#define GPS_TX 8
#define GPSECHO  true
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);


SoftwareSerial mySerial(GPS_TX, GPS_RX);
Adafruit_GPS GPS(&mySerial);
boolean usingInterrupt = false;
void useInterrupt(boolean);
uint32_t timer = millis();
short tzOffset = 4;

static const unsigned char PROGMEM waveWithName[]  = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfd, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x0c, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x3f, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x61, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00,
  0x00, 0x40, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0f, 0xff, 0xf8, 0x00,
  0x00, 0x20, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x07, 0xff, 0x80, 0x00, 0x00,
  0x00, 0x18, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00,
  0x00, 0x07, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x0e, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x04, 0x00, 0x40, 0x00, 0x7e, 0x02, 0x00, 0x04, 0x10,
  0x1b, 0x00, 0x00, 0x10, 0x00, 0x84, 0x00, 0x04, 0x00, 0x40, 0x00, 0x04, 0x02, 0x00, 0x04, 0x00,
  0x10, 0x38, 0xc7, 0x38, 0xc3, 0x87, 0x22, 0x04, 0xe1, 0xc6, 0x38, 0x0c, 0xe2, 0x30, 0xe4, 0x90,
  0x10, 0x21, 0x20, 0x91, 0x24, 0x84, 0x96, 0x04, 0x12, 0x49, 0x24, 0x18, 0x12, 0x49, 0x05, 0x10,
  0x10, 0x21, 0xe7, 0x91, 0xe4, 0x84, 0x94, 0x04, 0xf2, 0x4f, 0x24, 0x10, 0xf2, 0x78, 0xc7, 0x10,
  0x10, 0x21, 0x04, 0x91, 0x04, 0x84, 0x94, 0x04, 0x92, 0x48, 0x24, 0x30, 0x92, 0x40, 0x27, 0x10,
  0x1b, 0x21, 0x24, 0x91, 0x24, 0x84, 0x88, 0x0c, 0x92, 0x49, 0x24, 0x20, 0x92, 0x48, 0x25, 0x90,
  0x0e, 0x20, 0xc7, 0x98, 0xc3, 0x87, 0x08, 0x78, 0xf1, 0xc6, 0x24, 0x7e, 0xf1, 0x31, 0xc4, 0xd0,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};


void setup() {
 
  display.begin(SSD1306_SWITCHCAPVCC);
  startScreen();
  GPS.begin(9600);
//  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA); // these three lines are the problem
//  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
//  GPS.sendCommand(PGCMD_ANTENNA);
  useInterrupt(true);
  delay(1000);
 
}

SIGNAL(TIMER0_COMPA_vect) {
    char c = GPS.read();
#ifdef UDR0
    if (GPSECHO)
        if (c) UDR0 = c;
#endif
}
 
void useInterrupt(boolean v) {
    if (v) {
        OCR0A = 0xAF;
        TIMSK0 |= _BV(OCIE0A);
        usingInterrupt = true;
    }
    else {
        TIMSK0 &= ~_BV(OCIE0A);
        usingInterrupt = false;
    }
}

void startScreen() {
  display.clearDisplay();

  display.drawBitmap(0, 0, waveWithName, 128, 64, WHITE);
  display.display();

  delay(3000);

  for(int16_t i=0; i<display.height()/2; i+=1) {
    display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
    display.display();
    delay(2);
  }


}

void printDateTime() {
    short hr = GPS.hour - tzOffset;
    if (hr < 0)
    {
        hr += 24;
    }
    if (hr  < 10)
    {
        display.print('0');
    }
    display.print(hr, DEC);
    display.print(':');
    if ((short)GPS.minute < 10)
    {
        display.print('0');
    }
    display.print(GPS.minute, DEC);
    display.print(':');
    if ((short)GPS.seconds < 10)
    {
        display.print('0');
    }
    display.print(GPS.seconds, DEC);
}

void printHeading() {
    char dir[3];
    dir[0] = ' ';
    dir[1] = ' ';
    dir[2] = ' ';
 
    if (GPS.angle > 337.25)
    {
        dir[0] = 'N';
    }
    else if (GPS.angle <= 22.5)
    {
        dir[0] = 'N';
    }
    else if (GPS.angle <= 67.5)
    {
        dir[0] = 'N';
        dir[1] = 'E';
    }
    else if (GPS.angle <= 112.5)
    {
        dir[0] = 'E';
    }
    else if (GPS.angle <= 157.5)
    {
        dir[0] = 'S';
        dir[1] = 'E';
    }
    else if (GPS.angle <= 202.5)
    {
        dir[0] = 'S';
    }
    else if (GPS.angle <= 247.5)
    {
        dir[0] = 'S';
        dir[1] = 'W';
    }
    else if (GPS.angle <= 292.5)
    {
        dir[0] = 'W';
    }
    else if (GPS.angle <= 337.5)
    {
        dir[0] = 'N';
        dir[1] = 'W';
    }
    display.print(dir[0]);
    display.print(dir[1]);
    display.print(dir[2]);
}
 
void updateDisplay() {
    display.clearDisplay();
    display.setTextColor(WHITE);
    display.setCursor(0, 0);
    display.setTextSize(2);
    printDateTime();
    display.setTextSize(0);
    display.setCursor(110, 0);
    display.print((int)GPS.satellites);

    if (GPS.fix)
    {
        display.setCursor(110, 8);
        display.print(GPS.HDOP, 1);
        display.print(GPS.latitudeDegrees, 5); display.print(','); display.println(GPS.longitudeDegrees, 5);

        display.print(GPS.altitude, 0); display.print("m ");
       
        if ((int)GPS.speed>0)
        {
            printHeading();
        }
        else
        {
           display.print("-- ");
        }
        // speed is in knots, convert to mph
        display.print((int)(GPS.speed*1.15078)); display.println(" mph");
    }
    display.display();
}

void loop()
{
    if (GPS.newNMEAreceived()) {
        if (!GPS.parse(GPS.lastNMEA()))
            return;
    }
    if (timer > millis())  timer = millis();
 
    if (millis() - timer > 1000) {
        timer = millis(); // reset the timer
 
        updateDisplay();
    }
}

Squiddles1227
 
Posts: 10
Joined: Mon Jan 23, 2017 4:44 pm

Re: OLED display not working with Ultimate GPS

by adafruit_support_carter on Mon Jul 29, 2019 7:17 pm

Seems odd, esp. since you call startScreen() first and it has a 3 second delay. You don't even see the 'waveWithName' bitmap?

adafruit_support_carter
 
Posts: 13163
Joined: Tue Nov 29, 2016 2:45 pm

Re: OLED display not working with Ultimate GPS

by Squiddles1227 on Mon Jul 29, 2019 7:27 pm

No, the screen never turns on.

Squiddles1227
 
Posts: 10
Joined: Mon Jan 23, 2017 4:44 pm

Re: OLED display not working with Ultimate GPS

by adafruit_support_carter on Mon Jul 29, 2019 7:42 pm

Try adding some serial prints to verify the code is tracing through as expected. Ex:
Code: Select all | TOGGLE FULL SIZE
    void startScreen() {
      Serial.println("startScreen - clear");
      display.clearDisplay();

      display.drawBitmap(0, 0, waveWithName, 128, 64, WHITE);
      display.display();
      Serial.println("startScreen - 3 second delay");
      delay(3000);
      Serial.println("startScreen - loop");
      for(int16_t i=0; i<display.height()/2; i+=1) {
        display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
        display.display();
        delay(2);
      }


    }

Be sure to do the typical serial init stuff in setup(). And post what you get in the serial monitor.

adafruit_support_carter
 
Posts: 13163
Joined: Tue Nov 29, 2016 2:45 pm

Re: OLED display not working with Ultimate GPS

by Squiddles1227 on Mon Jul 29, 2019 8:05 pm

Heres the code:
Code: Select all | TOGGLE FULL SIZE
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_MOSI   9
#define OLED_CLK   10
#define OLED_DC    11
#define OLED_CS    12
#define OLED_RESET 13
#define GPS_RX 7
#define GPS_TX 8
#define GPSECHO  true
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);


SoftwareSerial mySerial(GPS_TX, GPS_RX);
Adafruit_GPS GPS(&mySerial);
boolean usingInterrupt = false;
void useInterrupt(boolean);
uint32_t timer = millis();
short tzOffset = 4;

static const unsigned char PROGMEM waveWithName[]  = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfd, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x0c, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x3f, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x61, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00,
  0x00, 0x40, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0f, 0xff, 0xf8, 0x00,
  0x00, 0x20, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x07, 0xff, 0x80, 0x00, 0x00,
  0x00, 0x18, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00,
  0x00, 0x07, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x0e, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x04, 0x00, 0x40, 0x00, 0x7e, 0x02, 0x00, 0x04, 0x10,
  0x1b, 0x00, 0x00, 0x10, 0x00, 0x84, 0x00, 0x04, 0x00, 0x40, 0x00, 0x04, 0x02, 0x00, 0x04, 0x00,
  0x10, 0x38, 0xc7, 0x38, 0xc3, 0x87, 0x22, 0x04, 0xe1, 0xc6, 0x38, 0x0c, 0xe2, 0x30, 0xe4, 0x90,
  0x10, 0x21, 0x20, 0x91, 0x24, 0x84, 0x96, 0x04, 0x12, 0x49, 0x24, 0x18, 0x12, 0x49, 0x05, 0x10,
  0x10, 0x21, 0xe7, 0x91, 0xe4, 0x84, 0x94, 0x04, 0xf2, 0x4f, 0x24, 0x10, 0xf2, 0x78, 0xc7, 0x10,
  0x10, 0x21, 0x04, 0x91, 0x04, 0x84, 0x94, 0x04, 0x92, 0x48, 0x24, 0x30, 0x92, 0x40, 0x27, 0x10,
  0x1b, 0x21, 0x24, 0x91, 0x24, 0x84, 0x88, 0x0c, 0x92, 0x49, 0x24, 0x20, 0x92, 0x48, 0x25, 0x90,
  0x0e, 0x20, 0xc7, 0x98, 0xc3, 0x87, 0x08, 0x78, 0xf1, 0xc6, 0x24, 0x7e, 0xf1, 0x31, 0xc4, 0xd0,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};


void setup() {
  Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC);
  startScreen();
  GPS.begin(9600);
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
  GPS.sendCommand(PGCMD_ANTENNA);
  useInterrupt(true);
  delay(1000);
 
}

SIGNAL(TIMER0_COMPA_vect) {
    char c = GPS.read();
#ifdef UDR0
    if (GPSECHO)
        if (c) UDR0 = c;
#endif
}
 
void useInterrupt(boolean v) {
    if (v) {
        OCR0A = 0xAF;
        TIMSK0 |= _BV(OCIE0A);
        usingInterrupt = true;
    }
    else {
        TIMSK0 &= ~_BV(OCIE0A);
        usingInterrupt = false;
    }
}

void startScreen() {
  display.clearDisplay();

  display.drawBitmap(0, 0, waveWithName, 128, 64, WHITE);
  display.display();
  Serial.println("startScreen - 3 second delay");
  delay(3000);
  Serial.println("startScreen - loop");

  for(int16_t i=0; i<display.height()/2; i+=1) {
    display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
    display.display();
    delay(2);
  }


}

void printDateTime() {
    short hr = GPS.hour - tzOffset;
    if (hr < 0)
    {
        hr += 24;
    }
    if (hr  < 10)
    {
        display.print('0');
    }
    display.print(hr, DEC);
    display.print(':');
    if ((short)GPS.minute < 10)
    {
        display.print('0');
    }
    display.print(GPS.minute, DEC);
    display.print(':');
    if ((short)GPS.seconds < 10)
    {
        display.print('0');
    }
    display.print(GPS.seconds, DEC);
}

void printHeading() {
    char dir[3];
    dir[0] = ' ';
    dir[1] = ' ';
    dir[2] = ' ';
 
    if (GPS.angle > 337.25)
    {
        dir[0] = 'N';
    }
    else if (GPS.angle <= 22.5)
    {
        dir[0] = 'N';
    }
    else if (GPS.angle <= 67.5)
    {
        dir[0] = 'N';
        dir[1] = 'E';
    }
    else if (GPS.angle <= 112.5)
    {
        dir[0] = 'E';
    }
    else if (GPS.angle <= 157.5)
    {
        dir[0] = 'S';
        dir[1] = 'E';
    }
    else if (GPS.angle <= 202.5)
    {
        dir[0] = 'S';
    }
    else if (GPS.angle <= 247.5)
    {
        dir[0] = 'S';
        dir[1] = 'W';
    }
    else if (GPS.angle <= 292.5)
    {
        dir[0] = 'W';
    }
    else if (GPS.angle <= 337.5)
    {
        dir[0] = 'N';
        dir[1] = 'W';
    }
    display.print(dir[0]);
    display.print(dir[1]);
    display.print(dir[2]);
}
 
void updateDisplay() {
    display.clearDisplay();
    display.setTextColor(WHITE);
    display.setCursor(0, 0);
    display.setTextSize(2);
    printDateTime();
    display.setTextSize(0);
    display.setCursor(110, 0);
    display.print((int)GPS.satellites);

    if (GPS.fix)
    {
        display.setCursor(110, 8);
        display.print(GPS.HDOP, 1);
        display.print(GPS.latitudeDegrees, 5); display.print(','); display.println(GPS.longitudeDegrees, 5);

        display.print(GPS.altitude, 0); display.print("m ");
       
        if ((int)GPS.speed>0)
        {
            printHeading();
        }
        else
        {
           display.print("-- ");
        }
        // speed is in knots, convert to mph
        display.print((int)(GPS.speed*1.15078)); display.println(" mph");
    }
    display.display();
}

void loop()
{
    if (GPS.newNMEAreceived()) {
        if (!GPS.parse(GPS.lastNMEA()))
            return;
    }
    if (timer > millis())  timer = millis();
 
    if (millis() - timer > 1000) {
        timer = millis(); // reset the timer
 
        updateDisplay();
    }
}

And here's what the serial reads:
Code: Select all | TOGGLE FULL SIZE
startScreen - 3 second delay
ststartScreen - 3 second delay
ststartScreen - 3 second delay
ststartScreen - 3 second delay
ststartScreen - 3 second delay
ststartScreen - 3 second delay
ststartScreen - 3 second delay
ststartScreen - 3 second delay
ststartScreen - 3 second delay
ststartScreen - 3 second delay
ststartScreen - 3 second delay
ststartScreen - 3 second delay
ststartScreen - 3 second delay

Every three seconds a new line pops up.

Squiddles1227
 
Posts: 10
Joined: Mon Jan 23, 2017 4:44 pm

Re: OLED display not working with Ultimate GPS

by adafruit_support_carter on Mon Jul 29, 2019 8:17 pm

I'd suspect something with the interrupt, but in theory you haven't even turned it on at that point in the code. And it stays commented in with the version that works.

What are you using as the host controller? UNO?

adafruit_support_carter
 
Posts: 13163
Joined: Tue Nov 29, 2016 2:45 pm

Re: OLED display not working with Ultimate GPS

by Squiddles1227 on Mon Jul 29, 2019 8:30 pm

Yes, Uno.

Squiddles1227
 
Posts: 10
Joined: Mon Jan 23, 2017 4:44 pm

Re: OLED display not working with Ultimate GPS

by adafruit_support_carter on Tue Jul 30, 2019 12:58 pm

Try without interrupts.

Code: Select all | TOGGLE FULL SIZE
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_MOSI   9
#define OLED_CLK   10
#define OLED_DC    11
#define OLED_CS    12
#define OLED_RESET 13
#define GPS_RX 7
#define GPS_TX 8
#define GPSECHO  true
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);


SoftwareSerial mySerial(GPS_TX, GPS_RX);
Adafruit_GPS GPS(&mySerial);
boolean usingInterrupt = false;
//void useInterrupt(boolean);
uint32_t timer = millis();
short tzOffset = 4;

static const unsigned char PROGMEM waveWithName[]  = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfd, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x0c, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x3f, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x61, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00,
  0x00, 0x40, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0f, 0xff, 0xf8, 0x00,
  0x00, 0x20, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x07, 0xff, 0x80, 0x00, 0x00,
  0x00, 0x18, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00,
  0x00, 0x07, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x0e, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x04, 0x00, 0x40, 0x00, 0x7e, 0x02, 0x00, 0x04, 0x10,
  0x1b, 0x00, 0x00, 0x10, 0x00, 0x84, 0x00, 0x04, 0x00, 0x40, 0x00, 0x04, 0x02, 0x00, 0x04, 0x00,
  0x10, 0x38, 0xc7, 0x38, 0xc3, 0x87, 0x22, 0x04, 0xe1, 0xc6, 0x38, 0x0c, 0xe2, 0x30, 0xe4, 0x90,
  0x10, 0x21, 0x20, 0x91, 0x24, 0x84, 0x96, 0x04, 0x12, 0x49, 0x24, 0x18, 0x12, 0x49, 0x05, 0x10,
  0x10, 0x21, 0xe7, 0x91, 0xe4, 0x84, 0x94, 0x04, 0xf2, 0x4f, 0x24, 0x10, 0xf2, 0x78, 0xc7, 0x10,
  0x10, 0x21, 0x04, 0x91, 0x04, 0x84, 0x94, 0x04, 0x92, 0x48, 0x24, 0x30, 0x92, 0x40, 0x27, 0x10,
  0x1b, 0x21, 0x24, 0x91, 0x24, 0x84, 0x88, 0x0c, 0x92, 0x49, 0x24, 0x20, 0x92, 0x48, 0x25, 0x90,
  0x0e, 0x20, 0xc7, 0x98, 0xc3, 0x87, 0x08, 0x78, 0xf1, 0xc6, 0x24, 0x7e, 0xf1, 0x31, 0xc4, 0xd0,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};


void setup() {
  Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC);
  startScreen();
  GPS.begin(9600);
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
  GPS.sendCommand(PGCMD_ANTENNA);
//  useInterrupt(true);
  delay(1000);
 
}

//SIGNAL(TIMER0_COMPA_vect) {
//    char c = GPS.read();
//#ifdef UDR0
//    if (GPSECHO)
//        if (c) UDR0 = c;
//#endif
//}
//
//void useInterrupt(boolean v) {
//    if (v) {
//        OCR0A = 0xAF;
//        TIMSK0 |= _BV(OCIE0A);
//        usingInterrupt = true;
//    }
//    else {
//        TIMSK0 &= ~_BV(OCIE0A);
//        usingInterrupt = false;
//    }
//}

void startScreen() {
  display.clearDisplay();

  display.drawBitmap(0, 0, waveWithName, 128, 64, WHITE);
  display.display();
  Serial.println("startScreen - 3 second delay");
  delay(3000);
  Serial.println("startScreen - loop");

  for(int16_t i=0; i<display.height()/2; i+=1) {
    display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
    display.display();
    delay(2);
  }


}

void printDateTime() {
    short hr = GPS.hour - tzOffset;
    if (hr < 0)
    {
        hr += 24;
    }
    if (hr  < 10)
    {
        display.print('0');
    }
    display.print(hr, DEC);
    display.print(':');
    if ((short)GPS.minute < 10)
    {
        display.print('0');
    }
    display.print(GPS.minute, DEC);
    display.print(':');
    if ((short)GPS.seconds < 10)
    {
        display.print('0');
    }
    display.print(GPS.seconds, DEC);
}

void printHeading() {
    char dir[3];
    dir[0] = ' ';
    dir[1] = ' ';
    dir[2] = ' ';
 
    if (GPS.angle > 337.25)
    {
        dir[0] = 'N';
    }
    else if (GPS.angle <= 22.5)
    {
        dir[0] = 'N';
    }
    else if (GPS.angle <= 67.5)
    {
        dir[0] = 'N';
        dir[1] = 'E';
    }
    else if (GPS.angle <= 112.5)
    {
        dir[0] = 'E';
    }
    else if (GPS.angle <= 157.5)
    {
        dir[0] = 'S';
        dir[1] = 'E';
    }
    else if (GPS.angle <= 202.5)
    {
        dir[0] = 'S';
    }
    else if (GPS.angle <= 247.5)
    {
        dir[0] = 'S';
        dir[1] = 'W';
    }
    else if (GPS.angle <= 292.5)
    {
        dir[0] = 'W';
    }
    else if (GPS.angle <= 337.5)
    {
        dir[0] = 'N';
        dir[1] = 'W';
    }
    display.print(dir[0]);
    display.print(dir[1]);
    display.print(dir[2]);
}
 
void updateDisplay() {
    display.clearDisplay();
    display.setTextColor(WHITE);
    display.setCursor(0, 0);
    display.setTextSize(2);
    printDateTime();
    display.setTextSize(0);
    display.setCursor(110, 0);
    display.print((int)GPS.satellites);

    if (GPS.fix)
    {
        display.setCursor(110, 8);
        display.print(GPS.HDOP, 1);
        display.print(GPS.latitudeDegrees, 5); display.print(','); display.println(GPS.longitudeDegrees, 5);

        display.print(GPS.altitude, 0); display.print("m ");
       
        if ((int)GPS.speed>0)
        {
            printHeading();
        }
        else
        {
           display.print("-- ");
        }
        // speed is in knots, convert to mph
        display.print((int)(GPS.speed*1.15078)); display.println(" mph");
    }
    display.display();
}

void loop()
{
    char c = GPS.read();
    if (GPS.newNMEAreceived()) {
        if (!GPS.parse(GPS.lastNMEA()))
            return;
    }
    if (timer > millis())  timer = millis();
 
    if (millis() - timer > 1000) {
        timer = millis(); // reset the timer
 
        updateDisplay();
    }
}

adafruit_support_carter
 
Posts: 13163
Joined: Tue Nov 29, 2016 2:45 pm

Re: OLED display not working with Ultimate GPS

by Squiddles1227 on Tue Jul 30, 2019 11:40 pm

The code uploads correctly but seems to have no effect on the screen at all. The screen is still black.

Squiddles1227
 
Posts: 10
Joined: Mon Jan 23, 2017 4:44 pm

Please be positive and constructive with your questions and comments.