OLED display glitches only in one part

Hello im new to coding and i am working on a project with 2 buttons, arduino uno and oled display 1.3" 128x64 SPI. Everything is working as it should except for one issue. i have 3 differetn display layouts switching every 10 seconds. the first two work fine but the last one glitches in a weird way. the text on it disappears for a few miliseconds continuosly. mainly the last three lines. i will provide the code and some pictures.

this is the layout that gives me issues,

here is my code (there are no errors in the code):

// 2 screens, two buttons no monitor serial, everything works perfectly, motivacni quotes

#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>
#include <EEPROM.h> // For persistent storage

// Constructor for SH1106 SPI OLED
U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);

// Button pin
const int resetButtonPin = 3; // Reset button connected to pin 3
const int buttonPin = 7; // Button connected to pin 2
bool lastButtonState = LOW; // Previous button state

// Variables for cigarette counts and health
int dnesCigarettes = 0; // Cigarettes for the day
int totalCigarettes = 0; // Total cigarettes
int healthBarPixels = 0; // Pixels filled in the health bar (persistent)
int nicotineMg = 0;      // Total mg of nicotine
int tarMg = 0;           // Total mg of tar
int caloriesBurned = 0;  // Total calories burned

// Rectangle dimensions and position
const int rectX = 25;       // Start 25 pixels from the left
const int rectY = 50;       // Y position
const int rectWidth = 98;   // Width of the rectangle
const int rectHeight = 10;  // Height of the rectangle

// Timing for screen switching
unsigned long lastSwitchTime = 0; // Last time the screen switched
int currentScreen = 0;           // Tracks the current screen (0: Main, 1: Secondary, 2: New Screen)

void setup(void) {
    u8g2.begin(); // Initialize the display
  pinMode(buttonPin, INPUT_PULLUP); // Set button pin as input with pull-up resistor
  pinMode(resetButtonPin, INPUT_PULLUP); // Set reset button pin as input with pull-up resistor
}

void loop(void) {
  // Check if reset button is pressed
  if (digitalRead(resetButtonPin) == LOW) { // Reset button pressed
    totalCigarettes = 0; // Reset total count
    healthBarPixels = 0; // Reset health bar
    dnesCigarettes = 0;
    nicotineMg = 0;
    tarMg = 0;
    caloriesBurned = 0;
    delay(1000); // Debounce delay
  }

  handleButtonPress(); // Call to handle button press

  if (millis() - lastSwitchTime > 10000) {
    currentScreen = (currentScreen + 1) % 3; // Cycle between two screens
    lastSwitchTime = millis(); // Update the last switch time
  }

  if (currentScreen == 0) {
    drawMainScreen();
  } else if (currentScreen == 1) {
    drawPixelArtScreen();
  } else if (currentScreen == 2) {
    drawStatisticsScreen();
  }

  delay(100); // Small delay to avoid flickering
}

int motivationalQuoteIndex = 0; // Tracks the current quote index
const char* motivationalQuotes[] = {
  "VICE DEHTU = VICE ZAZITKU!",
  "DYCHEJ DO TOHO! JSI SAMPION!",
  "TVE PLICE SI TO ZASLOUZI!",
  "JEN TAK DAL!",
  "DOKOURIL JSI... JSI VITEZ!",
  "KAZDY POTAH SE POCITA!",
  "KOURENI (NE)ZABIJI"
};

void displayMotivationalQuote() {
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_ncenB08_tr); // Smaller font for better fit

  // Break the quote into multiple lines if needed
  const char* quote = motivationalQuotes[motivationalQuoteIndex];
  char firstLine[64] = "";
  char secondLine[64] = "";
  char thirdLine[64] = "";

  int len = strlen(quote);
  if (len > 20) { // Split intelligently by spaces
    int breakPoint = len / 2;
    while (breakPoint > 0 && quote[breakPoint] != ' ') {
      breakPoint--; // Find nearest space
    }

    strncpy(firstLine, quote, breakPoint);
    firstLine[breakPoint] = '\0'; // Null-terminate

    const char* remaining = &quote[breakPoint + 1];
    int remainingLen = strlen(remaining);

    if (remainingLen > 20) {
      int secondBreakPoint = remainingLen / 2;
      while (secondBreakPoint > 0 && remaining[secondBreakPoint] != ' ') {
        secondBreakPoint--; // Find nearest space
      }

      strncpy(secondLine, remaining, secondBreakPoint);
      secondLine[secondBreakPoint] = '\0'; // Null-terminate

      strcpy(thirdLine, &remaining[secondBreakPoint + 1]);
    } else {
      strcpy(secondLine, remaining);
    }
  } else {
    strcpy(firstLine, quote);
  }

  // Calculate x position for centering each line
  int textX1 = (128 - u8g2.getStrWidth(firstLine)) / 2;
  int textX2 = (128 - u8g2.getStrWidth(secondLine)) / 2;
  int textX3 = (128 - u8g2.getStrWidth(thirdLine)) / 2;

  // Display the first line
  u8g2.setCursor(textX1, 20); // Adjusted vertical position for first line
  u8g2.print(firstLine);

  // Display the second line if it exists
  if (strlen(secondLine) > 0) {
    u8g2.setCursor(textX2, 36); // Adjusted vertical position for second line
    u8g2.print(secondLine);
  }

  // Display the third line if it exists
  if (strlen(thirdLine) > 0) {
    u8g2.setCursor(textX3, 52); // Adjusted vertical position for third line
    u8g2.print(thirdLine);
  }

  u8g2.sendBuffer(); // Send data to the display

  delay(5000); // Show the quote for 5 seconds

  // Increment the quote index
  motivationalQuoteIndex = (motivationalQuoteIndex + 1) % 6;
}

void handleButtonPress() {
  bool currentButtonState = digitalRead(buttonPin) == LOW; // Read button state

  if (currentButtonState && !lastButtonState) { // Detect button press
    displayMotivationalQuote();
    currentScreen = 0; // Switch to main screen
    lastSwitchTime = millis(); // Reset the timer
    dnesCigarettes++; // Increment daily count
    totalCigarettes++; // Increment total count
    nicotineMg += 2; // Increment nicotine count
    tarMg += 11; // Increment tar count
    caloriesBurned += 10; // Increment calories count

    // Update health bar
    if (totalCigarettes % 20 == 0 && healthBarPixels < rectWidth - 2) {
      healthBarPixels += 1; // Add one pixel to the health bar for every 20 presses
    }
  }

  lastButtonState = currentButtonState; // Update last button state
}

void drawMainScreen() {
  u8g2.clearBuffer(); // Clear the internal memory

  // Draw "DNES" (Centered Text)
  u8g2.setFont(u8g2_font_ncenB14_tr); // Medium font
  int dnesX = (128 - u8g2.getStrWidth("DNES: 00")) / 2; // Calculate centered X position
  u8g2.setCursor(dnesX, 40);
  u8g2.print("DNES: ");
  u8g2.print(dnesCigarettes);

  // Draw "CELKEM" (Top Left)
  u8g2.setFont(u8g2_font_ncenB08_tr);
  u8g2.setCursor(0, 10);
  u8g2.print("CELKEM: ");
  u8g2.print(totalCigarettes);

  // Draw Health Bar
  u8g2.setFont(u8g2_font_ncenB08_tr); // Font for HP
  u8g2.setCursor(0, 58);             // Adjusted to align with the rectangle
  u8g2.print("HP");

  // Draw transparent rectangle (outline only)
  u8g2.drawFrame(rectX, rectY, rectWidth, rectHeight);

  // Draw filled part of the rectangle
  if (healthBarPixels > 0) {
    u8g2.drawBox(rectX + 1, rectY + 1, healthBarPixels, rectHeight - 2);
  }

  u8g2.sendBuffer(); // Transfer internal memory to display
}


