Coder Social home page Coder Social logo

adafruit / adafruit_ssd1306 Goto Github PK

View Code? Open in Web Editor NEW
1.7K 1.7K 962.0 503 KB

Arduino library for SSD1306 monochrome 128x64 and 128x32 OLEDs

Home Page: http://www.adafruit.com/category/63_98

License: Other

C++ 77.38% C 19.90% Makefile 0.91% Python 1.35% CMake 0.45%
arduino-library

adafruit_ssd1306's Introduction

Adafruit_SSD1306 Build StatusDocumentation

This is a library for our Monochrome OLEDs based on SSD1306 drivers

Pick one up today in the adafruit shop! ------> http://www.adafruit.com/category/63_98

These displays use I2C or SPI to communicate, 2 to 5 pins are required to interface.

Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries, with contributions from the open source community. Scrolling code contributed by Michael Gregg. Dynamic buffer allocation based on work by Andrew Canaday. BSD license, check license.txt for more information. All text above must be included in any redistribution

Preferred installation method is to use the Arduino IDE Library Manager. To download the source from Github instead, click "Clone or download" above, then "Download ZIP." After uncompressing, rename the resulting folder Adafruit_SSD1306. Check that the Adafruit_SSD1306 folder contains Adafruit_SSD1306.cpp and Adafruit_SSD1306.h.

You will also have to install the Adafruit GFX library which provides graphics primitves such as lines, circles, text, etc. This also can be found in the Arduino Library Manager, or you can get the source from https://github.com/adafruit/Adafruit-GFX-Library

Changes

Pull Request: (November 2021)

  • Added define SSD1306_NO_SPLASH to opt-out of including splash images in PROGMEM and drawing to display during begin.

Pull Request: (September 2019)

  • new #defines for SSD1306_BLACK, SSD1306_WHITE and SSD1306_INVERSE that match existing #define naming scheme and won't conflict with common color names
  • old #defines for BLACK, WHITE and INVERSE kept for backwards compat (opt-out with #define NO_ADAFRUIT_SSD1306_COLOR_COMPATIBILITY)

Version 1.2 (November 2018) introduces some significant changes:

  • Display dimensions are now specified in the constructor...you no longer need to edit the .h file for different screens (though old sketches can continue to work that way).
  • SPI transactions are used and SPI bitrate can be specified (both require Arduino 1.6 or later).
  • SPI and Wire (I2C) interfaces other than the defaults are supported.

Compatibility

MCU Tested Works Doesn't Work Not Tested Notes
Atmega328 X
Atmega32u4 X
Atmega2560 X
ESP8266 X Change OLED_RESET to different pin if using default I2C pins D4/D5.
ESP32 X
ATSAM3X8E X
ATSAMD21 X
Intel Curie X
WICED X No hardware SPI - bitbang only
ATtiny85 X
Particle X
  • ATmega328 : Arduino UNO, Adafruit Pro Trinket, Adafruit Metro 328, Adafruit Metro Mini
  • ATmega32u4 : Arduino Leonardo, Arduino Micro, Arduino Yun, Teensy 2.0, Adafruit Flora, Bluefruit Micro
  • ATmega2560 : Arduino Mega
  • ESP8266 : Adafruit Huzzah
  • ATSAM3X8E : Arduino Due
  • ATSAMD21 : Arduino Zero, M0 Pro, Adafruit Metro Express, Feather M0
  • ATtiny85 : Adafruit Gemma, Arduino Gemma, Adafruit Trinket
  • Particle: Particle Argon

adafruit_ssd1306's People

Contributors

470mr0f1 avatar andydoro avatar ausi avatar billydonahue avatar bmoniey avatar caternuson avatar evaherrada avatar facchinm avatar fingolfin avatar flywire avatar focalintent avatar jarruda avatar ladyada avatar layerde avatar makermelissa avatar microbuilder avatar montoyamoraga avatar mzero avatar norpchen avatar paintyourdragon avatar palmstroemen avatar paulstoffregen avatar plocher avatar rgiese avatar siddacious avatar tdicola avatar tyeth avatar waynepiekarski avatar wecassidy avatar zwettekop 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  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  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  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

adafruit_ssd1306's Issues

Invalid Vcomh deselect level register value 0x40

