Skip to content

untergeekDE/OLED_I2C_128x64_Monochrome_Library

 
 

Repository files navigation

OLED Library

This is a simple, lightweight library for displaying text info in three character sizes on an 0,96" monochrome organic liquid crystal display (128x64 pixels) It has been tested with the following device: - 0,96" I2C OLED, Manufacturer: Heltec-Taobao - Teensy 3.2

Watch it in action here on Youtube. Used for a small MIDI controller project: A Teensy-Based Midi Controller.

If this library is not for you, you may try the Adafruit_SSD1306 library - does the same things more consistently,

Forked from a project by deloarts because I built my own character enlargement routines into it - using a small and simple 8x8 pixel font, it can display nice, readable characters in three sizes 1x, 2x, and 3x (i.e. with up to 24x24px).

TODO:

  • Replace CP437 font with a CP1252 font and...
  • ...add println() functionality to interpret the most used utf-8 chars (this is the way the Arduino IDE stores umlauts)
  • Clean up and all that

My blog can be found at https://www.untergeek.de

For further information on deloarts' original project, please visit:

How to use it

  • Download all files as ZIP
  • In the Arduino/Teensyduino IDE, select "Sketch/Add library.../Select ZIP". Add the library
  • Add <OLED_I2C_128x64_Monochrome.h> to your sketch
  • The library creates an object called oled - the first thing to do is to call the method oled.initialize();

oled.methods - The commands

	void initialize();
	void sendCommand(byte Command);
	void sendData(byte Data);
	void printChar(byte Char);
	void printChar(byte Char, byte PosX, byte PosY); 
	void printString(const byte *Data, byte PosX = 255, byte PosY = 255);
	void printNum(signed char Data);
	void printNum(char Data, byte PosX, byte PosY);
	void printHex(byte Data);
	void drawBitmap(const byte *Bitmaparray, byte PosX, byte PosY, byte Width, byte Height);
	void clearDisplay();
	void setPos(byte PosX, byte PosY);
	void setCursor(byte PosX, byte PosY);
	void setBlackBackground();
	void setWhiteBackground();
	void setDisplayOff();
	void setDisplayOn();
	void setPageMode();
	void setHorizontalMode();
	void setBrightness(byte Brightness);
	void rotateDisplay180();
	void setFontSize(byte f);
	void invert(boolean f); 
	byte px, py, fontsize;

The additional functions of this library

Compared with deloarts' project, these additional methods exist:

  • oled.fontsize = f with f in {1, 2, 3}
  • oled.invert(true) to print black characters on white ground
  • oled.printNum(byte) - print three-digit values from -99 to 127 -> will rename that to oled.printByte
  • oled.printHex(byte) - print hexadecimal values
  • oled.px and oled.py for the cursor position, can be set by oled.setCursor()
  • oled.setPos is an internal method to set the graphics cursor

About

Arduino: A library for a 0,96" OLED display.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • C++ 63.2%
  • C 36.8%