128X32 I2C OLED Display Library [SOLVED]

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
Knight
 
Posts: 2
Joined: Wed Oct 03, 2012 10:02 pm

128X32 I2C OLED Display Library [SOLVED]

Post by Knight »

Board,

So I purchased a 128x32 OLED display, and I tried to get the example code working. Here is what I have done so far:

* Downloaded and installed both libraries: https://github.com/adafruit/Adafruit_SSD1306 and https://github.com/adafruit/Adafruit-GFX-Library
* Renamed the folders in the libraries folder to Adafruit_SSD1306 and Adafruit_GFX as per the readme.
* Opened up the Adafruit_SSD1306.h file in notepad and commented out "#define SSD1306_128_64" and uncommented out "#define SSD1306_128_32".

This is all I have done.

I then attempt to compile and run the default example code sketch by clicking on File > Examples > Adafruit_SSD1306 > ssd1306_128x32_i2c. After I attempt to compile I get the following error: ssd1306_128x32_i2c.cpp:53:2: error: #error ("Height incorrect, please fix Adafruit_SSD1306.h!");

I have tried removing everything that says anything to do with 64, and nothing I do seems to help. In desperation I commented out the checks in the sketch, and was able to get the display to run, though it's only using the top half of the screen, which makes all but the largest text unreadable. Obviously I'm missing something in regards to the library configuration.



Below is the modified Adafruit_SSD1306.h file:

Code: Select all

/*********************************************************************
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 SPI to communicate, 4 or 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.
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/

#if ARDUINO >= 100
 #include "Arduino.h"
#else
 #include "WProgram.h"
#endif

#include <Adafruit_GFX.h>

#define BLACK 0
#define WHITE 1

#define SSD1306_I2C_ADDRESS 0x3C // 011110+SA0+RW - 0x3C or 0x3D
// Address for 128x32 is 0x3C
// Address for 128x32 is 0x3D (default) or 0x3C (if SA0 is grounded)

/*=========================================================================
SSD1306 Displays
-----------------------------------------------------------------------
The driver is used in multiple displays (128x64, 128x32, etc.).
Select the appropriate display below to create an appropriately
sized framebuffer, etc.

SSD1306_128_64 128x64 pixel display

SSD1306_128_32 128x32 pixel display

You also need to set the LCDWIDTH and LCDHEIGHT defines to an
appropriate size

-----------------------------------------------------------------------*/
// #define SSD1306_128_64
#define SSD1306_128_32
/*=========================================================================*/

#if defined SSD1306_128_64 && defined SSD1306_128_32
  #error "Only one SSD1306 display can be specified at once in SSD1306.h"
#endif
#if !defined SSD1306_128_64 && !defined SSD1306_128_32
  #error "At least one SSD1306 display must be specified in SSD1306.h"
#endif

#if defined SSD1306_128_64
  #define SSD1306_LCDWIDTH 128
  #define SSD1306_LCDHEIGHT 64
#endif
#if defined SSD1306_128_32
  #define SSD1306_LCDWIDTH 128
  #define SSD1306_LCDHEIGHT 32
#endif


#define SSD1306_SETCONTRAST 0x81
#define SSD1306_DISPLAYALLON_RESUME 0xA4
#define SSD1306_DISPLAYALLON 0xA5
#define SSD1306_NORMALDISPLAY 0xA6
#define SSD1306_INVERTDISPLAY 0xA7
#define SSD1306_DISPLAYOFF 0xAE
#define SSD1306_DISPLAYON 0xAF

#define SSD1306_SETDISPLAYOFFSET 0xD3
#define SSD1306_SETCOMPINS 0xDA

#define SSD1306_SETVCOMDETECT 0xDB

#define SSD1306_SETDISPLAYCLOCKDIV 0xD5
#define SSD1306_SETPRECHARGE 0xD9

#define SSD1306_SETMULTIPLEX 0xA8

#define SSD1306_SETLOWCOLUMN 0x00
#define SSD1306_SETHIGHCOLUMN 0x10

#define SSD1306_SETSTARTLINE 0x40

#define SSD1306_MEMORYMODE 0x20

#define SSD1306_COMSCANINC 0xC0
#define SSD1306_COMSCANDEC 0xC8

#define SSD1306_SEGREMAP 0xA0

#define SSD1306_CHARGEPUMP 0x8D

#define SSD1306_EXTERNALVCC 0x1
#define SSD1306_SWITCHCAPVCC 0x2

// Scrolling #defines
#define SSD1306_ACTIVATE_SCROLL 0x2F
#define SSD1306_DEACTIVATE_SCROLL 0x2E
#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3
#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26
#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27
#define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29
#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A

class Adafruit_SSD1306 : public Adafruit_GFX {
 public:
  Adafruit_SSD1306(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS);
  Adafruit_SSD1306(int8_t RST);

  void begin(uint8_t switchvcc = SSD1306_SWITCHCAPVCC, uint8_t i2caddr = SSD1306_I2C_ADDRESS);
  void ssd1306_command(uint8_t c);
  void ssd1306_data(uint8_t c);

  void clearDisplay(void);
  void invertDisplay(uint8_t i);
  void display();

  void startscrollright(uint8_t start, uint8_t stop);
  void startscrollleft(uint8_t start, uint8_t stop);

  void startscrolldiagright(uint8_t start, uint8_t stop);
  void startscrolldiagleft(uint8_t start, uint8_t stop);
  void stopscroll(void);

  void drawPixel(int16_t x, int16_t y, uint16_t color);

 private:
  int8_t _i2caddr, sid, sclk, dc, rst, cs;
  void fastSPIwrite(uint8_t c);
  void slowSPIwrite(uint8_t c);

  volatile uint8_t *mosiport, *clkport, *csport, *dcport;
  uint8_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
};

Much thanks in advance for what I'm sure is a silly mistake on my part!
Knight.
Last edited by Knight on Thu Oct 04, 2012 12:48 am, edited 1 time in total.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: 128X32 I2C OLED Display Library

Post by adafruit »

try with a fresh copy of the library, make sure you only have one copy

change which line is commented in the .h file, and be sure to save it!

then try to re-compile and upload the sketch

Knight
 
Posts: 2
Joined: Wed Oct 03, 2012 10:02 pm

Re: 128X32 I2C OLED Display Library

Post by Knight »

adafruit wrote:.... make sure you only have one copy ....
You know... it's like you've done this before! And I ALMOST ignored that part of your response, figuring, "yeah, sure, typical response."

Much thanks! That was it, multiple copies of the library.

Knight.

farn7259
 
Posts: 1
Joined: Mon Nov 12, 2012 8:07 pm

Re: 128X32 I2C OLED Display Library [SOLVED]

Post by farn7259 »

So I've tried to run this code for a simple school project, but due to my apparent lack of knowledge for the fundamentals of the Arduino platform I need help.
- Ive downloaded both zip folders
- I dont know how to correct the error: " 'Adafruit_SS1306' does not name a type"
- I know that the .h file must be changed but I dont know it that is everything I need to do.

Some assistance on this would be greatly appreciated!!

Thanks

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: 128X32 I2C OLED Display Library [SOLVED]

Post by adafruit_support_rick »

Have a look at this page for instructions on how to install libraries. And no, you don't want to rename the .h file. You want to make sure the library folder has the right name.

User avatar
cls413
 
Posts: 1
Joined: Mon Sep 11, 2017 1:51 pm

Re: 128X32 I2C OLED Display Library [SOLVED]

Post by cls413 »

This is pretty late but, I had the same problem as the original person and after doing everything over as the person said to, the error I had was fixed, but nothing happens when I download the program to the arduino.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: 128X32 I2C OLED Display Library [SOLVED]

Post by adafruit_support_rick »

Please post some pictures of your soldering and wiring.

Are you getting any output in Serial Monitor? Please post the entire trace.

You're net seeing any compile errors? Does Arduino say that the upload completed successfully?

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”