Page 1 of 1

ESP8266 oled display and inverted text

PostPosted: Fri Oct 15, 2021 2:30 pm
by Romek
Hi everyone,
I am struggling to solve how to display inverted text if i use custom fonts. With regular font it works, but font size "display.setTextSize(1);" or "display.setTextSize(2);" is too small or too big for me. So my code is following:
Code: Select all#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

#include <Fonts/FreeSerif9pt7b.h>

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {

  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));

  display.setTextColor(BLACK,WHITE);  // <<-- This is supposed to be inverted text, but it does not show anything on display.....
  display.setCursor(0, 30);
  display.println("Hello, world!");

void loop() {

Any ideas how to make it work? I am to a programmer, just hobbyist....