Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Sabernetics I2C OLED display / Adafruit SSD1306 library problem

  1. #1
    Member
    Join Date
    Feb 2013
    Location
    Portland, OR
    Posts
    55

    Sabernetics I2C OLED display / Adafruit SSD1306 library problem

    I got a Sabernetics I2C OLED display from kickstarter a while back, and decided to try and use it with Teensy3, then I ran into some problems.
    The display comes with arduino libraries and examples, which look to be based on the code in the Adafruit SSD1306 and GFX libraries.

    The code from Sabernetics is here: http://sabernetics.com/wp-content/up...6/OLED_I2C.zip

    When I compile, I get an error that /util/delay.h was missing from SSD1306.cpp. Following advice in this thread I removed references to that header, but then it gave me: "error: 'TWBR' was not declared in this scope"

    Any suggestions on how to get this to work?

    -Tom

  2. #2
    Senior Member
    Join Date
    Mar 2013
    Location
    Austin TX
    Posts
    429
    Quote Originally Posted by tomfrisch View Post
    When I compile, I get an error that /util/delay.h was missing from SSD1306.cpp. Following advice in this thread I removed references to that header, but then it gave me: "error: 'TWBR' was not declared in this scope"
    Looks like they manually alter the TWBR register (an AVR specific register) in the Adafruit_SSD1306.cpp file, specifically the display() function where they "boost" it to 400kHz (woo~). How unportable of them.

    Well if it's going to be unportable you can do better than that. I've uploaded a revised version that compiles ok for me on Teensy3. To use it you will also want to grab the 'v5' I2C library from here:
    http://forum.pjrc.com/threads/21680-...ry-for-Teensy3

    The modifications I did are as follows (very minor):

    • In MiniOLED and MiniOLED_Multi example sketches, line 7:
      changed #include <Wire.h> to #include <i2c_t3.h>

    • In Adafruit_SSD1306.cpp, line 23:
      changed #include <Wire.h> to #include <i2c_t3.h>

    • In Adafruit_SSD1306.cpp, line 167:
      changed Wire.begin() to Wire.begin(I2C_MASTER,0,I2C_PINS_18_19,I2C_PULLUP_ EXT,I2C_RATE_400);
      This sets up Teensy3 as the Master, using I2C pins 18/19, external pullups, and 400kHz rate.

    • In Adafruit_SSD1306.cpp, line 336-375:
      Commented out the TWBR lines for altering the baud rate.


    Those examples compile ok for me now, but I can't test them since I don't have the hardware. One thing you can do however, once you check it works, is an actual boost - by altering the I2C rate on line 167 above you can achieve perhaps a real boost in display performance. Refer to the I2C thread above for the different rates you can try.
    Attached Files Attached Files

  3. #3
    Member
    Join Date
    Feb 2013
    Location
    Portland, OR
    Posts
    55
    nox- thanks so much for your help!

    I installed the v5 version of your I2C library, and your altered version of the OLED_I2C_t3 library.

    When I compiled I got errors about the /util/delay.h missing. So I found this post about it- which says to comment out the /util/delay.h, and then make some changes to the makefile, and the Adafruit GFX library. I made those, and am now able to compile without errors.

    Switched the pin for the reset to the correct pin.... and we have contact!

    Click image for larger version. 

Name:	photo.JPG 
Views:	407 
Size:	118.1 KB 
ID:	564

    -Tom
    Last edited by tomfrisch; 06-11-2013 at 03:53 PM.

  4. #4
    Senior Member
    Join Date
    Mar 2013
    Location
    Austin TX
    Posts
    429
    Hmm, IIRC I didn't see anything about delay.h when I compiled (I am running latest Teensyduino). In any event, good to see it worked. That is a really small display.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,090
    Here is my first attempt at TWBR emulation to set 400 kHz speed.

    Copy this file to libraries/Wire. Please let me know if it works for you?
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •