Having a heck of a time getting a TFT w/ ST7735 to even compile

impcc

Active member
I have a Teensy 4.1. I normally use PlatformIO, but often fall back to Arduino IDE when things don't work, especially for the examples. If it matters, I have both the 1.8.19 version of the Arduino IDE installed and 2.3.0 (I changed the name of the app. I need this because I also develop for the ESP boards, and the one I have only supports Arduino IDE 1.x.y).

I've been in the Arduino IDE trying to get the TFTDisplayText example working, and frankly, I'm having a heck of a time. The only edits I've made to the stock example has been to change the pins, since it appears it was made for an UNO.

I appear to be in some embedded version of DLL-hell. Here's what I'm getting:

Code:
In file included from /Users/ipm/Documents/Arduino/libraries/TFT/src/utility/Adafruit_GFX.h:58,
                 from /Users/ipm/Documents/Arduino/libraries/TFT/src/TFT.h:36,
                 from /Users/ipm/Documents/Arduino/TFTDisplayText/TFTDisplayText.ino:19:
/Users/ipm/Documents/Arduino/libraries/TFT/src/utility/PImage.h: In constructor 'PImage::PImage()':
/Users/ipm/Documents/Arduino/libraries/TFT/src/utility/PImage.h:43:12: warning: 'PImage::_valid' will be initialized after [-Wreorder]
   43 |   bool     _valid;
      |            ^~~~~~
/Users/ipm/Documents/Arduino/libraries/TFT/src/utility/PImage.h:37:8: warning:   'int PImage::_bmpWidth' [-Wreorder]
   37 |   int  _bmpWidth, _bmpHeight;   // W+H in pixels
      |        ^~~~~~~~~
/Users/ipm/Documents/Arduino/libraries/TFT/src/utility/PImage.h:17:3: warning:   when initialized here [-Wreorder]
   17 |   PImage() :
      |   ^~~~~~
In file included from /Users/ipm/Documents/Arduino/libraries/TFT/src/TFT.h:36,
                 from /Users/ipm/Documents/Arduino/TFTDisplayText/TFTDisplayText.ino:19:
/Users/ipm/Documents/Arduino/libraries/TFT/src/utility/Adafruit_GFX.h: In static member function 'static PImage PImage::loadImage(const char*)':
/Users/ipm/Documents/Arduino/libraries/TFT/src/utility/Adafruit_GFX.h:318:40: warning: NULL used in arithmetic [-Wpointer-arith]
  318 |   if ((bmpFile = SD.open(fileName)) == NULL) {
      |                                        ^~~~
In file included from /Users/ipm/Documents/Arduino/libraries/TFT/src/utility/Adafruit_ST7735.h:28,
                 from /Users/ipm/Documents/Arduino/libraries/TFT/src/utility/Adafruit_ST7735.cpp:19:
/Users/ipm/Documents/Arduino/libraries/TFT/src/utility/Adafruit_GFX.h:60:3: warning: #warning "The SD library was not found. loadImage() and image() won't be supported." [-Wcpp]
   60 |  #warning "The SD library was not found. loadImage() and image() won't be supported."
      |   ^~~~~~~
In file included from /Users/ipm/Library/Arduino15/packages/teensy/hardware/avr/1.59.0/cores/teensy4/core_pins.h:33,
                 from /Users/ipm/Library/Arduino15/packages/teensy/hardware/avr/1.59.0/cores/teensy4/wiring.h:39,
                 from /Users/ipm/Library/Arduino15/packages/teensy/hardware/avr/1.59.0/cores/teensy4/WProgram.h:46,
                 from /private/var/folders/03/1grbyxdj5q5cspbhcp3cwffm0000gn/T/arduino/sketches/2E8FDD83F841A95CF96D39096A55AC6A/pch/Arduino.h:6,
                 from /Users/ipm/Documents/Arduino/libraries/TFT/src/utility/Adafruit_ST7735.h:23,
                 from /Users/ipm/Documents/Arduino/libraries/TFT/src/utility/Adafruit_ST7735.cpp:19:
/Users/ipm/Documents/Arduino/libraries/TFT/src/utility/Adafruit_ST7735.cpp: In member function 'void Adafruit_ST7735::commonInit(const uint8_t*)':
/Users/ipm/Library/Arduino15/packages/teensy/hardware/avr/1.59.0/cores/teensy4/pins_arduino.h:142:71: error: cannot convert 'volatile uint32_t*' {aka 'volatile long unsigned int*'} to 'volatile uint8_t*' {aka 'volatile unsigned char*'} in assignment
  142 | #define portOutputRegister(pin)  ((digital_pin_to_info_PGM[(pin)].reg + (uint8_t)0))
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
      |                                                                       |
      |                                                                       volatile uint32_t* {aka volatile long unsigned int*}
/Users/ipm/Documents/Arduino/libraries/TFT/src/utility/Adafruit_ST7735.cpp:349:15: note: in expansion of macro 'portOutputRegister'
  349 |   csport    = portOutputRegister(digitalPinToPort(_cs));
      |               ^~~~~~~~~~~~~~~~~~
/Users/ipm/Library/Arduino15/packages/teensy/hardware/avr/1.59.0/cores/teensy4/pins_arduino.h:142:71: error: cannot convert 'volatile uint32_t*' {aka 'volatile long unsigned int*'} to 'volatile uint8_t*' {aka 'volatile unsigned char*'} in assignment
  142 | #define portOutputRegister(pin)  ((digital_pin_to_info_PGM[(pin)].reg + (uint8_t)0))
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
      |                                                                       |
      |                                                                       volatile uint32_t* {aka volatile long unsigned int*}
/Users/ipm/Documents/Arduino/libraries/TFT/src/utility/Adafruit_ST7735.cpp:351:15: note: in expansion of macro 'portOutputRegister'
  351 |   rsport    = portOutputRegister(digitalPinToPort(_rs));
      |               ^~~~~~~~~~~~~~~~~~
/Users/ipm/Library/Arduino15/packages/teensy/hardware/avr/1.59.0/cores/teensy4/pins_arduino.h:142:71: error: cannot convert 'volatile uint32_t*' {aka 'volatile long unsigned int*'} to 'volatile uint8_t*' {aka 'volatile unsigned char*'} in assignment
  142 | #define portOutputRegister(pin)  ((digital_pin_to_info_PGM[(pin)].reg + (uint8_t)0))
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
      |                                                                       |
      |                                                                       volatile uint32_t* {aka volatile long unsigned int*}
/Users/ipm/Documents/Arduino/libraries/TFT/src/utility/Adafruit_ST7735.cpp:370:19: note: in expansion of macro 'portOutputRegister'
  370 |     clkport     = portOutputRegister(digitalPinToPort(_sclk));
      |                   ^~~~~~~~~~~~~~~~~~
/Users/ipm/Library/Arduino15/packages/teensy/hardware/avr/1.59.0/cores/teensy4/pins_arduino.h:142:71: error: cannot convert 'volatile uint32_t*' {aka 'volatile long unsigned int*'} to 'volatile uint8_t*' {aka 'volatile unsigned char*'} in assignment
  142 | #define portOutputRegister(pin)  ((digital_pin_to_info_PGM[(pin)].reg + (uint8_t)0))
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
      |                                                                       |
      |                                                                       volatile uint32_t* {aka volatile long unsigned int*}
/Users/ipm/Documents/Arduino/libraries/TFT/src/utility/Adafruit_ST7735.cpp:372:19: note: in expansion of macro 'portOutputRegister'
  372 |     dataport    = portOutputRegister(digitalPinToPort(_sid));
      |                   ^~~~~~~~~~~~~~~~~~
Multiple libraries were found for "SD.h"
  Used: /Users/ipm/Library/Arduino15/packages/teensy/hardware/avr/1.59.0/libraries/SD
  Not used: /Users/ipm/Documents/Arduino/libraries/SD
exit status 1

Compilation error: exit status 1

What I'm seeing here is:
  • Warning: Some initialization issues with reorder. I understand what this error means, but not why I have to fix it as a consumer of this library.
  • Warning: A pointer arithmetic warning when comparing a pointer to `NULL`. I guess they want us to use it in a boolean context? Or maybe use `nullptr`? (Also note that this appears to be a warning in the SD library. This may be important later.)
  • Warning: An `unused-const-variable` issue that I don't care about (but which the library authors should suppress. Yes, I suspect that's probably not Teensy specific.)
  • Warning: A warning that `The SD library was not found.` in Adafruit GFX. I have installed it, removed it, reinstalled it, etc. `#including` it from my main sketch doesn't seem to be a problem, but we'll see this warning a bunch of times. (Always in libraries, never in my code, which `#includes` it, seemingly without issue.)
Now we get to the fun part:
  • Error: `Cannot convert 'volatile uint32_t*' {aka 'volatile long unsigned int*'} to 'volatile uint8_t*' {aka 'volatile unsigned char*'} in assignment.` So, I know conceptually what this error means, and I tried to dig into the library code and fix it with a bunch of casts, but I kinda got three layers down and thought, "The authors of this library couldn't mean for us to need to do ALL this work to get a stock example working, could they?"
  • A bunch more of those...
  • Then this:
    Code:
    Multiple libraries were found for "SD.h"  Used: /Users/ipm/Library/Arduino15/packages/teensy/hardware/avr/1.59.0/libraries/SD
      Not used: /Users/ipm/Documents/Arduino/libraries/SD
    which I suspect is somehow rooted in my multiple versions of the IDE. I have noticed though that Arduino IDE 2 seems to install things in the Arduino15 directory, even when I uninstall and reinstall. I don't know what's going on here, TBH. I have tried completely removing the Arduino15 directory and reinstalling everything exclusively from 2.3.0 but it still puts some libraries into that folder.
Has anyone been able to get this example working, and have any tips?

Thanks!

- Ian
 
Last edited:
I would suggest that you use the ST7735_t3 library that is included with the install of Teensyduino. To start I would use the graphicstest sketch that provides examples of the different initializes used to support different versions of the ST7735 and the ST7789.

The Adafruit graphics library for the display does not currently support T4.x boards. Same with their SD library. The teensy version is used by default as you can see:
Multiple libraries were found for "SD.h" Used: /Users/ipm/Library/Arduino15/packages/teensy/hardware/avr/1.59.0/libraries/SD Not used: /Users/ipm/Documents/Arduino/libraries/SD
and is not compatible with Adafruit.
 
The Adafruit graphics library for the display does not currently support T4.x boards.
Interesting. I had no problem using it with the SSD1306 displays (128x32 OLED) I have. For the ST7735, I will try again with the ST7735_t3 driver. Ultimately, I need to be able to use both displays in the same project, so it sounds like I probably have some more figuring out to do even after I get the ST7735 display working. Also I don't see a SSD1306 driver in the teensy stuff, but maybe I can make it work with both libraries, in due time.

Thanks for the tips! I'll report back.

- Ian
 
Its not so much the GFX lib but the hooks into their display driver. The T4x (IMXRT1060) use 32bit registers so thats why you are seeing errors:
Code:
#define portOutputRegister(pin)  ((digital_pin_to_info_PGM[(pin)].reg + (uint8_t)0))
cannot convert 'volatile uint32_t*' {aka 'volatile long unsigned int*'} to 'volatile uint8_t*' {aka 'volatile unsigned char*'}
.
The display driver for the SD1306 may not use this format for their driver.
 
Sorry, I am sort of lost on this one. Which example sketch are you using?
If for example I try the graphicstest of the Adafruit ST7735 and ST7789 boards library, it compiles just fine for
the Teensy 4.1
 
I use the Adafruit_ST7735 lib all the time and have no compile issues. In fact I also wrote a menu system for that driver.

I hate to cop out and suggest this, but try 1) reboot your machine 2) delete the lib (display and GFX) and reinstall 3) Maybe delete the Arduino IDE and reinstall as well?
 
Edit2: Got it to work! First problem was that I needed the alternate constructor that lets you pass in `&SPI1`. I also had a wiring mistake. (I'm an old fart at this point with bad vision and the angled screening of the pin numbers has caught me before. Maybe I should get a pair of 2x readers for this work. Who knows?)

@KrisKasprzak I would rather not cut the LED trace, so I changed all the pin defines to SPI1 (and rewired), but the LED still blinks, and nothing is triggering my scope on CLK1 or MOSI1 (I do see some high frequency signal on pin 13), so I'm guessing it's using SPI0 despite me setting the SPI1 pins. Do you know how to change which SPI interface it's using? Thanks.

Edit: Even if it's not using hardware SPI1 shouldn't it just bit-bang those pins? See the Pin0 CS doing it's thing, but nothing on 26 and 27, and still seeing the activity on 13.
 
Last edited:
Back
Top