128x64 OLED SSD1306

Driver and demo code for the generic SSD1306 type displays
Share this object
<

Overview

Content

This object was created by JonnyMac at the Parallax forums.
I've added some P1 SPIN demo code below to show how to use it.

spin
{{ Quick test of an 128x64 OLED display with JonnyMac's jm_ssd1306_128x64_ez.spin object }} ' ---------------------------------------------------------------------------------------------------------------- CON { timing } _clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz _xinfreq = 5_000_000 ' ---------------------------------------------------------------------------------------------------------------- CON { pins } OLED_CS = 7 OLED_RST = 9 OLED_DC = 8 OLED_CLK = 6 OLED_DATA = 4 ' ---------------------------------------------------------------------------------------------------------------- OBJ { code objects / drivers } oled : "jm_ssd1306_128x64_ez.spin" ' ---------------------------------------------------------------------------------------------------------------- PUB Main ' #1, FONT_NORM, FONT_WIDE, FONT_BIG ' font sizes ' #0, PIXEL_OFF, PIXEL_ON, PIXEL_XOR ' pixel styles ' oled.startx(rstpin, dcpin, cspin, dopin, clkpin) ' start object ' oled.str(p_str, size, style) ' write string to display ' oled.goto_xy(column, row) ' move cursor to xy position ' Start the OLED driver oled.startx(OLED_RST, OLED_DC, OLED_CS, OLED_DATA, OLED_CLK) oled.enable(true) oled.clear ' Move to column, row. Then write some text! oled.goto_xy(0, 0) oled.str(string(" Hello! "), oled#FONT_BIG, oled#PIXEL_ON ) oled.goto_xy(0, 2) oled.str(string("12345678"), oled#FONT_BIG, oled#PIXEL_ON ) oled.goto_xy(0, 4) oled.str(string("ABCDEFGH"), oled#FONT_BIG, oled#PIXEL_ON ) oled.goto_xy(0, 6) oled.str(string("INVERTME"), oled#FONT_BIG, oled#PIXEL_ON ) oled.goto_xy(0, 6) oled.str(string("INVERTME"), oled#FONT_BIG, oled#PIXEL_OFF ) ' Repeat endlessly to prevent IO pins changing state repeat ' forever waitcnt(0)

Downloads  
Zip archive download

Leave a Reply