Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ILI9486 Screen with ESP32 SPI and Parallel #299

Closed
HumamHelfawi opened this issue Feb 4, 2019 · 31 comments
Closed

ILI9486 Screen with ESP32 SPI and Parallel #299

HumamHelfawi opened this issue Feb 4, 2019 · 31 comments

Comments

@HumamHelfawi
Copy link

Hi,
I have this screen (Driver: ILI9486):
20190204_104926

I tried to connect it in parallel as it was decided here #167, I did not get any results.

I connect it using SPI and as it was decibed in Setup11_RPi_touch_ILI9486. I did not get any results.

Is there any other suggestion?

Thank you very much!

@Bodmer
Copy link
Owner

Bodmer commented Feb 4, 2019

The compatible RPi displays have a 16 bit serial interface. You have a display with a 16 bit parallel interface which unfortunately is not compatible with the library.

@Bodmer Bodmer closed this as completed Feb 4, 2019
@HumamHelfawi
Copy link
Author

Thank you very much for your reply!

Just in case someone passes by this issue in the future. I managed to to run it using this settings:

#define ILI9488_DRIVER
#define ESP32_PARALLEL
#define TFT_CS   15  // Chip select control pin (library pulls permanently low
#define TFT_DC   2  // Data Command control pin - use a pin in the range 0-31
#define TFT_RST  -1  // Reset pin, toggles on startup
#define TFT_WR   4  // Write strobe control pin - use a pin in the range 0-31
#define TFT_RD    3  // Read strobe control pin  - use a pin in the range 0-31
#define TFT_D0   22  // Must use pins in the range 0-31 for the data bus
#define TFT_D1   13  // so a single register write sets/clears all bits.
#define TFT_D2    9  // Pins can be randomly assigned, this does not affect
#define TFT_D3   0  // TFT screen update performance.
#define TFT_D4   17
#define TFT_D5   16
#define TFT_D6   27
#define TFT_D7   14

The screen is almost blue which is logical since only the first 8 bits are connected.

@Bodmer
Copy link
Owner

Bodmer commented Feb 4, 2019

Have a look at this thread.

@Bodmer
Copy link
Owner

Bodmer commented Feb 4, 2019

If you wish to try the pseudo 8 bit mode with the TFT_eSPI library then use:

#define PSEUDO_8_BIT

in the setup file. I have neot tried it myself, so cannot guarantee it will work.

@HumamHelfawi
Copy link
Author

Yes the colors are much more realistic now. Thanks again Bodmer!

@flykarlos
Copy link

dear HumamHelfawi and Bodmer
I have few questions regarding connecting display mentioned in first post.
1.

Thank you very much for your reply!

Just in case someone passes by this issue in the future. I managed to to run it using this settings:

#define ILI9488_DRIVER
#define ESP32_PARALLEL
#define TFT_CS   15  // Chip select control pin (library pulls permanently low
#define TFT_DC   2  // Data Command control pin - use a pin in the range 0-31
#define TFT_RST  -1  // Reset pin, toggles on startup
#define TFT_WR   4  // Write strobe control pin - use a pin in the range 0-31
#define TFT_RD    3  // Read strobe control pin  - use a pin in the range 0-31
#define TFT_D0   22  // Must use pins in the range 0-31 for the data bus
#define TFT_D1   13  // so a single register write sets/clears all bits.
#define TFT_D2    9  // Pins can be randomly assigned, this does not affect
#define TFT_D3   0  // TFT screen update performance.
#define TFT_D4   17
#define TFT_D5   16
#define TFT_D6   27
#define TFT_D7   14

The screen is almost blue which is logical since only the first 8 bits are connected.

Working config from this post has DC pin defined, but display does not have one. So which pin on display is DC?

  1. Should I connect also MOSI MISO and SCLK for SPI initialization?
    thanks!

@Bodmer
Copy link
Owner

Bodmer commented Mar 24, 2021

No, those SPI connections only connect to the SD card slot.

The RS pin has the same function as the DC pin, it is just named differently.

@flykarlos
Copy link

Thanks Bodmer, as usual You are extremely helpful. Can You advice about RD pin? Such pin marking is not present on this display..
And should I also #define TFT_PARALLEL_8_BIT before #define ESP32_PARALLEL? I tried many different pin mappings and settings and it does not work. I have exactly the same display as in first post. I am using ESP32-WROVER-B. Thanks in advance!

@drewp
Copy link

drewp commented Mar 25, 2021

DC is sometimes called RS. My board is like http://www.lcdwiki.com/3.5inch_Arduino_Display-UNO and calls it LCD_RS.

The datasheet at https://www.waveshare.com/w/upload/7/78/ILI9486_Datasheet.pdf calls it "D/CX".

I'm working on an esphome driver for these 8-bit boards, and I'm using DC internally since I can remember "data/command mode".

