# Lilygo TTGO, TFT_eSPI, and the Dino/T-Rex Game


Ever since the Espressif's [ESP8266](https://en.wikipedia.org/wiki/ESP8266) wi-fi capable microcontroller was launched, I've been thinking about all the possibilities for low cost network connected devices. And, nothing world changing, but I have used it to build [a data logging CO2 monitor](../inexpensivesensorsproxycovidrisk/) and [a device to control my old TV with Alexa](/me/?p=496).

I have been thinking of NEW possibilities as I see development boards with the ESP8266's successor, the [ESP32, with a small screen, for less than $20CAD shipped from Aliexpress](https://www.aliexpress.com/item/33050667207.html). What can I build with a really tiny internet connected dashboard? So I ordered a Lilygo TTGO.

A day after it arrived, Hackaday published an article about a re-creation of Google Chrome's [T-Rex game for this TTGO dev board](https://hackaday.com/2021/12/15/googles-t-rex-game-ported-to-the-esp32/). Getting that loaded on to the board seems like a good test. I downloaded the [TRexTTGOdisplay](https://github.com/VolosR/TRexTTGOdisplay) and installed [Lilygo's TFT\_eSPI](https://github.com/Xinyuan-LilyGO/TTGO-T-Display) driver, compiled and...  
  
``undefined reference to `TFT_eSprite::pushToSprite(TFT_eSprite*, int, int, unsigned short)'``

Hmm. I search around, and I see a hint in the comment's of the [author's Youtube video](https://www.youtube.com/watch?v=ilC4LIQZ77g): "You will need to update tft library". I find the source of the [TFT\_eSPI library](https://github.com/Bodmer/TFT_eSPI), review it a bit, and see that it is designed for a number of microcontrollers and screen controllers - so I copy the _User\_Setup\_Select.h_ from the Lilygo repository to Bodmer's most recent TFT\_eSPI libary. For anyone doing this now, this will fix the `TFT_eSprite::pushToSprite` issue and just work... but I got:  
  
`TFT_eSPI/TFT_eSPI.cpp: In member function 'virtual void TFT_eSPI::drawPixel(int32_t, int32_t, uint32_t)':  
TFT_eSPI/TFT_eSPI.cpp:3289:21: error: 'SPI_X' was not declared in this scope  
while (spi_get_hw(SPI_X)->sr & SPI_SSPSR_BSY_BITS) {};`

  
I take a look at what's happening around line 3289 in TFT\_eSPI.cpp, and it appears to be optimization code for the RP2040 - it shouldn't be compiled in... Taking a look at line 3285:  

`// Temporary solution is to include the RP2040 optimised code here`  
`#elif (defined (ARDUINO_ARCH_RP2040) || **!**defined (ARDUINO_ARCH_MBED)) && !defined(TFT_PARALLEL_8_BIT)`

See that exclamation point? And everywhere else in the code there are RP2040 optimizations, I see:

`//Temporary solution is to include the RP2040 optimised code here`  
`#elif (defined (ARDUINO_ARCH_RP2040) || defined (ARDUINO_ARCH_MBED)) && !defined(TFT_PARALLEL_8_BIT)`

Cool, I'll submit a patch. So I fork the code, and... [I don't see the bug, it's already been fixed](https://github.com/raudette/TFT_eSPI/commit/e66d0f4069759eced6165a9ff7c0dc953b303bda).  
  
I was hoping for another successful contribution to open source, but I was beaten to the punch - if I had started this project a day later, it just would have worked with the latest TFT\_eSPI library. In any case, the important thing is, I got TRexTTGOdisplay running. My next project for this dev board will be a little internet connected dashboard.