void drawPixelArtScreen() {
  u8g2.clearBuffer(); // Clear the internal memory

  // Define pixel ranges for each line
  u8g2.drawHLine(22, 23, 106); // Line 23
  u8g2.drawHLine(22, 24, 106); // Line 24
  u8g2.drawHLine(21, 25, 4);   // Line 25: Part 1
  u8g2.drawHLine(112, 25, 16); // Line 25: Part 2
  u8g2.drawHLine(21, 26, 3);   // Line 26: Part 1
  u8g2.drawHLine(25, 26, 2);   // Line 26: Part 2
  u8g2.drawHLine(112, 26, 16); // Line 26: Part 3
  u8g2.drawHLine(20, 27, 1);   // Line 27: Part 1
  u8g2.drawHLine(23, 27, 3);   // Line 27: Part 2
  u8g2.drawHLine(113, 27, 15); // Line 27: Part 3
  u8g2.drawHLine(20, 28, 7);   // Line 28
  u8g2.drawHLine(113, 28, 14); // Line 28
  u8g2.drawHLine(19, 29, 2);   // Line 29: Part 1
  u8g2.drawHLine(114, 29, 14); // Line 29: Part 2
  u8g2.drawHLine(22, 30, 1);   // Line 30
  u8g2.drawHLine(113, 30, 14); // Line 30
  u8g2.drawHLine(22, 31, 3);   // Line 31
  u8g2.drawHLine(113, 31, 13); // Line 31
  u8g2.drawHLine(21, 32, 4);   // Line 32
  u8g2.drawHLine(112, 32, 15); // Line 32
  u8g2.drawHLine(20, 33, 6);   // Line 33
  u8g2.drawHLine(111, 33, 16); // Line 33
  u8g2.drawHLine(20, 34, 7);   // Line 34
  u8g2.drawHLine(111, 34, 15); // Line 34
  u8g2.drawHLine(21, 35, 3);   // Line 35
  u8g2.drawHLine(113, 35, 14); // Line 35
  u8g2.drawHLine(22, 36, 1);   // Line 36
  u8g2.drawHLine(114, 36, 14); // Line 36
  u8g2.drawHLine(22, 37, 2);   // Line 37
  u8g2.drawHLine(113, 37, 13); // Line 37
  u8g2.drawHLine(23, 38, 4);   // Line 38
  u8g2.drawHLine(112, 38, 16); // Line 38
  u8g2.drawHLine(23, 39, 6);   // Line 39
  u8g2.drawHLine(111, 39, 15); // Line 39
  u8g2.drawHLine(24, 40, 8);   // Line 40
  u8g2.drawHLine(110, 40, 17); // Line 40
  u8g2.drawHLine(22, 41, 106); // Line 41 (Bottom line)

  u8g2.sendBuffer(); // Transfer the buffer to the display
}

void drawStatisticsScreen() {
  u8g2.clearBuffer(); // Clear the internal memory

  // Adjusted Y positions for equal spacing
  int topTextY = 10; // Align top of "PRUMERNE" with "CELKEM"

  // Draw "PRUMERNE:"
  u8g2.setFont(u8g2_font_ncenB08_tr); // Medium font
  u8g2.setCursor(0, topTextY);
  u8g2.print("PRUMERNE:");
  int bottomLineY = 60; // Bottom of the last line (aligned with the rectangle's bottom)
  int lineSpacing = (bottomLineY - topTextY) / 3; // Calculate uniform spacing

  // Draw "NIKOTINU"
  u8g2.setCursor(0, topTextY + lineSpacing); // Next line
  u8g2.print(nicotineMg);
  u8g2.print("mg NIKOTINU");

  // Draw "DEHTU"
  u8g2.setCursor(0, topTextY + 2 * lineSpacing); // Next line
  u8g2.print(tarMg);
  u8g2.print("mg DEHTU");

  // Draw "KALORII"
  u8g2.setCursor(0, topTextY + 3 * lineSpacing); // Next line
  u8g2.print(caloriesBurned);
  u8g2.print(" KALORII");

  u8g2.sendBuffer(); // Transfer internal memory to display
}

Errors are not always syntactic.

Sometimes the error is in what you've told the code to do.

This is one of those times.

If you know what a beat frequency is, you know what's going on. It's an interference pattern.

Your code appears to be refreshing the screen contents 10 times a second.

The controller is refreshing the screen at a different frequency than you're updating. When those frequencies reinforce or cancel out, you're going to miss parts of the screen.

Try changing your code to only update the screen when the currentScreen changes and see what happens.

ive tried to put this under the handleButton press but it made it worse, now the first screen starts to flicker and everything dissapears completeley after a few seconds

} else if (currentScreen == 1) { // Only update statistics on drawNewScreen
      nicotineMg += 2; // Increment nicotine count
      tarMg += 11;     // Increment tar count
      caloriesBurned += 10; // Increment calorie count
    }

Hello, i have written into this forum a few times about my project already. i have one last issue with the code. i am new to coding, ive been coding for a month so i am sure i am missing some issues.

void handleButtonPress() {
  bool currentButtonState = digitalRead(buttonPin) == LOW; // Read button state

  if (currentButtonState && !lastButtonState) { // Detect button press
    displayMotivationalQuote();
    currentScreen = 0; // Switch to main screen
    lastSwitchTime = millis(); // Reset the timer
    dnesCigarettes++; // Increment daily count
    totalCigarettes++; // Increment total count

this code works perfectlu fine. i have no issues with it. but as soon as i add 3 more lines, the screen starts flickering and the code no longer works.

void handleButtonPress() {
  bool currentButtonState = digitalRead(buttonPin) == LOW; // Read button state

  if (currentButtonState && !lastButtonState) { // Detect button press
    displayMotivationalQuote(); // Show motivational quote
    currentScreen = 0; // Switch to the main screen after the quote
    lastSwitchTime = millis(); // Reset the timer
    dnesCigarettes++; // Increment daily count
    totalCigarettes++; // Increment total count
    nicotineMg += 2; // Increment nicotine count
    tarMg += 11;     // Increment tar count
    caloriesBurned += 10; // Increment calories count

i will also add the whole code if the issue may be there:

// 2 screens, two buttons no monitor serial, everything works perfectly, motivacni quotes

#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>
#include <EEPROM.h> // For persistent storage

// Constructor for SH1106 SPI OLED
U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);

// Button pin
const int resetButtonPin = 3; // Reset button connected to pin 3
const int buttonPin = 7; // Button connected to pin 2
bool lastButtonState = LOW; // Previous button state

// Variables for cigarette counts and health
int dnesCigarettes = 0; // Cigarettes for the day
int totalCigarettes = 0; // Total cigarettes
int healthBarPixels = 0; // Pixels filled in the health bar (persistent
int nicotineMg = 0;
int tarMg = 0;
int caloriesBurned = 0;

// Rectangle dimensions and position
const int rectX = 25;       // Start 25 pixels from the left
const int rectY = 50;       // Y position
const int rectWidth = 98;   // Width of the rectangle
const int rectHeight = 10;  // Height of the rectangle

// Timing for screen switching
unsigned long lastSwitchTime = 0; // Last time the screen switched
int currentScreen = 0;           // Tracks the current screen (0: Main, 1: Secondary, 2: New Screen)

void setup(void) {
    u8g2.begin(); // Initialize the display
  pinMode(buttonPin, INPUT_PULLUP); // Set button pin as input with pull-up resistor
  pinMode(resetButtonPin, INPUT_PULLUP); // Set reset button pin as input with pull-up resistor

  // Load total cigarettes and health bar pixels from EEPROM
  EEPROM.get(0, totalCigarettes);
  EEPROM.get(sizeof(totalCigarettes), healthBarPixels);
  if (totalCigarettes < 0) {
    totalCigarettes = 0; // Ensure no negative value is loaded
  }
}

void loop(void) {
  // Check if reset button is pressed
  if (digitalRead(resetButtonPin) == LOW) { // Reset button pressed
    totalCigarettes = 0; // Reset total count
    healthBarPixels = 0; // Reset health bar
    EEPROM.put(0, totalCigarettes); // Save reset values to EEPROM
    EEPROM.put(sizeof(totalCigarettes), healthBarPixels);
    delay(1000); // Debounce delay
  }


  handleButtonPress(); // Call to handle button press

  if (millis() - lastSwitchTime > 10000) {
    currentScreen = (currentScreen + 1) % 3; // Cycle between two screens
    lastSwitchTime = millis(); // Update the last switch time
  }

    if (currentScreen == 0) {
      drawMainScreen();
    } else if (currentScreen == 1) {
      drawNewScreen();
    } else if (currentScreen == 2) {
      drawPixelArtScreen();
    }

  delay(100); // Small delay to avoid flickering
}

int motivationalQuoteIndex = 0; // Tracks the current quote index
const char* motivationalQuotes[] = {
  "VICE DEHTU = VICE ZAZITKU!",
  "DYCHEJ DO TOHO! JSI SAMPION!",
  "TVE PLICE SI TO ZASLOUZI!",
  "JEN TAK DAL!",
  "KOURENI (NE)ZABIJI",
  "DOKOURIL JSI... JSI VITEZ!",
  "KAZDY POTAH SE POCITA!"
};

void displayMotivationalQuote() {
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_ncenB08_tr); // Smaller font for better fit

  // Break the quote into multiple lines if needed
  const char* quote = motivationalQuotes[motivationalQuoteIndex];
  char firstLine[64] = "";
  char secondLine[64] = "";
  char thirdLine[64] = "";

  int len = strlen(quote);
  if (len > 20) { // Split intelligently by spaces
    int breakPoint = len / 2;
    while (breakPoint > 0 && quote[breakPoint] != ' ') {
      breakPoint--; // Find nearest space
    }

    strncpy(firstLine, quote, breakPoint);
    firstLine[breakPoint] = ''; // Null-terminate

    const char* remaining = &quote[breakPoint + 1];
    int remainingLen = strlen(remaining);

    if (remainingLen > 20) {
      int secondBreakPoint = remainingLen / 2;
      while (secondBreakPoint > 0 && remaining[secondBreakPoint] != ' ') {
        secondBreakPoint--; // Find nearest space
      }

      strncpy(secondLine, remaining, secondBreakPoint);
      secondLine[secondBreakPoint] = ''; // Null-terminate

      strcpy(thirdLine, &remaining[secondBreakPoint + 1]);
    } else {
      strcpy(secondLine, remaining);
    }
  } else {
    strcpy(firstLine, quote);
  }

  // Calculate x position for centering each line
  int textX1 = (128 - u8g2.getStrWidth(firstLine)) / 2;
  int textX2 = (128 - u8g2.getStrWidth(secondLine)) / 2;
  int textX3 = (128 - u8g2.getStrWidth(thirdLine)) / 2;

  // Display the first line
  u8g2.setCursor(textX1, 20); // Adjusted vertical position for first line
  u8g2.print(firstLine);

  // Display the second line if it exists
  if (strlen(secondLine) > 0) {
    u8g2.setCursor(textX2, 36); // Adjusted vertical position for second line
    u8g2.print(secondLine);
  }

  // Display the third line if it exists
  if (strlen(thirdLine) > 0) {
    u8g2.setCursor(textX3, 52); // Adjusted vertical position for third line
    u8g2.print(thirdLine);
  }

  u8g2.sendBuffer(); // Send data to the display

  delay(5000); // Show the quote for 5 seconds

  // Increment the quote index
  motivationalQuoteIndex = (motivationalQuoteIndex + 1) % 6;
}

void handleButtonPress() {
  bool currentButtonState = digitalRead(buttonPin) == LOW; // Read button state

  if (currentButtonState && !lastButtonState) { // Detect button press
    displayMotivationalQuote(); // Show motivational quote
    currentScreen = 0; // Switch to the main screen after the quote
    lastSwitchTime = millis(); // Reset the timer
    dnesCigarettes++; // Increment daily count
    totalCigarettes++; // Increment total count
    nicotineMg += 2; // Increment nicotine count
    tarMg += 11;     // Increment tar count
    caloriesBurned += 10; // Increment calories count

    // Save total cigarettes and health bar pixels to EEPROM
    EEPROM.put(0, totalCigarettes);
    EEPROM.put(sizeof(totalCigarettes), healthBarPixels);

    // Update health bar
    if (totalCigarettes % 20 == 0 && healthBarPixels < rectWidth - 2) {
      healthBarPixels += 1; // Add one pixel to the health bar for every 20 presses
    }
  }

  lastButtonState = currentButtonState; // Update last button state
}

void drawMainScreen() {
  u8g2.clearBuffer(); // Clear the internal memory

  // Draw "DNES" (Centered Text)
  u8g2.setFont(u8g2_font_ncenB14_tr); // Medium font
  int dnesX = (128 - u8g2.getStrWidth("DNES: 00")) / 2; // Calculate centered X position
  u8g2.setCursor(dnesX, 40);
  u8g2.print("DNES: ");
  u8g2.print(dnesCigarettes);

  // Draw "CELKEM" (Top Left)
  u8g2.setFont(u8g2_font_ncenB08_tr);
  u8g2.setCursor(0, 10);
  u8g2.print("CELKEM: ");
  u8g2.print(totalCigarettes);

  // Draw Health Bar
  u8g2.setFont(u8g2_font_ncenB08_tr); // Font for HP
  u8g2.setCursor(0, 58);             // Adjusted to align with the rectangle
  u8g2.print("HP");

  // Draw transparent rectangle (outline only)
  u8g2.drawFrame(rectX, rectY, rectWidth, rectHeight);

  // Draw filled part of the rectangle
  if (healthBarPixels > 0) {
    u8g2.drawBox(rectX + 1, rectY + 1, healthBarPixels, rectHeight - 2);
  }

  u8g2.sendBuffer(); // Transfer internal memory to display
}



void drawNewScreen() {
  u8g2.clearBuffer(); // Clear the internal memory

  // Adjusted Y positions for equal spacing
  int topTextY = 10; // Align top of "DNES" with "CELKEM"
  int bottomLineY = 60; // Bottom of the last line (aligned with the rectangle's bottom)
  int lineSpacing = (bottomLineY - topTextY) / 3; // Calculate uniform spacing

  // Draw "DNES:"
  u8g2.setFont(u8g2_font_ncenB08_tr); // Medium font
  u8g2.setCursor(0, topTextY);
  u8g2.print("PRUMERNE:");

  // Draw "% NIKOTINU"
  u8g2.setCursor(0, topTextY + lineSpacing); // Next line
  u8g2.print("0mg NIKOTINU");

  // Draw "DEHETU"
  u8g2.setCursor(0, topTextY + 2 * lineSpacing); // Next line
  u8g2.print("0mg DEHETU");

  // Draw "KALORII"
  u8g2.setCursor(0, topTextY + 3 * lineSpacing); // Next line
  u8g2.print("0 KALORII");

  u8g2.sendBuffer(); // Transfer internal memory to display
}

void drawPixelArtScreen() {
  u8g2.clearBuffer(); // Clear the internal memory

  // Define pixel ranges for each line
  u8g2.drawHLine(22, 23, 106); // Line 23
  u8g2.drawHLine(22, 24, 106); // Line 24
  u8g2.drawHLine(21, 25, 4);   // Line 25: Part 1
  u8g2.drawHLine(112, 25, 16); // Line 25: Part 2
  u8g2.drawHLine(21, 26, 3);   // Line 26: Part 1
  u8g2.drawHLine(25, 26, 2);   // Line 26: Part 2
  u8g2.drawHLine(112, 26, 16); // Line 26: Part 3
  u8g2.drawHLine(20, 27, 1);   // Line 27: Part 1
  u8g2.drawHLine(23, 27, 3);   // Line 27: Part 2
  u8g2.drawHLine(113, 27, 15); // Line 27: Part 3
  u8g2.drawHLine(20, 28, 7);   // Line 28
  u8g2.drawHLine(113, 28, 14); // Line 28
  u8g2.drawHLine(19, 29, 2);   // Line 29: Part 1
  u8g2.drawHLine(114, 29, 14); // Line 29: Part 2
  u8g2.drawHLine(22, 30, 1);   // Line 30
  u8g2.drawHLine(113, 30, 14); // Line 30
  u8g2.drawHLine(22, 31, 3);   // Line 31
  u8g2.drawHLine(113, 31, 13); // Line 31
  u8g2.drawHLine(21, 32, 4);   // Line 32
  u8g2.drawHLine(112, 32, 15); // Line 32
  u8g2.drawHLine(20, 33, 6);   // Line 33
  u8g2.drawHLine(111, 33, 16); // Line 33
  u8g2.drawHLine(20, 34, 7);   // Line 34
  u8g2.drawHLine(111, 34, 15); // Line 34
  u8g2.drawHLine(21, 35, 3);   // Line 35
  u8g2.drawHLine(113, 35, 14); // Line 35
  u8g2.drawHLine(22, 36, 1);   // Line 36
  u8g2.drawHLine(114, 36, 14); // Line 36
  u8g2.drawHLine(22, 37, 2);   // Line 37
  u8g2.drawHLine(113, 37, 13); // Line 37
  u8g2.drawHLine(23, 38, 4);   // Line 38
  u8g2.drawHLine(112, 38, 16); // Line 38
  u8g2.drawHLine(23, 39, 6);   // Line 39
  u8g2.drawHLine(111, 39, 15); // Line 39
  u8g2.drawHLine(24, 40, 8);   // Line 40
  u8g2.drawHLine(110, 40, 17); // Line 40
  u8g2.drawHLine(22, 41, 106); // Line 41 (Bottom line)

  u8g2.sendBuffer(); // Transfer the buffer to the display
}

What type of arduino fo you have?
How much ram is used by glibal variables?
This number is reported after successfull compilation...
Those 3 lines seem to have no errors...

This is not a null terminate...
That would be '\0' or ""...?

Not handy to have this ' in your comment...
It upsets the colors of the forum code viewer..

i am using an arduino uno R3 and the global variables are: Global variables use 1726 bytes (84%) of dynamic memory, leaving 322 bytes for local variables. Maximum is 2048 bytes.

ive also changed the null to /0 as you said in another comment. i am really sorry i am trying to figure this all out on the go, its my first time writing an actual code

You are in the danger zone of ram shortage...
The u2gs library may well use significant heap memory...
There are special functions to print the available ram... i suppose it is a good idea to try that...

Be more observant. The character is '\0'

This whole lot can be written in maybe 10 lines of code using for loops...

You may try to replace print(" by print(F".
That will put your strings into progmem.

Just for testing you could try with just 1 font.

I have merged the topics, as requested.

@thenextsaint, in the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.