Skip to content

Cannot Display Text - ESP32_Lora_V4 #237

@jlt206

Description

@jlt206

Having tried most of the exmples for Arduino, using the Arduino IDE and Platform.IO, I have not been able to get the display to output text to the display. I'm not sure this is the correct driver even, but it the most common used in the examples. So I'm thinking it must be something silly, maybe?

#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET RST_OLED
#define OLED_ADDRESS 0x3C
#define OLED_WIDTH 128
#define OLED_HEIGHT 64

Adafruit_SSD1306 display(OLED_WIDTH, OLED_HEIGHT, &Wire, OLED_RESET);

void drawTestScreen(uint8_t step)
{
display.clearDisplay();

display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);

display.setCursor(0, 0);
display.println("HT OLED Test");

display.drawRect(2, 12, 124, 50, SSD1306_WHITE);
display.drawLine(2, 28, 126, 28, SSD1306_WHITE);
display.drawLine(64, 12, 64, 62, SSD1306_WHITE);

if (step == 0)
{
display.setCursor(10, 18);
display.println("Screen OK");
display.setCursor(10, 36);
display.println("Text test");
}
else if (step == 1)
{
display.setCursor(10, 18);
display.println("Shapes test");
display.fillRect(18, 36, 30, 12, SSD1306_WHITE);
display.setCursor(56, 36);
display.print("BOX");
}
else
{
display.setCursor(10, 18);
display.println("Wiring test");
display.fillCircle(48, 48, 8, SSD1306_WHITE);
display.setCursor(64, 42);
display.println("OK");
}

display.display();
}

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

pinMode(Vext, OUTPUT);
digitalWrite(Vext, HIGH);
delay(50);

Wire.begin(SDA_OLED, SCL_OLED);

if (!display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDRESS))
{
Serial.println("SSD1306 init failed");
while (true)
{
delay(1000);
}
}

Serial.println("OLED initialized");
drawTestScreen(0);
}

void loop()
{
static uint8_t step = 0;
static unsigned long lastUpdate = 0;

if (millis() - lastUpdate >= 2000)
{
lastUpdate = millis();
step = (step + 1) % 3;
drawTestScreen(step);
Serial.print("OLED step: ");
Serial.println(step);
}

delay(20);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions