Conflict between Lib i2c_t3 and Adafruit_GFX.g / Adafruit_SSD1306.h

Status
Not open for further replies.

Chris2019

New member
Trying to use mutiple of small OLED displays with help i2c switch TCA9548 - Adafruit breakout.
The code to control OLED with TCA95948 worked on a Arduino micro pro, but not then I shifted to Teensy due to I need the MidiUSB support which Teensy has built in.
Apparently the normal Wire.h library does not work with Teensy 3.2 and TCA9548, so I tried to use the i2c_t3.h instead.
But I get mutiple of compiling errors after I shift from Wire.h to i2c_t3.h
Then I tried reinstall the full software (Arduio + Teensy) and run a code from the forum to see if it works, but still error, conflict between the different libraries.


I used this code to check if my installation is ok:
https://forum.pjrc.com/archive/index.php/t-33298.html

Different application, different input, but still use the same libraries and the TCA9548

#include <Adafruit_GFX.h>
#include <gfxfont.h>
#include <Adafruit_SSD1306.h>
#include <i2c_t3.h>

And get this error:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Arduino: 1.8.8 (Windows 7), TD: 1.45, Board: "Teensy 3.2 / 3.1, MIDI, 96 MHz (overclock), Faster, US English"

C:\Users\Chris\AppData\Local\Temp\arduino_build_121718\libraries\Wire\WireKinetis.cpp.o: In function `i2c0_isr':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/WireKinetis.cpp:895: multiple definition of `i2c0_isr'

C:\Users\Chris\AppData\Local\Temp\arduino_build_121718\libraries\i2c_t3\i2c_t3.cpp.o:C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\i2c_t3/i2c_t3.cpp:1134: first defined here

c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions

C:\Users\Chris\AppData\Local\Temp\arduino_build_121718\libraries\Wire\WireKinetis.cpp.o: In function `Print::availableForWrite()':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/WireKinetis.h:132: multiple definition of `i2c1_isr'

C:\Users\Chris\AppData\Local\Temp\arduino_build_121718\libraries\i2c_t3\i2c_t3.cpp.o:C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\i2c_t3/i2c_t3.h:883: first defined here

C:\Users\Chris\AppData\Local\Temp\arduino_build_121718\libraries\Wire\WireKinetis.cpp.o: In function `Print::availableForWrite()':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/WireKinetis.h:132: multiple definition of `Wire1'

C:\Users\Chris\AppData\Local\Temp\arduino_build_121718\libraries\i2c_t3\i2c_t3.cpp.o:C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\i2c_t3/i2c_t3.h:883: first defined here

c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: Warning: size of symbol `Wire1' changed from 20 in C:\Users\Chris\AppData\Local\Temp\arduino_build_121718\libraries\i2c_t3\i2c_t3.cpp.o to 108 in C:\Users\Chris\AppData\Local\Temp\arduino_build_121718\libraries\Wire\WireKinetis.cpp.o

C:\Users\Chris\AppData\Local\Temp\arduino_build_121718\libraries\Wire\WireKinetis.cpp.o: In function `Print::availableForWrite()':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/WireKinetis.h:132: multiple definition of `Wire'

C:\Users\Chris\AppData\Local\Temp\arduino_build_121718\libraries\i2c_t3\i2c_t3.cpp.o:C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\i2c_t3/i2c_t3.h:883: first defined here

c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: Warning: size of symbol `Wire' changed from 20 in C:\Users\Chris\AppData\Local\Temp\arduino_build_121718\libraries\i2c_t3\i2c_t3.cpp.o to 108 in C:\Users\Chris\AppData\Local\Temp\arduino_build_121718\libraries\Wire\WireKinetis.cpp.o

collect2.exe: error: ld returned 1 exit status

Error compiling for board Teensy 3.2 / 3.1.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

The I run the standard shift function from Adafruit with the Wire.h, nothing happens, that is why I tried to shift to the enhanced i2c_t3.h

This is the normal shift function; which works on Arduino micro pro but not on a Teensy 3.2 if using the Wire.h

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

#define TCAADDR 0x70

void tcaselect(uint8_t i) {
if (i > 7) return;

Wire.beginTransmission(TCAADDR);
Wire.write(1 << i);
Wire.endTransmission();
}

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

How do you use the Libraires: i2c_t3.h, Adafruit_GFX.g and Adafruit_SSD1306.h in the same code?
Looking forward to some good tips, I am stuck
Or any other good idea how to use a TCA9548 with a Teensy 3.2.
 
Again not sure why TCA9548 would not work with Wire library but would with i2c_t3?

But these two libraries can not co-exist in the same sketch either directly or through libraries.

That is if you include i2c_t3, and want to use another library that uses the Wire library. You often then have to make a copy of that library (maybe with different name) and edit it to replace all of the #include <Wire.h> to #include <i2c_t3.h>

You may then also have to change some of the code in the library as i2c_t3 is not 100% compatible with Wire. In particular things like: setSCL and setSDA are not implemented. He has a different way to handle alternate pins.

Good luck
 
Status
Not open for further replies.
Back
Top