Ssd1306 OLED appears to be stuck on single line

trying to get to grips with the ssd1306 OLED display on the simulator on https://wokwi.com/ as research for a future project. I'm using an ESP32 controller and working from this example ESP32 OLED Display with Arduino IDE | Random Nerd Tutorials.

I'm currently just trying drawing to draw a simple diaganol line but the it appears to be wrapping around the first text line of the screen. I added an 'X' on the end to illustrate the height restriction.

If I use the drawCircle, drawPixel or drawChar functions the result is same. Weirdly the drawRect function does appear to work. Here is my circuit:

And my code:

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define LED 14

void setup() {
  Serial.begin(115200);

  pinMode(LED, OUTPUT);
  
  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    digitalWrite(LED, LOW);
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  } else {
    digitalWrite(LED, HIGH);
  }

  // Clear the buffer
  display.clearDisplay();

  // Draw a single pixel in white
  //display.drawPixel(10, 10, WHITE);
  
  display.setTextSize(1);      // Normal 1:1 pixel scale
  display.setTextColor(WHITE); // Draw white text
  display.setCursor(0, 0);     // Start at top-left corner
  display.cp437(true);         // Use full 256 char 'Code Page 437' font

  display.print("Initialising...");

  display.display();
  delay(1000);

  //testdrawrect();
  //testdrawcircle();
  //testdrawchar();
  //testdrawline();

  display.clearDisplay();
  //display.drawPixel(0, 32, WHITE);
  display.drawLine(0, 0, 64, 63, SSD1306_WHITE);
  display.setCursor(65, 0);
  display.print("X");
  display.display();
}

void loop() {
  // put your main code here, to run repeatedly:
  
}

Any Suggestions?

When I get an OLED I write a test program to see how many pixels I actually get across and down before trying to program the actual display.

Are you trying to draw a diagonal line from corner to corner of the display?

Yes, I'm just trying to get a line from corner to corner at the moment but it appears to be reaching the bottom of what would be a character line then looping back round to the top.

I have not used the library for quite a while, so I had to look stuff up.

In the Adafruit GFX library is this function:

/**************************************************************************/
/*!
   @brief    Draw a line
    @param    x0  Start point x coordinate
    @param    y0  Start point y coordinate
    @param    x1  End point x coordinate
    @param    y1  End point y coordinate
    @param    color 16-bit 5-6-5 Color to draw with
*/
/**************************************************************************/
void Adafruit_GFX::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
                            uint16_t color) {
  // Update in subclasses if desired!
  if (x0 == x1) {
    if (y0 > y1)
      _swap_int16_t(y0, y1);
    drawFastVLine(x0, y0, y1 - y0 + 1, color);
  } else if (y0 == y1) {
    if (x0 > x1)
      _swap_int16_t(x0, x1);
    drawFastHLine(x0, y0, x1 - x0 + 1, color);
  } else {
    startWrite();
    writeLine(x0, y0, x1, y1, color);
    endWrite();
  }
}

Hopefully that helps.

Adafruit-GFX-Library/Adafruit_GFX.cpp at master · adafruit/Adafruit-GFX-Library (github.com)

Try running the example code provided by Adafruit in the library. It is already programmed for you and it does text diagonal lines, text sizes, and more. See if that works

I am sure that it will be no consolation to you, but when I run your code it draws a diagonal line across the screen as expected

I ran the same code on a simulated arduino and it worked as expected. Possibly the simulater just doesn't work right for the ESP32. I've got the actual display and controller arriving later this week so wil give it a go with the real thing.