Goal: get a TFT screen working. Neil's notes: http://academy.cba.mit.edu/classes/output_devices/index.html ILI9341: 240x320 color TFT driver chip. http://academy.cba.mit.edu/classes/output_devices/TFT/ILI9341.pdf Can send data several ways, including SPI, 8- or 16-bit parallel. Library: https://github.com/olikraus/ucglib uses SPI I think. Not sure exactly what Neil is using, possibly this: https://www.amazon.com/HiLetgo-240X320-Resolution-Display-ILI9341/dp/B073R7BH1B?ref_=ast_sto_dp Will order one of these. I have a "3.5" TFT LCD Shield" http://www.lcdwiki.com/3.5inch_Arduino_Display-UNO Uses ILI9486 color TFT LCD driver chip. Similar to above, chip supports SPI http://www.lcdwiki.com/res/MAR3501/datasheet_ILI9486.pdf But the board I have, I think is hardwired to use 8-bit parallel. Can't use 8-bit parallel with Xiao, not enough pins. This looks like it supports TFT displays on RP2040: https://registry.platformio.org/libraries/bodmer/TFT_eSPI Adafruit's version: https://www.adafruit.com/product/2050 (This one does either 8-bit or SPI, and has a touch screen) I bought HiLetgo ILI9341 2.8" SPI TFT LCD Display Touch Panel 240X320 with PCB 5V/3.3V STM32 https://www.amazon.com/gp/product/B073R7BH1B and https://www.amazon.com/gp/product/B08C7NPQZR LCD Screen Module, 3.5Inch 480 x 320 TFT LCD Display Module, 4 Wire SPI Interface, ILI9488 Driver Chip, Mini TFT Display Module for Electronic DIY, 3.3V~5V Monday update: second one arrived, first one is due this evening. Didn't realize that the 480x320 doesn't do touch-screen! And the Amazon reviewer comment said so and I ignored it! Whoops! Fine for this week though. Also it's SPI-only, which I knew, but man, I should have bought the Adafruit one. Touchscreen and both 8-bit / SPI input. Possible libraries to use it with: Adafruit: https://learn.adafruit.com/adafruit-3-5-color-320x480-tft-touchscreen-breakout/ Bodmer: https://registry.platformio.org/libraries/bodmer/TFT_eSPI I'll try Adafruit with an Uno, first, for maximum chance of success. Wiring: Amazon page has zero documentation. Title says this can take 3-5V, so it should be Uno compatible... https://learn.adafruit.com/adafruit-3-5-color-320x480-tft-touchscreen-breakout/spi-wiring-and-test Uno pin --> TFT pin 5V --> VCC GND --> GND 10 --> CS (Chip select) NC --> Reset (TFT reset) 9 --> DC/RS (Data vs command selector) 11 --> SDI (MOSI) 13 --> SCK NC --> LED (PWM LED brightness) 12 --> SDO (MISO) Use graphicstest.ino from Adafruit_HX8357 library. Results: no dice. Backlight flashes a little bit but no grafix. Serial port output: HX8357D Test! Display Power Mode: 0x0 MADCTL Mode: 0x0 Pixel Format: 0x0 Image Format: 0x0 Self Diagnostic: 0x0 This may mean the display isn't talking back to the Uno at all. Idea: while the Adafruit panel looks identical, the HX8357D is a different display than what I have. My display uses the ILI9488 driver. Adafruit supports ILI9341 which is the 320x240 version of the same thing. https://github.com/jaretburkett/ILI9488 has an Adafruit-comptabible library specifically for the ILI9488. But let's try the Adafruit ILI9341 first and see what happens. Oh, duh. I noticed the backlight was flashing dimly whenever the Uno was sending data, which clued me in that the display was hooked up wrong: I had the Uno's MOSI tied to LED rather than the display's MOSI. Now it's pitch black, so probably I just have to provide power to the LED by tying it to +VCC. Oh good, now the display lights up, and meaningless garbage is shown in the top left corner. So let's try that jaretburkett driver. Haha the garbage in the top left corner was the pull-tab for the screen protector, I'm a double idiot. jaretburkett ILI9488 driver does *something* at least, stuff appears on the screen but it's washed out and covered in extra white pixels all over. OK let's try the Bodmer TFT library: https://registry.platformio.org/libraries/bodmer/TFT_eSPI This library requires you to modify User_Setup.h within the library to configure your particular TFT, see below. When I first tried it I got "Sketch too big; see https://support.arduino.cc/hc/en-us/articles/360013825179 for tips on reducing it. text section exceeds available space in board" Uh-oh! Commenting out some of the font-load commands in the User_Setup.h got it to work on the Uno. #define USER_SETUP_INFO "User_Setup" #define ILI9488_DRIVER #define TFT_BL 5 // LED back-light control pin #define TFT_BACKLIGHT_ON HIGH // Level to turn ON back-light (HIGH or LOW) #define TFT_CS 10 // Chip select control pin D8 #define TFT_DC 9 // Data Command control pin #define TFT_RST 6 // Reset pin (could connect to NodeMCU RST, see next line) #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters #define SPI_FREQUENCY 4000000 // Arduino Uno has 16Mhz clock rate, 4 Mhz SPI frequency should be safe. #define SPI_READ_FREQUENCY 4000000 #define SPI_TOUCH_FREQUENCY 2500000 This library worked the same as the jaretburkett+Adafruit library. The graphics drew, but they were washed out and covered in white stripes. Interestingly, the display got *better* when I jiggled the LED jumper. Not perfect, but I was able to make some of the white washout go away. Maybe the display is defective? It came in a slightly torn, badly taped-up box... Let me try it with the RP2040 Xiao and see what happens. Xiao pin --> TFT pin 3V3 --> VCC GND --> GND D7 --> CS (Chip select) D0 --> Reset (TFT reset) D1 --> DC/RS (Data vs command selector) D10 --> SDI (MOSI) D8 --> SCK D3 --> LED (PWM LED brightness) D9 --> SDO (MISO) #define USER_SETUP_INFO "User_Setup" #define ILI9488_DRIVER #define TFT_BL D3 // LED back-light control pin #define TFT_BACKLIGHT_ON HIGH // Level to turn ON back-light (HIGH or LOW) #define TFT_CS D7 // Chip select control pin D8 #define TFT_DC D1 // Data Command control pin #define TFT_RST D0 // Reset pin (could connect to NodeMCU RST, see next line) #define TFT_MISO D9 #define TFT_MOSI D10 #define TFT_SCLK D8 #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters // Start slow and see how we go #define SPI_FREQUENCY 4000000 // Arduino Uno has 16Mhz clock rate, 4 Mhz SPI frequency should be safe. #define SPI_READ_FREQUENCY 4000000 #define SPI_TOUCH_FREQUENCY 2500000 This doesn't work. White screen, no graphics. But I did realize that maybe I wasn't using the TFT_eSPI library with the uno when I thought I was so I'll try that again. Yeah, I wasn't using the TFT_eSPI library earlier. The new library is MUCH MUCH faster, but I still have those horizontal lines on the screen. ------ 3.5" TFT LCD Shield ------ Okay back to basics, let's just start with the 3.5" TFT LCD shield I got from the lab. Which is *hopefully* this: http://www.lcdwiki.com/3.5inch_Arduino_Display-UNO http://www.lcdwiki.com/res/MAR3501/3.5inch_Arduino_8BIT_Module_MAR3501_User_Manual_EN.pdf Setup instructions from (hopeful) manufacturer above. Instructions claim it's a ILI9486 (Other board was supposedly a 9488 I'll have to check) Works great. Interestingly the provided code doesn't use any libraries at all: it just writes directly to the parallel port. Setup instructions from bodmer: https://github.com/Bodmer/TFT_eSPI/issues/448: Use Setup13_ILI9481_Parallel Setup Set pins using comment in lcdwiki's test code: *pin usage as follow: * LCD_CS LCD_CD LCD_WR LCD_RD LCD_RST SD_SS SD_DI SD_DO SD_SCK * Arduino Uno A3 A2 A1 A0 A4 10 11 12 13 * LCD_D0 LCD_D1 LCD_D2 LCD_D3 LCD_D4 LCD_D5 LCD_D6 LCD_D7 * Arduino Uno 8 9 2 3 4 5 6 7 Doesn't compile. PARALLEL_INIT_TFT_DATA_BUS undefined, which seems to be defined only for some processors. Looks like bodmer library only does parallel comms for advanced chipsets (ESP32, RP2040 etc). Which I can't do on the Xiao, not enough pins. Things to try: maybe the 3.5" TFT SPI board I got isn't a ILI9488. The ILI9486 and ILI9481 are similar but are 262k (18-bit) color instead of 16.7M (24-bit). The extra bits might explain the weird color stuff? Also, probably the manufacturer used the least-capable chip. Is there a way to ask the chip what it is? Let's look at the datasheets... i dunno. Let's just try different chipsets. Trying YET ANOTHER library: https://github.com/moononournation/Arduino_GFX This one seems to ahve good support for all kinds of displays. Doesn't compile, may not support Uno. YET ANOTHER library: https://github.com/ZinggJM/ILI9486_SPI Behaves exactly the same as the 9488 libraries. Maybe I'll look at the links in Neil's notes... https://github.com/olikraus/ucglib/wiki/connectili9341 "How to Connect a ILI9341 Display Breakout Board The red breakout board from the following picture is a 3.3V board. It can be connected to the Arduino Due, but requires level shifters for the Uno and Mega boards...." FUCKING LEVEL SHIFTING! The Amazon web page lists the specs for the thing I bought: "5V compatible, use with 3.3V or 5V logic" And then way down at the bottom it says "Note: If you are using this LCD with a 5V device such as an Arduino, be aware that it doesn't work if WITHOUT level shifting to 3.3v logic. Please use level shifters from 5V to 3.3V, it will work then." The 480x320 one says in the title "LCD Screen Module, 3.5Inch 480 x 320 TFT LCD Display Module, 4 Wire SPI Interface, ILI9488 Driver Chip, Mini TFT Display Module for Electronic DIY, 3.3V~5V" But down at the bottom it says "Logic I/O Voltage: 3.3V (TTL)". I hope I haven't cooked these poor guys. FUCK. Quick and dirty level shifting: https://randomnerdtutorials.com/how-to-level-shift-5v-to-3-3v/ Maybe I should just be using the Xiao boards which are 3.3v native. No, the Uno is the only thing I've gotten to half-work. Resistor-based level shifting totally didn't work. Nothing on screen at all. Next step: fuck the Uno, go back to RP2040. Maybe I miswired it. HOLY SHIT IT WORKS. And it's fast. Gets through the whole Adafruit test in a couple of seconds. Okay time to try to make it actually *DO* something.