SSD1306 datasheet https://www.adafruit.com/datasheets/SSD1306.pdf describes on page 32:

"Set VCOMH Deselect Level" register describes for bits [6:4]:
000b 00h ~ 0.65 x VCC
010b 20h ~ 0.77 x VCC (RESET)
011b 30h ~ 0.83 x VCC

The SSD1306 display initialization configures Vcomh register value 0x40 which is invalid:
ssd1306_command(SSD1306_SETVCOMDETECT); // 0xDB
ssd1306_command(0x40); // <- Invalid

This is copied to/from many other drivers such as u8glib. What's the reason to use value 0x40?

Library fails to set correct page count for 128x32 display

Hi,
I was looking at your library while trying to make my own BeagleBone SSD1306 controller based on the datasheet. I think I discovered a bug in your code though, but I haven't actually tested this out on an Arduino.

At this line, you have a comment wondering why you need to write a whole lot of blank pixels to the display after the normal set of pixels.
https://github.com/adafruit/Adafruit_SSD1306/blob/master/Adafruit_SSD1306.cpp#L357

The answer is because you haven't set the display size correctly in your initialisation code. On the 128x32 board, since it's half-height, you need to set the page range to be 0-3, instead of the default 0-7.

In command-bytes, this is: 0x22 0x00 0x03

Cheers,
Toby

Add support for HUZZAH ESP8266 Breakout

There's branch of this library ( https://github.com/somhi/ESP_SSD1306 ) but I'm having a hard time getting the Huzzah ESP8266 Breakout and the Monochrome 1.3" 128x64 OLED graphic display (https://www.adafruit.com/products/938) to work with that library.

If there are some good resources available I'd take that as a starting point.

This persons claims to have success but I can't repeat his setup...

https://bagaloozy.wordpress.com/2015/07/14/cutting-the-cord-epg-getting-the-ssd1306sh1106-oled-working-with-esp8266/

Thanks

compatibility with mpu6050

Hello,

I use a 128x64 oled with arduino uno and it works perfectly.

I use a GY521 with freeimu at the same arduino (even installed parallel to the oled) and it works perfectly.

So both components work perfectly even when they are installed electrically parallel to each other.

But when I want to use IMU data to modify screen content (I comment in adafruit library and use the display) at the same time as my freeimu i simply don't get ypr values. some other raw values seem to be not affected...

As I'm totally new to Arduino, I2C,... could there be any incompatibility problems ?

best regards

M

incompatibility with SoftwareSerial

As soon as I instantiate a SoftwareSerial object, my OLED display doesn't work anymore.
I tried different pins for the SoftwareSerial to avoid hidden interrupt conflicts.
Is this a known problem?

No output on pins A0-A4 on M0 Pro

I have just switched from an Arduino Uno to a M0 Pro, using a SSD1306 128x64. On the Uno the display worked fine with the following settings:


#define OLED_MOSI   14 // Mapped to A0
#define OLED_CLK   15
#define OLED_DC    16
#define OLED_CS    17
#define OLED_RESET 18 // Mapped to A4

Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

But on the M0 Pro this does not work. All the pins are fixed at 3.3V. I have tried remapping the display to OLED_MOSI 2 [...] OLED_RESET 6 and there it works.

I localized some interesting code in Adafruit_SSD1306.h:

#if defined(__SAM3X8E__)
 typedef volatile RwReg PortReg;
 typedef uint32_t PortMask;
 #define HAVE_PORTREG
#elif defined(ARDUINO_ARCH_SAMD)
// not supported
#elif defined(ESP8266) || defined(ARDUINO_STM32_FEATHER)
  typedef volatile uint32_t PortReg;
  typedef uint32_t PortMask;
#else
  typedef volatile uint8_t PortReg;
  typedef uint8_t PortMask;
 #define HAVE_PORTREG
#endif

Especially the "not supported" comment seems to be a good start :-)

Sainsmart shifted

I'm just using this Driver with the U8glib library and my Sainsmart OLED Display, and it works. But it's shifted 2 Pixels, so on the left side there's a balk... Can sb. help?

TeEmZe

logo16_glcd_bmp must be const

