Coder Social home page Coder Social logo

ssd1306's Introduction

C Library for SSD1306 0.96" OLED display

SSD1306 Description

Detailed information are described in Datasheet SSD1306.

Library

C library is aimed for driving 0.96" OLED display with SSD1306 driver 128x64 or 128x32 version through TWI's (I2C). Settings for particular versions:

  • 128x64 version
    • command argument SSD1306_SET_MUX_RATIO set to 0x3F (ssd1306.c)
    • command argument SSD1306_COM_PIN_CONF set to 0x12 (ssd1306.c)
    • END_PAGE_ADDR set to 7 (ssd1306.h)
  • 128x32 version
    • command argument SSD1306_SET_MUX_RATIO set to 0x1F (ssd1306.c)
    • command argument SSD1306_COM_PIN_CONF set to 0x02 (ssd1306.c)
    • END_PAGE_ADDR set to 3 (ssd1306.h)

Versions

  • 1.0 - basic functions. The first publication.
  • 2.0 - more changes:
  • 3.0 - simplified alphanumeric version
    • displaying alphanumeric characters
    • for one display applicable
    • only few RAM bytes consumption
    • !!! no graphic functions like drawLine

Dependencies

Font.c can be modified according to application requirements with form defined in font.c. Maximal permissible horizontal dimension is 8 bits.

Usage

Prior defined for MCU Atmega328p / Atmega8 / Atmega16. Need to be carefull with TWI ports definition.

PORT Atmega16 Atmega8 / Atmega328
SCL PC0 PC5
SDA PC1 PC4

Picture of hardware connection

Hardware connection

Tested

Library was tested and proved with 0.96โ€ณ 128x64 and 0.91" 128x32 OLED Display (SSD1306 driver) and Arduino UNO R3. The Arduino was without a bootloader installed, it was only raw Atmega328P microcontroller. Communication was done through I2C (TWI) interface of Arduino UNO R3. This hardware configuration was chosen for simplicity.

Init OLED Sequence

Init sequence OLED display was defined mainly according to page 64 (next to last page) of Datasheet SSD1306.

Flowchart

// +---------------------------+
// |      Software Reset       |  // not tested yet, @source https://github.com/SmingHub/Sming/issues/501
// +---------------------------+
// |           0xE4            |
// +---------------------------+
//              ||
// +---------------------------+
// |        DISPLAY OFF        |
// +---------------------------+
// |           0xAE            |
// +---------------------------+
//              ||
// +---------------------------+
// |       Set MUX Ratio       |
// +---------------------------+
// |           0xA8            |
// |           0x3F            |
// +---------------------------+
//              ||
// +---------------------------+
// |   Set Memory Addr  Mode   |
// +---------------------------+
// |           0x20            |
// |           0x00            |
// +---------------------------+
//              ||
// +---------------------------+
// |      Set Start Line       |
// +---------------------------+
// |           0x40            |
// +---------------------------+
//              ||
// +---------------------------+
// |    Set Display Offset     |
// +---------------------------+
// |           0xD3            |
// |           0x00            |
// +---------------------------+
//              ||
// +---------------------------+
// |     Set Segment Remap     |
// +---------------------------+
// |       0xA0 or 0xA1        |
// +---------------------------+
//              ||
// +---------------------------+
// |   Set COM Output Scan     |
// |        Direction          |
// +---------------------------+
// |       0xC0 or 0xC8        |
// +---------------------------+
//              ||
// +---------------------------+
// |   Set COM Pins hardware   |
// |       configuration       |
// +---------------------------+
// |           0xDA            |
// |      0x12 for 128x64      |
// |      0x02 for 128x32      |
// +---------------------------+
//              ||
// +---------------------------+
// |   Set Contrast Control    |
// +---------------------------+
// |           0x81            |
// |           0x7F            |
// +---------------------------+
//              ||
// +---------------------------+
// | Disable Entire Display On |
// +---------------------------+
// |           0xA4            |
// +---------------------------+
//              ||
// +---------------------------+
// |    Set Normal Display     |
// +---------------------------+
// |           0xA6            |
// +---------------------------+
//              ||
// +---------------------------+
// |  Set OSC Frequency Fosc   |
// +---------------------------+
// |           0xD5            |
// |           0x80            |
// +---------------------------+
//              ||
// +---------------------------+
// |     Enable charge pump    |
// |         regulator         |
// +---------------------------+
// |           0x8D            |
// |           0x14            |
// +---------------------------+
//              ||
// +---------------------------+
// |     Deactivate Scroll     |
// +---------------------------+
// |           0x2E            |
// +---------------------------+
//              ||
// +---------------------------+
// |        Display On         |
// +---------------------------+
// |           0xAF            |
// +---------------------------+

Functions

Demonstration version v1.0.0

Demonstration version v2.0.0

Demonstration version v3.0.0

Acknowledgement

Links

ssd1306's People

Contributors

matiasus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ssd1306's Issues

Difficulties controlling the SSD1306 from AZ-Delivery 0,91 Zoll I2C Oled 128x32

Hi, I'm new to this forum but not to hardware/software, still I spent weeks on understanding the controller and how to control it.
I have read loads of how to initiate the controller with all kinds of settings which you can't find in the datasheet and still having problem.

I'm using ARM(NXP) and I2C(400Khz), and bare metal code. I have the same I2C routines that I have been using for 10 years so I think they are working, but now to one of many problems.

I initiate the SSD1306 to page mode setting......and all that, when I try to send text at Page 0(0xB0) with LSB=0x00 and MSB=0x10, should be Colum 0 at page 0, then I see the text I want to display, then I set page 0 and colum 0 again and try to clear everything, nothing happens. I have verified all one bytes command and they work all fine. Regarding any timing issues I normally step with debugger and there is no difference by running with breakpoints or not. I have seen so many interpretations regarding how to send CMND/DATA, but I'm using it like this ADR_SSD1306 = 0x78, // 0111 10+SA0(D/#C)+W
mDATA_ = 0xC0, // 1100 0000 multiple Data
mCMND_ = 0x80, // 1000 0000 multiple Command
sDATA_ = 0x40, // 0100 0000 single Data
sCMND_ = 0x00 // 0000 0000 single Command
So, does any have any ideas about this and make my day ?
Cheers
CK

Data Memory Usage

I use ATMEGA328P and when I build the application, it uses about 1000Bytes Data Memory (~50%). I would like to ask you, if I do something wrong or is that (SSD-LIB) usually that big (DATA Memory Usage).

Kind Regards

SSD1306_DrawPixel parameter check.

if ((x > MAX_X) && (y > MAX_Y)) {

I think there is an issue with the parameter checking in this routine?

  if ((x > MAX_X) && (y > MAX_Y)) {
    // out of range
    return SSD1306_ERROR;
  }

It should be '||' as we need both parameters to be in range?

Not working with 128X32 .96" Display

I'm attempting to use your library with the 128X32 .91" display. I have tested it by loading the Adafruit sketch in Arduino and it works as expected. Moving to native C in Atmel Studio with this library, the output sometimes resembles text but is too small and the top is cut off. Any thoughts on what to check?
Setup:
#define SSD1306_SET_MUX_RATIO 0x1F
#define SSD1306_COM_PIN_CONF 0x02
#define END_PAGE_ADDR 3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.