This library allows to display text on an OLED display controlled by the SSD1306. It is possible to use both sizes (128x64 and 128x32).
In contrast to other display drivers, this driver does not hold a buffer for execution of paint operations in memory, so the very limited SRAM on Arduino boards stays available for other needs.
Therefore enhanced paint operations (circles, flood fill, lines etc.) are not possible directly. The library is designed for displaying text.
Three fonts are available:
The library uses the Arduino wire library.
The OLED SSD1306 must be connected via I2C (aka TwoWire, TWI or simply Wire).
Arduino | Display |
---|---|
+5V | VCC |
GND | GND |
SDA | SDA |
SCL | SCL |
An instance of the class "SimpleOLED" is needed. As first argument, the constructor expects the I2C address of the display (usually 0x3C), followed by the width (128) and the height (32 or 64) in pixels.
#define DISPLAY_I2C_ADDR 0x3C
#define DISPLAY_WIDTH 128
#define DISPLAY_HEIGHT 32
SimpleOLED Display(DISPLAY_I2C_ADDR, DISPLAY_WIDTH, DISPLAY_HEIGHT);
This function must be called to initialise the display and switch it on.
Display.begin();
This function switches off the display.
Display.end();
This function clears the whole content of the display and sets the cursor to the top left corner.
Display.clear();
This function changes the font for the following operations. Possible fonts are "default", "Topaz" and "C64". The font height can be set with the parameter "DoubleHeight" - false means 8 pixels, true means 16 pixels.
After changing the font, the cursor position must be set again (see setCursor).
Display.setFont("Topaz", true);
This function sets the cursor position for the following print operations. The values are in characters, not in pixels.
Display.setCursor(8, 1);
This function writes a string to the display. The only special character is "\n", which performs a carriage return and a line feed.
Display.print("Hello World!");
This function works exactly like the print function, but it adds a carriage return / line feed at the end of the line.
Display.println("Hello World!");
Version: 5.2
© 1996-2024 by Stefan Trippler (stef2024@[REM0VE]trippler.de)
Impressum