SSD1306-AVR

Simple SSD1306 library for AVR microcontrollers.

  • Owner: tibounise/SSD1306-AVR
  • Platform:
  • License::
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

SSD1306-AVR

SSD1306-AVR is a C++ library for using SSD1306, 128x64, monochrome OLED displays. Currently only the I2C version of the display is supported.

The I2C address of the display is set up in SSD1306.h :

#define SSD1306_DEFAULT_ADDRESS 0x78

The library is written in pure C++. You'll only need avr-libc, Arduino framework is not needed.

This library is released under a VERY permissive license. Do anything with it, but if something goes wrong, it is YOUR problem (= NO WARRANTY AT ALL).

Example code (no framebuffer used)

#include <stdint.h>
#include "SSD1306.h"

int main(void) {
    // This is our buffer
    // Each byte = 8 pixels on the screen
    uint8_t buffer[1024];

    // Only two lines of code to initiate the driver
    // and to send our framebuffer
    SSD1306 myDisplay;
    myDisplay.sendFramebuffer(buffer);

    // Hardware function to reverse the pixels
    // (swap black and white pixel)
    myDisplay.invert(1);
    // Revert back to normal display
    myDisplay.invert(0);

    return 0;
}

Another example code (using the framebuffer)

#include <stdint.h>
#include "Framebuffer.h"

int main(void) {
    Framebuffer fb;

    fb.drawRectangle(1,1,126,62);
    fb.drawRectangle(3,3,124,60);
    fb.drawRectangle(5,5,122,58);
    fb.drawRectangle(7,7,120,56);
    fb.drawRectangle(9,9,118,54);
    fb.drawRectangle(11,11,116,52);
    fb.drawRectangle(13,13,114,50);
    
    fb.show();

    return 0;
}

As you can see the framebuffer API is quite easy to understand.

Images !

You can display images using the Framebuffer, though you will need to convert those images using Esther.

#include <stdint.h>
#include <avr/pgmspace.h>
#include "Framebuffer.h"

const uint8_t image[] PROGMEM = {
    ...
};

int main(void) {

    Framebuffer fb;

    fb.drawBitmap(image,64,128,0,0);
    
    fb.show();

    return 0;
}

SSD1306 simulator

It is very experimental, maybe not usefull.

The simulator in action

There are some example programs using the simulator, in /examples/. Compile the simulator (requires SDL2) and the example program, then run your example program like this :

./examples/example1/example1, ./simulator/simulator

Looking for your support

If you would like to see 128x32 displays (or any other I2C SSD1306-based displays) supported by my library, please do a donation, so that I could buy one of those displays to improve my library.

I currently accept PayPal and Bitcoin donations.

Main metrics

Overview
Name With Ownertibounise/SSD1306-AVR
Primary LanguageC++
Program languageC++ (Language Count: 4)
Platform
License:
所有者活动
Created At2015-01-15 08:44:52
Pushed At2017-06-17 04:33:06
Last Commit At2016-02-10 17:07:20
Release Count0
用户参与
Stargazers Count83
Watchers Count6
Fork Count16
Commits Count24
Has Issues Enabled
Issues Count3
Issue Open Count3
Pull Requests Count0
Pull Requests Open Count1
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private