TFT display works with ARM uLisp 4.4b but not 4.5a


#1

I found that my 2.4" display 320x240 ILI9341 does not work with brand new version of ulisp-arm 4.5a, however it does work with version 4.4b with commentaries - both versions are taken from current GitHub master branch.

What is confusing for me is that I cannot see any significant difference between these two files. In both files the same sections of code were added/altered by me:

#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_QTPY_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_SEEED_XIAO_RP2040)
#define WORKSPACESIZE (22912-SDSIZE) /* Objects (8*bytes) /
#define LITTLEFS
#include <LittleFS.h>
#define FILE_WRITE_BEGIN “w”
#define FILE_READ “r”
#define CODESIZE 256 /
Bytes */
#define STACKDIFF 320
#define CPU_RP2040
#if defined(gfxsupport)
const int COLOR_WHITE = 0xffff, COLOR_BLACK = 0;
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#define TFT_CS 17
#define TFT_DC 15
#define TFT_RST 14
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
#endif

and:

void initgfx () {

#elif defined(ARDUINO_RASPBERRY_PI_PICO)
tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9341_GREEN);
#endif
#endif

I cannot share these whole files here. If you need them, please, let me know.
Thanks in advance!
Petr


#2

Init of the ILI9341 does not work like this, it needs four pins, e.g.
#define PIN_TFT_CS 9
#define PIN_TFT_DC 10
#define PIN_TFT_MOSI 23
#define PIN_TFT_SCLK 24
(…)
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
Adafruit_ILI9341 tft = Adafruit_ILI9341(PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_MOSI, PIN_TFT_SCLK);

(replace pin assignments with the ones you use, in case of the Feather RP2040 it should be 9, 10, 19, 18 in the order above)

EDIT: This applies to the SPI version at least, right now I’m not sure whether there’s an I2C version as well.


#3

What you are showing, I believe, is software SPI of Pico. I want to use hardware SPI.

Adafruit_ILI9341.cpp

//
/*!
@brief Instantiate Adafruit ILI9341 driver with software SPI
@param cs Chip select pin #
@param dc Data/Command pin #
@param mosi SPI MOSI pin #
@param sclk SPI Clock pin #
@param rst Reset pin # (optional, pass -1 if unused)
@param miso SPI MISO pin # (optional, pass -1 if unused)
*/
/
/
Adafruit_ILI9341::Adafruit_ILI9341(int8_t cs, int8_t dc, int8_t mosi,
int8_t sclk, int8_t rst, int8_t miso)
: Adafruit_SPITFT(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT, cs, dc, mosi, sclk,
rst, miso) {}

//
/*!
@brief Instantiate Adafruit ILI9341 driver with hardware SPI using the
default SPI peripheral.
@param cs Chip select pin # (OK to pass -1 if CS tied to GND).
@param dc Data/Command pin # (required).
@param rst Reset pin # (optional, pass -1 if unused).
*/
/
/
Adafruit_ILI9341::Adafruit_ILI9341(int8_t cs, int8_t dc, int8_t rst)
: Adafruit_SPITFT(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT, cs, dc, rst) {}

As hardware SPI has always the same designated PINs, the library can figure them out from the board description. CS, DC are not integral part of HW SPI since they are perifery specific.

Anyway I tried using the SW SPI constructor with both versions and the result is the same. Version 4.4b works, version 4.5a does not. So the problem might be somewhere else…

If you have any suggestions what I should double check, let me know. Thanks!


#4

@pogurek I’ve compared uLisp ARM 4.4b and uLisp ARM 4.5a and the only relevant differences I can see is that I’ve added support for the 240x135 colour TFT display on the LILYGO T-Display RP2040:

LILYGO T-Display RP2040

These additions only take effect if you are using the Raspberry Pi Pico board option (or another RP2040 board), and have #define gfxsupport uncommented.

Please give a few more details about what board you are using, and what Arduino IDE board option you have selected, and I’ll try and help.


#5

Hello, @johnsondavies! Thank you for stepping in.

Yes, I saw your change of adding support for LILYGO T-Display RP2040. And I just reused your code almost 100% the same, but change it for a noname display 2.4" TFT 240x320.

Please see my both files:
https://drive.google.com/file/d/1Op0cmkAZF1OLR9AE2JEM3-nBAwtMrb2Y/view?usp=sharing

I use Windows 11 and Arduino IDE with the option of Raspberry Pi Pico - ARDUINO_RASPBERRY_PI_PICO
Version: 2.2.1
Date: 2023-08-31T14:35:44.802Z
CLI Version: 0.34.0
with this Arduino Core:
earlephilhower/arduino-pico: Raspberry Pi Pico Arduino core, for all RP2040 boards (github.com)

The board is standard Raspberry Pi Pico.

I did look at diff of those files and I did not find any significant change, either. Hope I won’t be embarassed by making some silly mistake :)

Thank you!


#6

Are you saying that uLisp4.4b-Pico-TFT2.4 works but uLisp4.5a-Pico-TFT2.4 doesn’t?


#7

Exactly!


#8

The only significant difference I can see is that in sp_withspi() release 4.4b has:

  #if defined(ARDUINO_NRF52840_CLUE) || defined(ARDUINO_GRAND_CENTRAL_M4) || defined(ARDUINO_PYBADGE_M4) || defined(ARDUINO_PYGAMER_M4) || defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41)
  if (address == 1) spiClass = &SPI1;
  #endif

whereas release 4.5a has:

  #if defined(ULISP_SPI1)
  if (address == 1) spiClass = &SPI1;
  #endif

where ULISP_SPI1 is defined as:

#if defined(ARDUINO_NRF52840_CLUE) || defined(ARDUINO_GRAND_CENTRAL_M4) || defined(ARDUINO_PYBADGE_M4) || defined(ARDUINO_PYGAMER_M4) || defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#define ULISP_SPI1
#endif

So on ARDUINO_RASPBERRY_PI_PICO release 4.4b doesn’t support SPI1 whereas 4.5a does.

I can’t immediately see why this would make a difference, but you could try applying this change to 4.5a and see if your TFT display then works.


#9

So, after getting through tests of versions 4.4a,b,d, 4.5 and 4.5a I found my stupid mistake - I forgot to somehow uncomment the gfxsupport.

What I can at least conclude is that the ILI9341 display works as expected. And also HW and SW SPI (SPI0) works. Using the short constructor will utilize the hardware SPI, while the long constructor will use software SPI (even with the HW SPI dedicated pins).

  #if defined(gfxsupport)
  const int COLOR_WHITE = 0xffff, COLOR_BLACK = 0;
  #include <Adafruit_GFX.h>
  #include <Adafruit_ILI9341.h>
  #define TFT_CS  17
  #define TFT_DC  15
  #define TFT_RST 14
  Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);    /* HW SPI /
  # define TFT_MOSI 19
  # define TFT_CLK 18
  // Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, -1);    /
SW SPI */
  #endif

Thank you for your support and I apologize for wasting your time!


#10

No problem - I’m glad you solved it!


#11