Although some versions of gcc accept the PROGMEM directive without explicitly declaring the variable as a const, the linux version 1.0.3 does not. Adding const eliminates a compile time error. Adding const should not cause adverse effects on other versions.

memory SRAM footprint too large

Hi.

I am having issues with your library for it uses 1,100 bytes of RAM - this is forcing me out of the 2k limit on most arduinos and into a MEGA which is not good.

Any advice on how to reduce the RAM needed by your library?

Thanks!

support non-ack oled

There are quite a number of oled lack ack in their I2C implements.

Currently I can only get my oled works by u8g with U8G_I2C_OPT_NO_ACK option.

So, how to do that with Adafruit SSD1306?

Font sizes

The difference in physical size of fonts using size 1 and size 2 is too great. There needs to be an intermediary size between them. The problem I encountered was that using display.setTextSize(1) makes the font too small to read easily on a 0.96" display and display.setTextSize(2) makes it too big to fit much information.

Corrupt display when mixed with devices using other SPI_MODE

Problem: When mixing this library with other libraries using SPI but with different SPI_MODE settings (SPI_MODE1 for example) the display is corrupted showing lines through characters.

Image

How to reproduce this: use any Adafruit SSD1306 display together with an Adafruit MAX31865 thermocouple amplifier (also with the Adafruit library for it), both in HW SPI mode. The display will show random lines out of place anywhere you try to draw something.

Cause: some libraries use SPI.beginTransaction(settings here) before each transaction. This library only uses it in the .begin() function. So if some other library changes the SPI_MODE or frequency or any SPI setting the display will be forced to use the same settings leading to corruption.

Easy fix: add SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0)); to Adafruit_SSD1306::fastSPIwrite(uint8_t d) before calling (void)SPI.transfer(d);. This will set the SPI to the right settings before doing a transaction.
This is what the other Adafruit libraries do so I'm sure it's ok to do. I tested it in the above mentioned combination of modules and it fixed the problem without affecting functionality.

Full sketch for testing: (I used a 128x64 adafruit oled + MAX31865 amplifier on an Arduino Pro Mini)

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_MAX31865.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

// THERMOCOUPLE AMPLIFIER
#define RREF 430.0
Adafruit_MAX31865 max = Adafruit_MAX31865(10);

//OLED
#define OLED_DC     6
#define OLED_CS     A0
#define OLED_RESET  8
Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);

void setup() {
  max.begin(MAX31865_3WIRE);  // set to 2WIRE or 4WIRE as necessary
  display.begin();
  display.setTextSize(3);
  display.setTextColor(WHITE);
  display.clearDisplay();
  display.display();
}

void loop() {
  float temp = max.temperature(100, RREF);
  delay(1000);
  //TOP LEFT TEMP
  display.clearDisplay();
  display.setCursor(2,30);
  display.println(temp);
  display.display(); //write to display
  delay(1000);
}

problem on code

I had verify the code of adafruit ssd1306 128*64 i2c. I got a compiling error

(height incorrected,please fix Adafruit_ssd1306.h!).

Then i check the adafruit h file,everything is good.I don't know how to fix it. Help me to fix it quickly.

Dimming feature submitted for review

Not an issue, I simple added the "Dimming" feature to this library. Updated .cpp and .h have been submitted for your review. Code is invoked using display.dim(1) or (0).

Problem in drawFastHLineInternal

Hi, Nice library but there is a bug in drawFastHLineInternal. In the code:
// make sure we don't go off the edge of the display
if( (x + w) > WIDTH) {
w = (HEIGHT- x);
}

HEIGHT should be WIDTH.

Instantiation of an `Adafruit_SSD1306` object should optionally take a `Wire` object.

Instantiation of an Adafruit_SSD1306 object should optionally take a Wire object.
In cases where there is more than one I2C (or Wire) device modification of the Adafruit_SSD1306 library code is required - or worse to be copied and renamed.
Given that Adafruit_SSD1306 is dependent on Wire, and that more than one Wire object can be in use in a single project, then the instantiation of Adafruit_SSD1306 needs to have the Wire object as a parameter, with sensible default if not provided to preserve backward compatibility.

Support Arduino /Genuino Board 101

  • Arduino board:
    BN: Arduino/Genuino 101
    VID: 8087
    PID: 0AB6
  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.6.9
  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too):

Lib seems not to be portet/testet on Arduino 101.
Compiling the exampe"ssd1306_128x32_i2c" results in following error:

C:\Users\joa\Documents\Arduino\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp:28:25: fatal error: util/delay.h: No such file or directory

#include <util/delay.h>

                     ^

compilation terminated.

exit status 1
Fehler beim Kompilieren für das Board Arduino/Genuino 101.

Dependency to Adafruit GFX Library not documented

When installing the library (Arduino IDE or copying source files in Arduino Sketch directory,

#include "Adafruit_SSD1306.h" // https://github.com/adafruit/Adafruit_SSD1306

results in

Adafruit_SSD1306.h:49:26: fatal error: Adafruit_GFX.h: No such file or directory

Once that "Adafruit GFX Library" (https://github.com/adafruit/Adafruit-GFX-Library) is installed, the (empty) sketch compiles fine.

Unfortunately there 's no mention of this dependency in the description shown in Arduino Library Manager (1.8.2) nor in the (GitHub repo) readme.md. But that should be an easy fix :-)


A solution would be to just append `readme.txt` to `readme.md`.

Scroll long text horizontally

I'm trying to figure out if there's a way to scroll long text (that wouldn't fit in one screen) horizontally. Any help would be appreciated! :D

Example code comments.

This library is fantastically difficult to approach due to poor commenting. I spent a good forty minutes absolutely not understanding why the demo code runs fine, but I was unable to even clear the screen, and it would require only a few simple comments to prevent that from happening.

I am referring specifically to ssd1306_128x32_i2c.ino, I imagine the other example programs are similar.

First: line 63's comment, "show splashscreen" completely threw me off the track of display() as something that must be run to modify the screen. This comment should be changed to make it clear that none of the other commands directly affect the screen, and display() must be run each time the screen needs to update.

The comment at line 65, "clears the screen and buffer" was the source of most of my initial frustration. clearDisplay() does not clear the screen, it simply clears the buffer. display() must be run to empty the screen.

Neither of these things became obvious to me until someone in #arduino on freenode looked over the example code and what I had written and pointed out that display() probably updates the display. The graphics library tutorial at http://learn.adafruit.com/adafruit-gfx-graphics-library/graphics-primitives could also be updated to make this point clear.

Use of "CS" as variable name

I've been successfully able to use this software with my Msp432 Launchpad using Energia, but I did run into one annoying issue.

In Adafruit_SSD1306::Adafruit_SSD1306 the variable name "CS" is used. CS is already #define'ed by TI in some of their driverlib stuff. As such, one gets a ton of (no-so-obvious) errors when trying to compile. It would be appreciated if another variable name could be used. Personally, I just suffixed all these short 2-capital letter variables in this part of the code with _SSD1306.

thx.

raspberry pi support

can it directly support raspberry pi ?
I hope there's a c/c++ version of Adafruit_SSD1306 library.

Include Guards missing

The header file doesn't have include guards, this causes errors when splitting the project across multiple sources files etc.

how to create my own logo

I need to create my own logo.

can you document the process of what tools you used to create the adafruit logo in the buffer() in Adafruit_SSD1306.cpp so that I can do it for my own jpg?

Thanks

undefine SSD1306_128_32

Currently when I want to use this library with a 128x64 OLED, I need to edit the Adafruit_SSD1306.h and comment out #define SSD1306_128_32.

Would a better pattern be to not define it in the library and rely on a #define in the code using the library?

drawFastVLine not optimized for SSD1306.

drawFastVLine will call setPixel on every pixel when drawing vertical lines. This is somewhat suboptimal.

I'm currently testing (unfortunately, the person with the board is elsewhere, so I am sending them code to test) code that makes fillRect/fillCircle upwards of 60 times faster for the SSD1306. Once they shake it out a little bit more, I'll check the code into my fork and submit a pull request.

Analog input problem on pin A5

I'm experiencing problems with one analog port when using the SSD1306 library. For example, when I plug in a sensor in analog input A5, the Arduino hangs at "boot" and doesn't even get into the setup method. As soon as I unplug the sensor, it continues and runs through setup and loop. I've experienced the same behaviour with another arduino. Is this an expected behaviour or am I doing sth wrong?

support for 64x48 displays ?

Hi,

I can get this library to work on my SSD1306 display but there is no constructor for a 64x48 display; using the larger ones results in an incorrect output.

Any way this new size could be supported ? So far is the only library that can seem to display text properly on the ESP8266 (Sparkfun's works except for text, and u8glib doesn't support the ESP8266)

Thanks

Two minor documentation updates needed

The README should reflect that this works with the ESP32 (I've tested against a 128x32 display and it works fine).

It would also be very useful to mention in the examples that if RST (reset) is not being used you can set it to -1, e.g.:

Adafruit_SSD1306 display(-1);  // More explicit

or (because the default argument to that constructor is -1):

Adafruit_SSD1306 display;

Support for 132x64 display

Support for 132x64 OLED with SH1106 chip, which is compatible with SSD1306 woudl be nice. I tried to figure what changem but simply change 128 to 132 is not enought, it generate mess only on the display.

How to display a value on the oled which is being provided by a sensor?

Thank you for opening an issue on an Adafruit Arduino library repository. To
improve the speed of resolution please review the following guidelines and
common troubleshooting steps below before creating the issue:

  • Do not use GitHub issues for troubleshooting projects and issues. Instead use
    the forums at http://forums.adafruit.com to ask questions and troubleshoot why
    something isn't working as expected. In many cases the problem is a common issue
    that you will more quickly receive help from the forum community. GitHub issues
    are meant for known defects in the code. If you don't know if there is a defect
    in the code then start with troubleshooting on the forum first.

  • If following a tutorial or guide be sure you didn't miss a step. Carefully
    check all of the steps and commands to run have been followed. Consult the
    forum if you're unsure or have questions about steps in a guide/tutorial.

  • For Arduino projects check these very common issues to ensure they don't apply:

    • For uploading sketches or communicating with the board make sure you're using
      a USB data cable and not a USB charge-only cable. It is sometimes
      very hard to tell the difference between a data and charge cable! Try using the
      cable with other devices or swapping to another cable to confirm it is not
      the problem.

    • Be sure you are supplying adequate power to the board. Check the specs of
      your board and plug in an external power supply. In many cases just
      plugging a board into your computer is not enough to power it and other
      peripherals.

    • Double check all soldering joints and connections. Flakey connections
      cause many mysterious problems. See the guide to excellent soldering for examples of good solder joints.

    • Ensure you are using an official Arduino or Adafruit board. We can't
      guarantee a clone board will have the same functionality and work as expected
      with this code and don't support them.

If you're sure this issue is a defect in the code and checked the steps above
please fill in the following fields to provide enough troubleshooting information.
You may delete the guideline and text above to just leave the following details:

  • Arduino board: INSERT ARDUINO BOARD NAME/TYPE HERE

  • Arduino IDE version (found in Arduino -> About Arduino menu): INSERT ARDUINO
    VERSION HERE

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too): LIST REPRO STEPS BELOW

ESP8266: I2C transmission rate stays at 100kHz

Adafruit_SSD1306.cpp, line 461 - 464

#ifdef TWBR
  uint8_t twbrbackup = TWBR;
  TWBR = 12; // upgrade to 400KHz!
#endif

When using ESP boards these lines seem to get ignored so the I2C rate stays at 100 kHz.

The problem here is that Adafruit_SSD1306::display takes way too long to transmit data with 100 kHz and therefore yielding only ~10 fps on my display which is way too slow. You can actually see every frame building up. 🐌

I tried this on a WeMos D1 Mini (4MB) and on a NodeMCU.


  • How I fixed it

In void setup(){} I inserted Wire.setClock(400000L); to successfully get 400 kHz on my ESP boards and ~30 fps on my display.

void setup()
{
  Wire.setClock(400000L);
}
  • Possible solution

Add code to Adafruit_SSD1306.cpp, line 465:

#ifdef TWBR
  uint8_t twbrbackup = TWBR;
  TWBR = 12; // upgrade to 400KHz!
#endif
 
#ifdef ESP8266
  Wire.setClock(400000L);
#endif

Additionally:

In this case an 800 kHz transmission rate seems to be the maximum. By calling Wire.setClock(800000L); ~60 fps can be achieved on SSD1306 OLEDs using an ESP8266. That's nearly a sixfold increase in drawing speed! compared to what's possible out of the box right now.

Library is changing I2C bus speed

Why is this library bumping up the I2C bus speed with line 511 in Adafruit_SSD1306.cpp. The code is:
TWBR = 12;

If I look at my bus speed on a scope, its switching between 100MHz and 400MHz. I want the bus to run at 100MHz as defined in the Arduino twi.h library.

Are umlauts supported?

First of all, thank you very much for this great library!
Does it also support umlauts like ö,ä,ü... ? I did not find any solution.

Support for Odroid C1/C1+/C2 ?

Im looking to use the Adafruit 128x64 OLED displays via I2C with the Odroid C2 board. The operating system is based on Debian linux. Would this library work on this environment? I already installed the i2c drivers for this board. Thanks.

Multiple Displays Sharing Reset

I have the same problem as described in the following post:
http://adafruit.com/forums/viewtopic.php?f=47&t=32745

The fix that I found to work was to wrap the reset in an if that only allows it to run once using a static flag. Now I can share my rst pin between all my displays. The side effect is that you only can reset once. There are lots of ways to fix this, but since it has been working for me, I haven't done anything about it.

Solution to "i wonder why we have to do this (check datasheet)"

Hey there,

Thanks for this great library, it has helped me a lot in implementing other OLEDs from same manufacturer. I came across this note "i wonder why we have to do this (check datasheet)" in line 404 og the cpp file. The solution to this problem is that horizontal addressing mode was enabled during initialization (SSD1306_MEMORYMODE + 0x00) which according to the datasheet means that these lines are simply ignored by the chip:

ssd1306_command(SSD1306_SETLOWCOLUMN | 0x0); // low col = 0
ssd1306_command(SSD1306_SETHIGHCOLUMN | 0x0); // hi col = 0
ssd1306_command(SSD1306_SETSTARTLINE | 0x0); // line #10

Instead you want to use the commands 0x21 and 0x22, something like this (works for me):

ssd1306_command(0x21);
ssd1306_command(0x0);
ssd1306_command(127);

ssd1306_command(0x22);
ssd1306_command(0x0);
ssd1306_command(3);

The key is the number "3" which is what you need to use for the 128x32 pixel display while I guess the 128x64 display still wants "7" here (because there are 8 pages of 8 bytes in that case.

Voila! :-)

  • kasper

Reading from GDDRAM

Hi guys,

Looking at the library, I couldn't identify any function that would allow us to read and possibly store the current contents of the screen (i.e. in form of a 128x64 binary pixel map or something).

Also, reading page 33 of the datasheet gives me a hint that such a functionality is provided. Since I am only just starting to go as low level as raw i2c, I was wondering if anyone has written code that could implement this?

If not, could anyone please confirm or reject my intuition about whether or not this is possible, and if it is possible maybe point me to the right direction?

Thanks much in advance!

I2C control stability on ESP8266 module

Drawing of SSD1306 in I2C stops in the middle of processing. But, ESP8266 mcu processing continues. I have encountered in NodeMCU V1.0 to this problem.
I2C of ESP8266 has implemented by Bit-Bang, It is a software takes time. Meanwhile, ESP8266 must keep WiFi connection and some background process running in consequence. It has been described in 'ESP8266 Thing Hookup Guide' at https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-guide/using-the-arduino-addon.
Thus the correct timing of I2C signal would be lost, I thought.

So, I tried yielding at the end of I2C transmission as follows. The problem is gone, SD1306 in I2C drawing process I think as stable. But this is not the best way, because I2C frequency can be varied.
Anyway, use as reference.

Modify the Adafruit_SSD1306.cpp latest version 1.0.1, three functions.

(1). ssd1306_command(uint8_t c) { ... : near the line 376

    ...
    Wire.write(c);
    Wire.endTransmission();
#ifdef ESP8266
    yield();
#endif
  }

(2). ssd1306_data(uint8_t c) { ... : near the line 499

    ...
    Wire.write(c);
    Wire.endTransmission();
#ifdef ESP8266
    yield();
#endif
  }

(3). display(void) { ... : near the line 567

    ...
    Wire.write(c);
    Wire.endTransmission();
#ifdef ESP8266
    yield();
#endif
  }

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.