When I was trying to compile the code to Teensy 3.1 with Arduino 1.0.5, it shows me the message below
/Users/MikeLo/Documents/Arduino/libraries/AdafruitSSD1306/Adafruit_SSD1306.cpp: In member function 'void Adafruit_SSD1306::display()':
/Users/MikeLo/Documents/Arduino/libraries/AdafruitSSD1306/Adafruit_SSD1306.cpp:432:26: error: 'TWBR' was not declared in this scope
Does anyone know how to solve this problem?
SSD128x32 OLED won't compile on Arduino 1.0.5 IDE
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 16
- Joined: Sat Jan 05, 2013 1:09 am
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: SSD128x32 OLED won't compile on Arduino 1.0.5 IDE
The library is written for Arduino. The teensy 3.1 is a completely different processor architecture, and the library is not completely compatible with it.
I was working on an Arduino Due port of the library. Let me see if I can make it work with a Teensy 3.1 as well. I'll let you know.
I was working on an Arduino Due port of the library. Let me see if I can make it work with a Teensy 3.1 as well. I'll let you know.
- pburgess
- Posts: 4161
- Joined: Sun Oct 26, 2008 2:29 am
Re: SSD128x32 OLED won't compile on Arduino 1.0.5 IDE
Hey Rick - I was merging a bunch of pull requests last night, Due support is taken care of.
- paulstoffregen
- Posts: 444
- Joined: Sun Oct 11, 2009 11:23 am
Re: SSD128x32 OLED won't compile on Arduino 1.0.5 IDE
Install the latest version of Teensyduino, either 1.18-rc2 or 1.18-rc3.Does anyone know how to solve this problem?
You probably using 1.17, which supports Teensy 3.1 but several of the libraries were not updated for 3.1. Simply installing the latest version will fix this problem.
Actually Rick, the 128x32 I2C OLED has been tested with Teensy 3.0 and 3.1. It works great. But the latest software is needed.adafruit_support_rick wrote:The teensy 3.1 is a completely different processor architecture, and the library is not completely compatible with it.
- paulstoffregen
- Posts: 444
- Joined: Sun Oct 11, 2009 11:23 am
Re: SSD128x32 OLED won't compile on Arduino 1.0.5 IDE
Oh, I'll retest it soon. Sometimes Due support breaks Teensy 3.X, especially if the code assumes #if defined(__arm__) can mean only Arduino Due. Yes, that's happened several times on various libraries. Simple to fix for library authors... but annoying for users.pburgess wrote:Hey Rick - I was merging a bunch of pull requests last night, Due support is taken care of.
- paulstoffregen
- Posts: 444
- Joined: Sun Oct 11, 2009 11:23 am
Re: SSD128x32 OLED won't compile on Arduino 1.0.5 IDE
Just tested the latest code on Teensy 3.1. It's works great.
Well, the library still requires editing the .h file to set 32 lines. Also, Arduino's 2 robot libraries cause conflicts with Adafruit_GFX. I just deleted the robot libs. But with the robot libs out of the way and the .h file edited, Adafruit_SSD1306 works great on Teensy 3.1.
Here's a photo:
Well, the library still requires editing the .h file to set 32 lines. Also, Arduino's 2 robot libraries cause conflicts with Adafruit_GFX. I just deleted the robot libs. But with the robot libs out of the way and the .h file edited, Adafruit_SSD1306 works great on Teensy 3.1.
Here's a photo:
- pburgess
- Posts: 4161
- Joined: Sun Oct 26, 2008 2:29 am
Re: SSD128x32 OLED won't compile on Arduino 1.0.5 IDE
Say, been meaning to ask, what's your Preferred Canonical Way™ of distinguishing among them, so I can follow it in the future? These two lines are from the NeoPixel and SSD1306 libraries, respectively:Sometimes Due support breaks Teensy 3.X [...] Simple to fix for library authors... but annoying for users.
Code: Select all
#if defined(__MK20DX128__) || defined(__MK20DX256__) // Teensy 3.0 & 3.1
#ifdef __SAM3X8E__ // Due
Yay!Just tested the latest code on Teensy 3.1. It's works great.
There's some kludgetacular stuff to get 400 KHz I2C going on the Due. Dunno if the Teensy uses the same 100 KHz default as Arduino...if so, the difference w/400KHz is very pronounced, so it might be worth doing the extra bit of ugly register-grappling.
Code: Select all
Well, the library still requires editing the .h file to set 32 lines.
- paulstoffregen
- Posts: 444
- Joined: Sun Oct 11, 2009 11:23 am
Re: SSD128x32 OLED won't compile on Arduino 1.0.5 IDE
For a lot of libraries, especially most of Adafruit's, it's best to just let the AVR code compile for Teensy3. Something like this:
Obviously this doesn't work if you get too specific on AVR stuff, but it does work for nearly everything Adafruit publishes. Teensyduino automatically translates commonly used AVR registers like PORTD, DDRD, TWBR, SPSR, SPDR, SREG into equivalent native code. This particular library is a perfect example, where it only depends on the Wire library and TWBR. Your AVR specific code "just works" on Teensy 3.1 and set the I2C to 400 kHz, just by writing to TWBR.
But for more specific code, "#if defined(__MK20DX128__) || defined(__MK20DX256__)" would be technically correct. Generally that's only needed in much lower level libraries, like NeoPixel.
The situation with the robot libraries is really annoying. In fact, I'm about to put a patch in the java code to specifically not check those 2 libraries if a Teensy board is selected. Yup, resorting to such a dirty hack makes me feel a bit icky, but I'm getting really tired of people hitting this problem over and over again.
Code: Select all
#if defined(__AVR__) || defined(TEENSYDUINO)
#elif defined(__SAM3X8e__)
#endif
But for more specific code, "#if defined(__MK20DX128__) || defined(__MK20DX256__)" would be technically correct. Generally that's only needed in much lower level libraries, like NeoPixel.
The situation with the robot libraries is really annoying. In fact, I'm about to put a patch in the java code to specifically not check those 2 libraries if a Teensy board is selected. Yup, resorting to such a dirty hack makes me feel a bit icky, but I'm getting really tired of people hitting this problem over and over again.
- paulstoffregen
- Posts: 444
- Joined: Sun Oct 11, 2009 11:23 am
Re: SSD128x32 OLED won't compile on Arduino 1.0.5 IDE
I think I've found the place in the IDE where the root library conflicts happens. It's Base.addLibraries().
Currently the last library found is used. I'm working on a patch that will always give preference to a library that has the same name as the header file. So Adafruit_GFX will be used with Adafruit_GFX.h is found in the sketch and never some other library like Robot_Control that just happens to have a (very old) copy of Adafruit_GFX.h.
Currently the last library found is used. I'm working on a patch that will always give preference to a library that has the same name as the header file. So Adafruit_GFX will be used with Adafruit_GFX.h is found in the sketch and never some other library like Robot_Control that just happens to have a (very old) copy of Adafruit_GFX.h.
- pburgess
- Posts: 4161
- Joined: Sun Oct 26, 2008 2:29 am
Re: SSD128x32 OLED won't compile on Arduino 1.0.5 IDE
The Robot issue will be fixed if they would just plop out a new release of the IDE! A pull request was already made (and accepted) with a new Adafruit_GFX library. In fact, it's probably fine in 1.5.5. But I don't know when (or even if) there will be a 1.0.6 release.
- paulstoffregen
- Posts: 444
- Joined: Sun Oct 11, 2009 11:23 am
Re: SSD128x32 OLED won't compile on Arduino 1.0.5 IDE
But what happens months or years after 1.0.6 when Adafruit_GFX updates again with some awesome new stuff, like variable size anti-aliased fonts or something?
- paulstoffregen
- Posts: 444
- Joined: Sun Oct 11, 2009 11:23 am
Re: SSD128x32 OLED won't compile on Arduino 1.0.5 IDE
Oh, I see... they moved Adafruit_GFX.h to a subdirectory and then added a non-conflicting name.
The whole library matching process is still able to match the wrong library. This really ought to be more reliable.
The whole library matching process is still able to match the wrong library. This really ought to be more reliable.
- paulstoffregen
- Posts: 444
- Joined: Sun Oct 11, 2009 11:23 am
Re: SSD128x32 OLED won't compile on Arduino 1.0.5 IDE
I created a patch and submitted it to Arduino.
https://github.com/arduino/Arduino/pull/1853
I'm also going to put this into the Teensyduino 1.18 installer. Since it's not the ugly Teensy-only kludge I'd imagined earlier, it should fix these problems even when using Arduino Uno or Leonardo or Mega, simply by having Teensyduino 1.18 installed.
https://github.com/arduino/Arduino/pull/1853
I'm also going to put this into the Teensyduino 1.18 installer. Since it's not the ugly Teensy-only kludge I'd imagined earlier, it should fix these problems even when using Arduino Uno or Leonardo or Mega, simply by having Teensyduino 1.18 installed.
- paulstoffregen
- Posts: 444
- Joined: Sun Oct 11, 2009 11:23 am
Re: SSD128x32 OLED won't compile on Arduino 1.0.5 IDE
The Arduino developers have merged my patch, so it'll be in 1.0.6.... when/if 1.0.6 ever releases.
I'm going to release Teensyduino 1.18 later today, with this patch in the installer.
I'm going to release Teensyduino 1.18 later today, with this patch in the installer.
-
- Posts: 16
- Joined: Sat Jan 05, 2013 1:09 am
Re: SSD128x32 OLED won't compile on Arduino 1.0.5 IDE
thank you Paul. Does that mean I load the example code of SSD 1306 will work just fine without edition any code? by the way, do I connect them to pin 18 and 19? Do I have to use pull up resister.
Please be positive and constructive with your questions and comments.