@drewp
Copy link

drewp commented Mar 25, 2021

Sorry, didn't refresh this page today before answering. RD is "RDX" in the spec, and the diagram on page 9 shows "WRX/SCL" as one input. SCL is the spi clock, so I'd guess your board's "CLK" is where to send the RD signal.

@Bodmer
Copy link
Owner

Bodmer commented Mar 26, 2021

It looks like the display is write only, so the RD pin can be left unconnected.

@drewp
Copy link

drewp commented Mar 26, 2021

Mine had to be held at RD=high for communication to work. HTH

I'm up and running in esphome now!
image

@flykarlos
Copy link

flykarlos commented Mar 26, 2021

Thanks guys!
I managed to make it work with pseudo 8bit mode. But I have a problem displaying text:
IMG_2409
Image shows below program drawing text "TEST" on sprite pushed to tft. Text looks distorted, almost like angled by some strange angle.

#include <TFT_eSPI.h>                
TFT_eSPI    tft = TFT_eSPI();         
TFT_eSprite spr = TFT_eSprite(&tft);

int colors_data[12]={0x0000, 0x1818, 0xE0E0, 0x0707, 0x7777, 0xF8F8, 0xE7E7, 0xFFFF, 0xB5B5, 0x6B6B, 0xF4F4, 0xE4E4};
int i = 0;




void setup()
{
  tft.init();
  spr.setColorDepth(8);
  spr.createSprite(200, 200);
  spr.setTextColor(0xE7E7, 0x0000);
}

void loop(void)
{
  tft.fillScreen(colors_data[i]);
  spr.drawString("TEST",100 ,100, 2);
  spr.pushSprite(60, 140);
  i = (i == 12) ? 0 : i+1;
  delay(2000);
}

Thanks for help!

@flykarlos
Copy link

Ok, disregard last post. Seems that spr.setColorDepth(8); was causing the problem. Removed it and now image looks better..

@Bodmer
Copy link
Owner

Bodmer commented Mar 26, 2021

You should be able to set the colour depth to 1, 4, 8 and 16 bpp, this works OK on my SPI display.

I do not have a psuedo16 bit setup to test so maybe it is just that interface that is the problem?

@flykarlos
Copy link

flykarlos commented Mar 27, 2021

Thanks Bodmer for Your efforts to help me each time I am writing here with a problem.
When I use color depth settings other than 16 bpp the sprite used with this setting goes black.
I reinstalled library to make sure my problems are not caused by my modifications done to library.
I am using this user_setup.h:

#define ILI9486_DRIVER
#define ESP32_PARALLEL
#define PSEUDO_16_BIT

#define TFT_CS   19  
#define TFT_DC  3 
#define TFT_RST  15 
#define TFT_WR   18  
#define TFT_RD    -1  
#define TFT_D0   4
#define TFT_D1   26 
#define TFT_D2    2
#define TFT_D3   14 
#define TFT_D4   13
#define TFT_D5   12
#define TFT_D6   25
#define TFT_D7   27

#define LOAD_GLCD   
#define LOAD_FONT2 
#define LOAD_FONT4  
#define LOAD_FONT6 
#define LOAD_FONT7
#define LOAD_FONT8  
#define LOAD_FONT8N
#define LOAD_GFXFF

#define SMOOTH_FONT

I am using Rotated_Sprite_1.ino example with addition of color definitions supporting PSEUDO_16_BIT mode:

#define TFT_BLACK   0x0000
#define TFT_BLUE    0x1818
#define TFT_RED     0xE0E0
#define TFT_GREEN   0x0707
#define TFT_CYAN    0x7777
#define TFT_MAGENTA 0xF8F8
#define TFT_YELLOW  0xE7E7
#define TFT_WHITE   0xFFFF
#define TFT_LIGHT_GREY  0xB5B5
#define TFT_DARKGREY   0x6B6B
#define TFT_PINK    0xF4F4
#define TFT_ORANGE  0xE4E4

I wired display D8-D15 pins as you described here
If I use this or any other example with text there is distortion in displayed image. It looks like each second pixel line is missing:

IMG_2413
IMG_2412

on the other hand same example displays numbers correctly(note: blue line is most probably caused by wiring interference):
IMG_2411

thanks for advices!

EDIT:
Rotated_sprite_2.ino:
IMG_2414

@Bodmer
Copy link
Owner

Bodmer commented Mar 27, 2021

OK, I just realised that the pseudo 16 bit mode must have been removed at some point. Not sure which version I did this but some earlier versions of TFT_eSPI did have this feature...

The problem is that every pixel (except single drawPixel where it does not matter) is being written twice. As the library expects to write 2 x 8 bit values it generates 2 write stobes per pixel. So, what I need to do is reinstate that mode. I will look to see if that is easy to do.

@flykarlos
Copy link

Thank You so much!

Bodmer added a commit that referenced this issue Mar 27, 2021
@Bodmer
Copy link
Owner

Bodmer commented Mar 27, 2021

I have updated the master copy on github with the changes I think are needed, please test.

Only the files TFT_eSPI_ESP32.h and TFT_eSPI_ESP32.c have been updated so you do not need to copy the entire library over.

@flykarlos
Copy link

flykarlos commented Mar 27, 2021

IMG_2417
Works beautifully now!
outstanding!
thanks a lot :)

@Bodmer
Copy link
Owner

Bodmer commented Mar 27, 2021

Yay! I think you are the first user of that feature.

Enjoy!

@flykarlos
Copy link

I will test it extensively, thank You so much!

@dinas80
Copy link

dinas80 commented Mar 28, 2021

@Bodmer @drewp
I have the same tft model as "drewp" and I want to make it work with esp32 so can anyone please tell me how to wire it, and what code did you use or which library settings

@drewp
Copy link

drewp commented Mar 29, 2021

Hi, I'm happy to try to help, but note that this is a ticket for the TFT_eSPI which I am not using. If you want to use my esphome code, we should discuss that on the esphome discord or in an esphome issue.

Here are my wiring notes:

# ili9486 setup
# http://www.lcdwiki.com/3.5inch_Arduino_Display-UNO
# (https://www.aliexpress.com/item/4000055026873.html $12)
# and https://circuits4you.com/wp-content/uploads/2018/12/ESP32-Pinout.jpg

#       GND      - GND  Power ground
#       5V       - 5V   5V power input
#       NC       - 3V3  3.3V power input, this pin can be disconnected
#       GND      - LCD_RST      LCD bus reset signal, low level reset
#       GND      - RESET      (not sure- just tied it to gnd)
#       NC         - F_CS         (not sure)
#
#       GPIO16   - LCD_CS       LCD bus chip select signal, low level enable
#
#       GPIO17   - LCD_RS       (aka DC) LCD bus command / data selection signal, low level: command, high level: data
#       GPIO5    - LCD_WR       LCD bus write signal
#       GPIO18   - LCD_RD       LCD bus read signal

#       GPIO33   - LCD_D0       LCD 8-bit data Bit0
#       GPIO32   - LCD_D1       LCD 8-bit data Bit1
#       GPIO13   - LCD_D2       LCD 8-bit data Bit2
#       GPIO12   - LCD_D3       LCD 8-bit data Bit3
#       GPIO14   - LCD_D4       LCD 8-bit data Bit4
#       GPIO27   - LCD_D5       LCD 8-bit data Bit5
#       GPIO26   - LCD_D6       LCD 8-bit data Bit6
#       GPIO25   - LCD_D7       LCD 8-bit data Bit7

Then I hacked this esphome fork (of someone else's fork) together: drewp/esphome@c160835

I receive mqtt lines and display them with this esphome code: drewp/homeauto@02c7c33

@Bodmer
Copy link
Owner

Bodmer commented Mar 29, 2021

Note that the display used by the OP has NOT got a RD pin, see image posted, so @drewp must have a different display.

Check the pinout of the display to see which it is. Post a link or picture of the back of the board to be sure.

@dinas80
Copy link

dinas80 commented Mar 29, 2021

@drewp Thank you so much, I really appreciate your help
I'm not familiar yet with esphome so it'll be very hard to keep up with you, once I'm if there were any issues I'll get back to you.

@dinas80
Copy link

dinas80 commented Mar 29, 2021

@Bodmer there's my board
I got it to display, but I'm facing a problem with the touch demo, and when I tried your solution for issue #117 it says can't compile so if you can help me with this it'll be great
PHOTO-2021-03-29-02-38-19

@flykarlos
Copy link

flykarlos commented Mar 29, 2021

Hi Bodmer, can You advice if antialiased/smooth fonts may be used with good effect with pseudo_16_bit mode? I tried some examples, but font edges are ragged.. Maybe it is a background color blending problem?

@Bodmer
Copy link
Owner

Bodmer commented Mar 29, 2021

@dinas80 Your display will have a resistance based analogue interface (assuming the screen has this fitted!). The TFT_eSPI library does not provide support for that type of interface. The complication is that the touch interface shares the pins with other TFT screen interface pins!

The good news is that a user has created a library for these UNO style displays. See last paragraph of this section.

@Bodmer
Copy link
Owner

Bodmer commented Mar 29, 2021

@flykarlos Good point, you will not be able to use the smooth fonts as the anti-aliasing will not work.

@zaydsaoudi
Copy link

Hi Bodmer , i need some help with tft shield uno 2.8
I have touche problem with parallel interfacing , i use the tft_espi and touche.h library , i tried touch_cs too
Nothing working with me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants