In need of help conjoining two sketches for LED display output from Arduino UNO to SSD1306

Good afternoon

There is a video of the two displays however I'm unsure how to link them here!

Hardware;

-Arduino UNO R3

-SSD1306

(Awaiting GPS module) not necessary for sketches.

Job spec;

To display 1xbitmap for 2 seconds then 1x text for 2 seconds then to initialise a GPS speedometer display and maintain that until power is cycled

-I have developed a code based on U8g2 library to display the picture then the text on loop. These are working fine when sent to the screen.

-I have also copied a code for a GPS speedometer (this works fine when sent to the screen but operates on U8G, not U8G2)

I've now managed to combine the two sketches (maybe) although I'm not sure what if anything will happen as I'm now out of dynamic memory and I'm not sure how to reduce it further to see if the program will run. Perhaps there's lines that're unnecessary now that I've combined the two codes or maybe there's a simpler way of displaying text/Bitmap that uses less memory.

I'm hoping to eventually move this to an arduino NANO as I'm needing everything to be extremely compact so i understand this may further my storage problems.

Looking forward to any help anyone can offer!

Thanks, Jack

#include <U8g2lib.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#define OLED_ADDR   0x3C
#define time_delay 900
#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3 //unused
SoftwareSerial neogps(rxPin,txPin);




U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);


void u8g2_prepare() {


u8g2.setFont(u8g2_font_maniac_tf);
u8g2.setFontRefHeightExtendedText();

u8g2.setDrawColor(2);
u8g2.setFontPosTop();
u8g2.setFontDirection(0);
u8g2.setDrawColor(WHITE);
u8g2.setCursor(20, 18);
u8g2.println(F("Caddy.\n"));

}

#define image_width 128
#define image_height 64
static const unsigned char image_bits[] U8X8_PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x5f, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x4f, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x67, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x60, 0x01, 0x08, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0x7f, 0xf9, 0xf7, 0x03, 0xfe, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfe, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x7f, 0x3e, 0xe0, 0xff, 0xff, 0x37, 0xf0, 0xfe, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x7f, 0x3e, 0xc0, 0xff, 0xfe, 0x17, 0xe0, 0xfe, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x7f, 0x1e, 0xc0, 0xff, 0xfe, 0x07, 0x40, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x7f, 0x1e, 0xc0, 0xff, 0xfe, 0x07, 0x60, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x20, 0xfc, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xf0, 0x00, 0x00, 0x38, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
void u8g2_bitmap() {
 u8g2.drawXBMP(0, 5, image_width, image_height, image_bits);

}

#include <TinyGPS++.h> //1.0.3
TinyGPSPlus gps;
//---------------------------------------------------------------------------
int x_max    = 128;      
int y_max    = 62;        
int x_center = x_max/2;
int y_center = y_max/2+10;
int arc      = y_max/2;
int angle    = 0;
//---------------------------------------------------------------------------
int needle_pos = 0;
u8g2_uint_t xx  = 0;


#define sat_logo_width 20
#define sat_logo_height 20

const unsigned char sat_logo[] = {
  0x00, 0x01, 0x00, 0x80, 0x07, 0x00, 0xc0, 0x06, 0x00, 0x60, 0x30, 0x00,
  0x60, 0x78, 0x00, 0xc0, 0xfc, 0x00, 0x00, 0xfe, 0x01, 0x00, 0xff, 0x01,
  0x80, 0xff, 0x00, 0xc0, 0x7f, 0x06, 0xc0, 0x3f, 0x06, 0x80, 0x1f, 0x0c,
  0x80, 0x4f, 0x06, 0x19, 0xc6, 0x03, 0x1b, 0x80, 0x01, 0x73, 0x00, 0x00,
  0x66, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x70, 0x00, 0x00
};

double lat;
double lng;

String hour, minute;
int second;

int num_sat, speed;
String heading;


void gauge(uint8_t angle) {

  u8g2.setFont(u8g2_font_maniac_tf);
  //---------------------------------------------------------------------------


  u8g2.drawCircle(x_center,y_center,arc+6, U8G2_DRAW_UPPER_RIGHT);
  u8g2.drawCircle(x_center,y_center,arc+4, U8G2_DRAW_UPPER_RIGHT);
  u8g2.drawCircle(x_center,y_center,arc+6, U8G2_DRAW_UPPER_LEFT);
  u8g2.drawCircle(x_center,y_center,arc+4, U8G2_DRAW_UPPER_LEFT);
  //---------------------------------------------------------------------------
u8g2.drawStr(20,  42, "0");  
  u8g2.drawStr(18,  29, "25");
  u8g2.drawStr(28,  14, "50");
  u8g2.drawStr(60,  14, "100");
  u8g2.drawStr(91,  14, "150");
  u8g2.drawStr(101, 29, "175");
  u8g2.drawStr(105, 42, "200");
  //---------------------------------------------------------------------------
  u8g2.setCursor(57,25);
  u8g2.print(F("MPH.\n"));
  u8g2.setCursor(50,32);
  u8g2.print(F("SPEED.\n"));
  //---------------------------------------------------------------------------
  float x1=sin(2*angle*2*3.14/360);          
  float y1=cos(2*angle*2*3.14/360);
  u8g2.drawLine(x_center, y_center, x_center+arc*x1, y_center-arc*y1);
  u8g2.drawDisc(x_center, y_center, 5, U8G2_DRAW_UPPER_LEFT);
  u8g2.drawDisc(x_center, y_center, 5, U8G2_DRAW_UPPER_RIGHT);
  //---------------------------------------------------------------------------
  u8g2.drawXBM(0, 0, sat_logo_width, sat_logo_height, sat_logo);
  u8g2.setCursor(18, 5);
  u8g2.print(num_sat, 5); 
  //---------------------------------------------------------------------------
  u8g2.setCursor(110, 5);
  u8g2.print(heading);
  //---------------------------------------------------------------------------
  u8g2.setCursor(0, 55);
  u8g2.print(lat, 4);
  u8g2.setCursor(0, 62);
  u8g2.print(lng, 4);
  //---------------------------------------------------------------------------
  //Display time
  u8g2.setFont(u8g2_font_maniac_tf);
  u8g2.setCursor(90, 65);
  u8g2.print(hour);
 
  if(second%2 == 0)
    {u8g2.drawStr(104, 65, ":");}
  else
    {u8g2.drawStr(104, 65, " ");}
   
  u8g2.setCursor(111, 65);
  u8g2.print(minute);
 
 
  u8g2.setFont(u8g_font_profont22);
  u8g2.setCursor(54,60);
  if (speed<10){                              
    u8g2.print(F("0.\n"));
  }
  if (speed>99) {                                  
    u8g2.setCursor(47,60);
  }
  u8g2.print(speed);
 
}


int i = 200;
void setup(void) {

 Serial.begin(9600);
  neogps.begin(9600);
 
  u8g2.setFont(u8g_font_chikita);
  u8g2.setColorIndex(1);
}

void loop(void) {
   needle_pos = map(speed,0,200,0,90); 
  
  xx = needle_pos;                                    
  if (xx<45)
    {xx=xx+135;}
  else
    {xx=xx-45;}
  {
    u8g2.firstPage();
    do {            
      gauge(xx);
    }
    while( u8g2.nextPage() );
  }
  
}

void u8g2clearBuffer() {
u8g2.clearBuffer();
u8g2_prepare();
u8g2.sendBuffer();
delay(time_delay);
u8g2.clearBuffer();
u8g2.sendBuffer();
delay(time_delay);

// one tab

u8g2.clearBuffer();
u8g2_bitmap();
u8g2.sendBuffer();
delay(time_delay);
u8g2.clearBuffer();
u8g2.sendBuffer();
delay(time_delay);
}
 
void Read_GPS(){
  //------------------------------------------------------------------
  boolean newData = false;
  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (neogps.available())
    {
      if (gps.encode(neogps.read()))
      {
        newData = true;
        break;
      }
    }
  }

  if(newData == true){
    newData = false;
    Get_GPS();
  }
  else {
  
  }
}




void Get_GPS(){
  num_sat = gps.satellites.value();




  if (gps.location.isValid() == 1) {
    speed = gps.speed.mph();
   
    lat = gps.location.lat();
  
    lng = gps.location.lng();
    
    heading = gps.cardinal(gps.course.value());
   
  }
 
  if (gps.time.isValid()){
    hour = String(gps.time.hour());
    hour = (hour.length() == 1) ? "0"+hour : hour;
   
    minute = String(gps.time.minute());
    minute= (minute.length() == 1) ? "0"+minute : minute;
   
    second = gps.time.second();
  }
}






Sketch uses 32302 bytes (100%) of program storage space. Maximum is 32256 bytes.
Global variables use 2149 bytes (104%) of dynamic memory, leaving -101 bytes for local variables. Maximum is 2048 bytes.
Sketch too big; see https://support.arduino.cc/hc/en-us/articles/360013825179 for tips on reducing it.
text section exceeds available space in board

Compilation error: text section exceeds available space in board

Hi, @jecksspecs. Using String variables will probably play a bad joke on you, and besides, I don't see the point of storing numeric values like hours and minutes in them. For less memory you can see other libraries especially instead of those of Adafruit, which are good and versatile but use a lot of resources. You can program the Arduino Nano through another microcontroller and remove the bootloader so you have the full 32768 bytes of flash or replace it with a smaller bootloader. Do you know about Wemos D1 MINI? Its dimensions are similar but it is much faster and with much more memory but it runs on 3.3 volts.

Several obvious problems.

You are including both the U8g2 and Adafruit_SSD1306 libraries, but you never use any of the Adafruit libraries, other than for the word "WHITE" in the u8g2.setDrawColor(WHITE); statement on line 27. This is incorrect anyway, since setDrawColor takes a 0, 1, or 2 as the argument.

You are using an incorrect constructor for U8g2:

U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);

This constructor is for the wrong type display, an SH1106, and a full buffer.
A paged buffer with an SSD1306 would use the following:

U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);

You are mixing the U8g2 commands for a full buffer and a paged buffer, choose one or the other and make it consistent. The paged buffer would be preferable, since it uses less memory, and has some advantages for the GPS later on.

The maniac font is very large, and consequently takes a lot of program memory to store. Looking over the code, the only place I see that font actually being useful is when you display "Caddy.", if that is correct then its possibly to generate a smaller font file with only the necessary five characters needed.

The splash page with the picture of the car uses a very large bitmap, most of which is solid background color. You can reduce the size significantly by drawing a box over the entire screen, then overwriting a smaller bitmap in the center:


#define image_width 64
#define image_height 16
static const unsigned char image_bits[] U8X8_PROGMEM = {
  0xff, 0xff, 0xff, 0x3f, 0xc0, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x3f, 0x00, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x1f, 0x00, 0xfe, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x5f, 0x00, 0xfc, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x4f, 0x00, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x67, 0x00, 0xe0, 0xff, 0xff,
  0x7f, 0x00, 0x00, 0x60, 0x01, 0x08, 0xe0, 0xff,
  0x7f, 0xfe, 0xff, 0x7f, 0xf9, 0xf7, 0x03, 0xfe,
  0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfe,
  0x7f, 0x3e, 0xe0, 0xff, 0xff, 0x37, 0xf0, 0xfe,
  0x7f, 0x3e, 0xc0, 0xff, 0xfe, 0x17, 0xe0, 0xfe,
  0x7f, 0x1e, 0xc0, 0xff, 0xfe, 0x07, 0x40, 0xff,
  0x7f, 0x1e, 0xc0, 0xff, 0xfe, 0x07, 0x60, 0xff,
  0xff, 0x00, 0x20, 0xfc, 0x00, 0x00, 0x80, 0xff,
  0xff, 0x7f, 0xf0, 0x00, 0x00, 0x38, 0xf0, 0xff,
  0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
};
void u8g2_bitmap() {
  u8g2.drawBox(0, 0, 128, 64);
  u8g2.drawXBMP(32, 24, image_width, image_height, image_bits);
}

That's really helpful, thank you so much!
I've made most of the changes you've suggested and it's dropped the dynamic memory right down however I'm a smidge over on the program storage space.

Would you be able to help me understand this please?

"You are mixing the U8g2 commands for a full buffer and a paged buffer, choose one or the other and make it consistent. The paged buffer would be preferable, since it uses less memory, and has some advantages for the GPS later on."

I don't know what a buffer is, let alone the difference between a full and paged (despite frantic googling) and I'm not clear on how that's reflected in my code.

Any time that you are able to offer will genuinely be appreciated greatly. This is my first coding project and I'm very clueless.

Thanks!

Here's the updates so far;

#include <U8g2lib.h>
#include <Wire.h>
#define OLED_ADDR   0x3C
#define time_delay 900
#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3 //unused
SoftwareSerial neogps(rxPin,txPin);

U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);

void u8g2_prepare() {

u8g2.setFont(u8g2_font_maniac_tf);
u8g2.setFontRefHeightExtendedText();


u8g2.setDrawColor(2);
u8g2.setFontPosTop();
u8g2.setFontDirection(0);
u8g2.setDrawColor(1);
u8g2.setCursor(20, 18);
u8g2.println(F("Caddy.\n"));

}
#define image_width 64
#define image_height 16
static const unsigned char image_bits[] U8X8_PROGMEM = {
  0xff, 0xff, 0xff, 0x3f, 0xc0, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x3f, 0x00, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x1f, 0x00, 0xfe, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x5f, 0x00, 0xfc, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x4f, 0x00, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x67, 0x00, 0xe0, 0xff, 0xff,
  0x7f, 0x00, 0x00, 0x60, 0x01, 0x08, 0xe0, 0xff,
  0x7f, 0xfe, 0xff, 0x7f, 0xf9, 0xf7, 0x03, 0xfe,
  0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfe,
  0x7f, 0x3e, 0xe0, 0xff, 0xff, 0x37, 0xf0, 0xfe,
  0x7f, 0x3e, 0xc0, 0xff, 0xfe, 0x17, 0xe0, 0xfe,
  0x7f, 0x1e, 0xc0, 0xff, 0xfe, 0x07, 0x40, 0xff,
  0x7f, 0x1e, 0xc0, 0xff, 0xfe, 0x07, 0x60, 0xff,
  0xff, 0x00, 0x20, 0xfc, 0x00, 0x00, 0x80, 0xff,
  0xff, 0x7f, 0xf0, 0x00, 0x00, 0x38, 0xf0, 0xff,
  0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
};
void u8g2_bitmap() {
  u8g2.drawBox(0, 0, 128, 64);
  u8g2.drawXBMP(32, 24, image_width, image_height, image_bits);
}


#include <TinyGPS++.h> //1.0.3
TinyGPSPlus gps;
//---------------------------------------------------------------------------
int x_max    = 128;      
int y_max    = 62;        
int x_center = x_max/2;
int y_center = y_max/2+10;
int arc      = y_max/2;
int angle    = 0;
//---------------------------------------------------------------------------
int needle_pos = 0;
u8g2_uint_t xx  = 0;




#define sat_logo_width 20
#define sat_logo_height 20


const unsigned char sat_logo[] = {
  0x00, 0x01, 0x00, 0x80, 0x07, 0x00, 0xc0, 0x06, 0x00, 0x60, 0x30, 0x00,
  0x60, 0x78, 0x00, 0xc0, 0xfc, 0x00, 0x00, 0xfe, 0x01, 0x00, 0xff, 0x01,
  0x80, 0xff, 0x00, 0xc0, 0x7f, 0x06, 0xc0, 0x3f, 0x06, 0x80, 0x1f, 0x0c,
  0x80, 0x4f, 0x06, 0x19, 0xc6, 0x03, 0x1b, 0x80, 0x01, 0x73, 0x00, 0x00,
  0x66, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x70, 0x00, 0x00
};


double lat;
double lng;


String hour, minute;
int second;


int num_sat, speed;
String heading;




void gauge(uint8_t angle) {


  u8g2.setFont(u8g2_font_maniac_tf);
  //---------------------------------------------------------------------------




  u8g2.drawCircle(x_center,y_center,arc+6, U8G2_DRAW_UPPER_RIGHT);
  u8g2.drawCircle(x_center,y_center,arc+4, U8G2_DRAW_UPPER_RIGHT);
  u8g2.drawCircle(x_center,y_center,arc+6, U8G2_DRAW_UPPER_LEFT);
  u8g2.drawCircle(x_center,y_center,arc+4, U8G2_DRAW_UPPER_LEFT);
  //---------------------------------------------------------------------------
u8g2.drawStr(20,  42, "0");  
  u8g2.drawStr(18,  29, "25");
  u8g2.drawStr(28,  14, "50");
  u8g2.drawStr(60,  14, "100");
  u8g2.drawStr(91,  14, "150");
  u8g2.drawStr(101, 29, "175");
  u8g2.drawStr(105, 42, "200");
  //---------------------------------------------------------------------------
  u8g2.setCursor(57,25);
  u8g2.print(F("MPH.\n"));
  u8g2.setCursor(50,32);
  u8g2.print(F("SPEED.\n"));
  //---------------------------------------------------------------------------
  float x1=sin(2*angle*2*3.14/360);          
  float y1=cos(2*angle*2*3.14/360);
  u8g2.drawLine(x_center, y_center, x_center+arc*x1, y_center-arc*y1);
  u8g2.drawDisc(x_center, y_center, 5, U8G2_DRAW_UPPER_LEFT);
  u8g2.drawDisc(x_center, y_center, 5, U8G2_DRAW_UPPER_RIGHT);
  //---------------------------------------------------------------------------
  u8g2.drawXBM(0, 0, sat_logo_width, sat_logo_height, sat_logo);
  u8g2.setCursor(18, 5);
  u8g2.print(num_sat, 5);
  //---------------------------------------------------------------------------
  u8g2.setCursor(110, 5);
  u8g2.print(heading);
  //---------------------------------------------------------------------------
  u8g2.setCursor(0, 55);
  u8g2.print(lat, 4);
  u8g2.setCursor(0, 62);
  u8g2.print(lng, 4);
  //---------------------------------------------------------------------------
  //Display time
  u8g2.setFont(u8g2_font_maniac_tf);
  u8g2.setCursor(90, 65);
  u8g2.print(hour);
 
  if(second%2 == 0)
    {u8g2.drawStr(104, 65, ":");}
  else
    {u8g2.drawStr(104, 65, " ");}
   
  u8g2.setCursor(111, 65);
  u8g2.print(minute);
 
 
  u8g2.setFont(u8g_font_profont22);
  u8g2.setCursor(54,60);
  if (speed<10){                              
    u8g2.print(F("0.\n"));
  }
  if (speed>99) {                                  
    u8g2.setCursor(47,60);
  }
  u8g2.print(speed);
 
}




int i = 200;
void setup(void) {


 Serial.begin(9600);
  neogps.begin(9600);
 
  u8g2.setFont(u8g_font_chikita);
  u8g2.setColorIndex(1);
}


void loop(void) {
   needle_pos = map(speed,0,200,0,90);
 
  xx = needle_pos;                                    
  if (xx<45)
    {xx=xx+135;}
  else
    {xx=xx-45;}
  {
    u8g2.firstPage();
    do {            
      gauge(xx);
    }
    while( u8g2.nextPage() );
  }
 
}


void u8g2clearBuffer() {
 u8g2.clearBuffer();
 u8g2_prepare();
 u8g2.sendBuffer();
 delay(time_delay);


// one tab


 u8g2.clearBuffer();
 u8g2_bitmap();
 u8g2.sendBuffer();
 delay(time_delay);

}
 
void Read_GPS(){
  //------------------------------------------------------------------
  boolean newData = false;
  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (neogps.available())
    {
      if (gps.encode(neogps.read()))
      {
        newData = true;
        break;
      }
    }
  }


  if(newData == true){
    newData = false;
    Get_GPS();
  }
  else {
 
  }
}

void Get_GPS(){
  num_sat = gps.satellites.value();


  if (gps.location.isValid() == 1) {
    speed = gps.speed.mph();
   
    lat = gps.location.lat();
 
    lng = gps.location.lng();
   
    heading = gps.cardinal(gps.course.value());
   
  }
 
  if (gps.time.isValid()){
    hour = String(gps.time.hour());
    hour = (hour.length() == 1) ? "0"+hour : hour;
   
    minute = String(gps.time.minute());
    minute= (minute.length() == 1) ? "0"+minute : minute;
   
    second = gps.time.second();
  }
}






type or paste code here

Sketch uses 32300 bytes (100%) of program storage space. Maximum is 32256 bytes.
Global variables use 1253 bytes (61%) of dynamic memory, leaving 795 bytes for local variables. Maximum is 2048 bytes.
text section exceeds available space in board

Compilation error: text section exceeds available space in board

A couple of things will get the code small enough to actually run:

Add the following to setup()

  u8g2.begin();

Then change u8g2_font_maniac_tf to u8g2_font_maniac_tr throughout the code. The _tf version of the font is all characters in the font, the _tr version only has the printable ASCII characters. I think you will find that font to be much too large for your gauge display.

The u8g2 library (as well as the Adafruit_SSD1306 library) uses a buffer in memory to form the image for the display, then that buffer is sent to the SSD1306. A full buffer for a 128 x 64 display needs 1024 bytes of ram, half the total ram of an UNO/nano.
A paged buffer is similar, but needs less ram. The display is divided up into sub-sections, in the case of the SSD1306 there are 8, which only requires a buffer 1/8 the size. The u8g2 library then uses the following code to fill each of the pages and send to the display, where draw() is a function with the display code:

  // picture loop
  u8g.firstPage();  
  do {
    draw();
  } while( u8g.nextPage() );

There is a more through explanation from the older u8g library https://github.com/olikraus/u8glib/wiki/tpictureloop

Thank you so much David. That's really helped me understand.

I've now managed to add the font on a time delay using your code and it isn't even close to exceeding memory limitations (although you were right, "maniac" is massive! so back to the drawing board on that one.

having now achieved the font before the GPS splash screen I have two issues (if you aren't bored of this one yet!)

Issue 1- for some unknown reason whilst the function of draw() works, it seems to upset the layout of the gps splash screen, leaving text in the wrong place etc. I've tried instructing it to clearbuffer in the setup after Draw() but i can't seem to stop it doing this. As soon as i take out the text and draw command, the gps screen stays good. odd.

Issue 2- I cannot find a solution for displaying the bitmap after the text.
I've tried using the code in your last response but changing the argument (i think that's how it's referred to) to u8g2_bitmap but again, no amount of putting things in different places seems to help, even copying what the previous code did to draw the GPS screen. pulling my hair out a little!

Again, any time you can spare to help me get through this is appreciated.

If i can compensate you for your time in any way, please do let me know.

This is where i'm up to, having removed any Bitmap display attempts since they're likely to just have been making things worse

#include <U8g2lib.h>
#include <Wire.h>

#define OLED_ADDR   0x3C
#define time_delay 900
#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3 //unused
SoftwareSerial neogps(rxPin,txPin);

U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);

void u8g2_draw() {

u8g2.setFont(u8g_font_chikita);
u8g2.setFontRefHeightExtendedText();


u8g2.setDrawColor(2);
u8g2.setFontPosTop();
u8g2.setFontDirection(0);
u8g2.setDrawColor(1);
u8g2.setCursor(20, 18);
u8g2.println(F("Caddy.\n"));

}

#define image_width 64
#define image_height 16
static const unsigned char image_bits[] U8X8_PROGMEM = {
  0xff, 0xff, 0xff, 0x3f, 0xc0, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x3f, 0x00, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x1f, 0x00, 0xfe, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x5f, 0x00, 0xfc, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x4f, 0x00, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x67, 0x00, 0xe0, 0xff, 0xff,
  0x7f, 0x00, 0x00, 0x60, 0x01, 0x08, 0xe0, 0xff,
  0x7f, 0xfe, 0xff, 0x7f, 0xf9, 0xf7, 0x03, 0xfe,
  0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfe,
  0x7f, 0x3e, 0xe0, 0xff, 0xff, 0x37, 0xf0, 0xfe,
  0x7f, 0x3e, 0xc0, 0xff, 0xfe, 0x17, 0xe0, 0xfe,
  0x7f, 0x1e, 0xc0, 0xff, 0xfe, 0x07, 0x40, 0xff,
  0x7f, 0x1e, 0xc0, 0xff, 0xfe, 0x07, 0x60, 0xff,
  0xff, 0x00, 0x20, 0xfc, 0x00, 0x00, 0x80, 0xff,
  0xff, 0x7f, 0xf0, 0x00, 0x00, 0x38, 0xf0, 0xff,
  0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
};
void u8g2_bitmap() {
  u8g2.drawBox(0, 0, 128, 64);
  u8g2.drawXBMP(32, 24, image_width, image_height, image_bits);
}

#include <TinyGPS++.h> //1.0.3
TinyGPSPlus gps;
//---------------------------------------------------------------------------
int x_max    = 128;      
int y_max    = 62;        
int x_center = x_max/2;
int y_center = y_max/2+10;
int arc      = y_max/2;
int angle    = 0;
//---------------------------------------------------------------------------
int needle_pos = 0;
u8g2_uint_t xx  = 0;




#define sat_logo_width 20
#define sat_logo_height 20


const unsigned char sat_logo[] = {
  0x00, 0x01, 0x00, 0x80, 0x07, 0x00, 0xc0, 0x06, 0x00, 0x60, 0x30, 0x00,
  0x60, 0x78, 0x00, 0xc0, 0xfc, 0x00, 0x00, 0xfe, 0x01, 0x00, 0xff, 0x01,
  0x80, 0xff, 0x00, 0xc0, 0x7f, 0x06, 0xc0, 0x3f, 0x06, 0x80, 0x1f, 0x0c,
  0x80, 0x4f, 0x06, 0x19, 0xc6, 0x03, 0x1b, 0x80, 0x01, 0x73, 0x00, 0x00,
  0x66, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x70, 0x00, 0x00
};


double lat;
double lng;


String hour, minute;
int second;


int num_sat, speed;
String heading;




void gauge(uint8_t angle) {


  u8g2.setFont(u8g_font_chikita);
  //---------------------------------------------------------------------------




  u8g2.drawCircle(x_center,y_center,arc+6, U8G2_DRAW_UPPER_RIGHT);
  u8g2.drawCircle(x_center,y_center,arc+4, U8G2_DRAW_UPPER_RIGHT);
  u8g2.drawCircle(x_center,y_center,arc+6, U8G2_DRAW_UPPER_LEFT);
  u8g2.drawCircle(x_center,y_center,arc+4, U8G2_DRAW_UPPER_LEFT);
  //---------------------------------------------------------------------------
u8g2.drawStr(20,  42, "0");  
  u8g2.drawStr(18,  29, "25");
  u8g2.drawStr(28,  14, "50");
  u8g2.drawStr(60,  14, "100");
  u8g2.drawStr(91,  14, "150");
  u8g2.drawStr(101, 29, "175");
  u8g2.drawStr(105, 42, "200");
  //---------------------------------------------------------------------------
  u8g2.setCursor(57,25);
  u8g2.print(F("MPH.\n"));
  u8g2.setCursor(50,32);
  u8g2.print(F("SPEED.\n"));
  //---------------------------------------------------------------------------
  float x1=sin(2*angle*2*3.14/360);          
  float y1=cos(2*angle*2*3.14/360);
  u8g2.drawLine(x_center, y_center, x_center+arc*x1, y_center-arc*y1);
  u8g2.drawDisc(x_center, y_center, 5, U8G2_DRAW_UPPER_LEFT);
  u8g2.drawDisc(x_center, y_center, 5, U8G2_DRAW_UPPER_RIGHT);
  //---------------------------------------------------------------------------
  u8g2.drawXBM(0, 0, sat_logo_width, sat_logo_height, sat_logo);
  u8g2.setCursor(18, 5);
  u8g2.print(num_sat, 5);
  //---------------------------------------------------------------------------
  u8g2.setCursor(110, 5);
  u8g2.print(heading);
  //---------------------------------------------------------------------------
  u8g2.setCursor(0, 55);
  u8g2.print(lat, 4);
  u8g2.setCursor(0, 62);
  u8g2.print(lng, 4);
  //---------------------------------------------------------------------------
  //Display time
  u8g2.setFont(u8g_font_chikita);
  u8g2.setCursor(90, 65);
  u8g2.print(hour);
 
  if(second%2 == 0)
    {u8g2.drawStr(104, 65, ":");}
  else
    {u8g2.drawStr(104, 65, " ");}
   
  u8g2.setCursor(111, 65);
  u8g2.print(minute);
 
 
  u8g2.setFont(u8g_font_profont22);
  u8g2.setCursor(54,60);
  if (speed<10){                              
    u8g2.print(F("0.\n"));
  }
  if (speed>99) {                                  
    u8g2.setCursor(47,60);
  }
  u8g2.print(speed);
 
}




int i = 200;
void setup(void) {
u8g2.begin();
ug82_draw();
u8g2.clearBuffer();
 Serial.begin(9600);
  neogps.begin(9600);
 
  u8g2.setFont(u8g_font_chikita);
  u8g2.setColorIndex(1);


}
void ug82_draw (void){
  // picture loop
  u8g2.firstPage();  
  do {
    u8g2_draw();
  } while( u8g2.nextPage() );
  delay(time_delay);
 u8g2.clearBuffer();

}

void loop(void) {
 
   needle_pos = map(speed,0,200,0,90);
 
  xx = needle_pos;                                    
  if (xx<45)
    {xx=xx+135;}
  else
    {xx=xx-45;}
  {
    u8g2.firstPage();
    do {            
      gauge(xx);
    }
    while( u8g2.nextPage() );
   
  }
 
}
 
void Read_GPS(){
  //------------------------------------------------------------------
  boolean newData = false;
  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (neogps.available())
    {
      if (gps.encode(neogps.read()))
      {
        newData = true;
        break;
      }
    }
  }


  if(newData == true){
    newData = false;
    Get_GPS();
  }
  else {
 
  }
}

void Get_GPS(){
  num_sat = gps.satellites.value();


  if (gps.location.isValid() == 1) {
    speed = gps.speed.mph();
   
    lat = gps.location.lat();
 
    lng = gps.location.lng();
   
    heading = gps.cardinal(gps.course.value());
   
  }
 
  if (gps.time.isValid()){
    hour = String(gps.time.hour());
    hour = (hour.length() == 1) ? "0"+hour : hour;
   
    minute = String(gps.time.minute());
    minute= (minute.length() == 1) ? "0"+minute : minute;
   
    second = gps.time.second();
  }
}

type or paste code here

I'm having a bit of a problem understanding your description of the exact problems you are having, although it seems you are not fully understanding how to use the U8g2 library with a paged buffer. The firstPage() / nextPage() loop has to be used whenever you want to display something on the display.

Have a look at this and see if you can understand how the display code works. I've removed all the gps related code, that is likely to give problems when using SoftwareSerial unless there is considerable idle time between sets of GPS data.
I've also included a customized subset of the maniac font for drawing the first splash page, the U8g2 library github page has all the code needed to generate customized font files, but it took a bit of googling to understand how to use it the first time I tried.

#include <U8g2lib.h>
#include <Wire.h>

//custom Maniac font, only contains letters to display "Caddy."
/*
  Fontname: -FreeType-Maniac-Medium-R-Normal--32-320-72-72-P-183-ISO10646-1
  Copyright: Copyright D-Sheep 2012
  Glyphs: 6/1530
  BBX Build Mode: 0
*/
const uint8_t u8g2_font_maniac_custom[253] U8G2_FONT_SECTION("u8g2_font_maniac_custom") = 
  "\6\0\4\2\5\5\1\4\6\21\37\0\370\27\370\27\0\0\0\0K\0\340 \5\0\304\23.\15\347D"
  "\24\16T\216\22\231\310 \3C\71\361F\271\6\203\240N\225\315\244#\351D^\66SeR\252L("
  "\221\312\224\244\62\203L*\232\312\14\6\252LJ\225I\251\62)\331L\237HG\322\231lJ'\34\14"
  "R\0a#\61F\31\276\312j\322\221x\42\236\310\17\16d\221t\42\256W\15T\372D<\21\217\204"
  "C\312\334\340\6d\63\361FY\7\203h*\232\212\246\242\251h*\65Xe\264\221t\42\236\210\353e"
  "\203\224*\223ReR\252LJ\66H\351\23\361D<\22\16)s\203\33\0y=\61\7\31\16\62\203"
  "\201*\223ReR\252LJ\225I\251\62)U&\245\312\244T\231\224*\223\222\15R\372D<\21\217"
  "\244\63\332\324`\25M\15\16dzy\42\236HG\262\232\301+\0\0\0\0\4\377\377\0";
  
#define time_delay 900

U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);

void u8g2_draw() {
  u8g2.setFont(u8g2_font_maniac_custom);
  u8g2.setFontRefHeightExtendedText();
  u8g2.setFontPosTop();
  u8g2.setFontDirection(0);
  u8g2.setDrawColor(1);
  u8g2.setCursor(20, 18);
  u8g2.println(F("Caddy.\n"));
}

#define image_width 64
#define image_height 16
static const unsigned char image_bits[] U8X8_PROGMEM = {
  0xff, 0xff, 0xff, 0x3f, 0xc0, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x3f, 0x00, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x1f, 0x00, 0xfe, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x5f, 0x00, 0xfc, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x4f, 0x00, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x67, 0x00, 0xe0, 0xff, 0xff,
  0x7f, 0x00, 0x00, 0x60, 0x01, 0x08, 0xe0, 0xff,
  0x7f, 0xfe, 0xff, 0x7f, 0xf9, 0xf7, 0x03, 0xfe,
  0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfe,
  0x7f, 0x3e, 0xe0, 0xff, 0xff, 0x37, 0xf0, 0xfe,
  0x7f, 0x3e, 0xc0, 0xff, 0xfe, 0x17, 0xe0, 0xfe,
  0x7f, 0x1e, 0xc0, 0xff, 0xfe, 0x07, 0x40, 0xff,
  0x7f, 0x1e, 0xc0, 0xff, 0xfe, 0x07, 0x60, 0xff,
  0xff, 0x00, 0x20, 0xfc, 0x00, 0x00, 0x80, 0xff,
  0xff, 0x7f, 0xf0, 0x00, 0x00, 0x38, 0xf0, 0xff,
  0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
};

void u8g2_bitmap() {
  u8g2.drawBox(0, 0, 128, 64);
  u8g2.drawXBMP(32, 24, image_width, image_height, image_bits);
}

//---------------------------------------------------------------------------
int x_max    = 128;
int y_max    = 62;
int x_center = x_max / 2;
int y_center = y_max / 2 + 10;
int arc      = y_max / 2;
int angle    = 0;
//---------------------------------------------------------------------------
int needle_pos = 0;
u8g2_uint_t xx  = 0;




#define sat_logo_width 20
#define sat_logo_height 20


const unsigned char sat_logo[] = {
  0x00, 0x01, 0x00, 0x80, 0x07, 0x00, 0xc0, 0x06, 0x00, 0x60, 0x30, 0x00,
  0x60, 0x78, 0x00, 0xc0, 0xfc, 0x00, 0x00, 0xfe, 0x01, 0x00, 0xff, 0x01,
  0x80, 0xff, 0x00, 0xc0, 0x7f, 0x06, 0xc0, 0x3f, 0x06, 0x80, 0x1f, 0x0c,
  0x80, 0x4f, 0x06, 0x19, 0xc6, 0x03, 0x1b, 0x80, 0x01, 0x73, 0x00, 0x00,
  0x66, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x70, 0x00, 0x00
};


double lat;
double lng;


String hour, minute;
int second;


int num_sat, speed;
String heading;




void gauge(uint8_t angle) {
  u8g2.setFont(u8g_font_chikita);
  //---------------------------------------------------------------------------

  u8g2.drawCircle(x_center, y_center, arc + 6, U8G2_DRAW_UPPER_RIGHT);
  u8g2.drawCircle(x_center, y_center, arc + 4, U8G2_DRAW_UPPER_RIGHT);
  u8g2.drawCircle(x_center, y_center, arc + 6, U8G2_DRAW_UPPER_LEFT);
  u8g2.drawCircle(x_center, y_center, arc + 4, U8G2_DRAW_UPPER_LEFT);
  //---------------------------------------------------------------------------
  u8g2.drawStr(20,  42, "0");
  u8g2.drawStr(18,  29, "25");
  u8g2.drawStr(28,  14, "50");
  u8g2.drawStr(60,  14, "100");
  u8g2.drawStr(91,  14, "150");
  u8g2.drawStr(101, 29, "175");
  u8g2.drawStr(105, 42, "200");
  //---------------------------------------------------------------------------
  u8g2.setCursor(57, 25);
  u8g2.print(F("MPH.\n"));
  u8g2.setCursor(50, 32);
  u8g2.print(F("SPEED.\n"));
  //---------------------------------------------------------------------------
  float x1 = sin(2 * angle * 2 * 3.14 / 360);
  float y1 = cos(2 * angle * 2 * 3.14 / 360);
  u8g2.drawLine(x_center, y_center, x_center + arc * x1, y_center - arc * y1);
  u8g2.drawDisc(x_center, y_center, 5, U8G2_DRAW_UPPER_LEFT);
  u8g2.drawDisc(x_center, y_center, 5, U8G2_DRAW_UPPER_RIGHT);
  //---------------------------------------------------------------------------
  u8g2.drawXBM(0, 0, sat_logo_width, sat_logo_height, sat_logo);
  u8g2.setCursor(18, 5);
  u8g2.print(num_sat, 5);
  //---------------------------------------------------------------------------
  u8g2.setCursor(110, 5);
  u8g2.print(heading);
  //---------------------------------------------------------------------------
  u8g2.setCursor(0, 55);
  u8g2.print(lat, 4);
  u8g2.setCursor(0, 62);
  u8g2.print(lng, 4);
  //---------------------------------------------------------------------------
  //Display time
  u8g2.setFont(u8g_font_chikita);
  u8g2.setCursor(90, 65);
  u8g2.print(hour);

  if (second % 2 == 0)
  {
    u8g2.drawStr(104, 65, ":");
  }
  else
  {
    u8g2.drawStr(104, 65, " ");
  }

  u8g2.setCursor(111, 65);
  u8g2.print(minute);


  u8g2.setFont(u8g_font_profont22);
  u8g2.setCursor(54, 60);
  if (speed < 10) {
    u8g2.print(F("0.\n"));
  }
  if (speed > 99) {
    u8g2.setCursor(47, 60);
  }
  u8g2.print(speed);
}

void setup(void) {
  Serial.begin(9600);
  u8g2.begin();
  
  // picture loop
  u8g2.firstPage();
  do {
    u8g2_draw();
  } while ( u8g2.nextPage() );
  delay(time_delay);

  u8g2.clearDisplay();
  delay(time_delay);

  u8g2.firstPage();
  do {
    u8g2_bitmap();
  } while (u8g2.nextPage());
  delay(time_delay);

  u8g2.clearDisplay();
  delay(time_delay);

  u8g2.firstPage();
  do {
    gauge(135);
  } while (u8g2.nextPage());
  delay(time_delay);

}

void loop(void) {
}

That's brilliant, thank you. I'm definitely beginning to understand how the paged buffer works, thank you for taking the time on that one.

I've attached two photos of the display;
one is without the text file and bitmap prior to the GPS splash and the GPS displays correctly (everything in it's correct position)

and the other photo is with the bitmap and caddy text, as you can see it's for some reason i cannot fathom altering the GPS display (the numbers aren't in the correct places and it loses the "0.0" I think it's dropping everything down a few mm.

Any ideas?


The problem is in your function for displaying the text screen.

setFontPosTop() changes the reference point for the characters to the upper left corner, instead of the default which is the left side at the baseline (line on which the base of the characters sits, with the descending portion (such as g, q, y, etc) being below the baseline). That applies to all subsequent fonts, so your text is being printed at a lower position.

As far as I can tell, setFontRefHeightExtendedText() is not having much effect, it changes how some of the calculations are done for character height and descent.

Here is the function with the cursor position adjusted so that setFontPosTop() is not needed.

void u8g2_prepare() {
  u8g2.setFont(u8g2_font_maniac_custom);
  //u8g2.setFontRefHeightExtendedText();
  //u8g2.setFontPosTop();
  u8g2.setFontDirection(0);
  u8g2.setDrawColor(1);
  //u8g2.setCursor(20, 18);
  u8g2.setCursor(20, 42); 
  u8g2.println(F("Caddy."));
}

Thank you again David, apologies for the late response, I've been a bit inundated with life. That definitely did the trick! I'm hoping to take it for a road test soon. Will keep you updated and thanks again for all the help so far!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.