openHASP icon indicating copy to clipboard operation
openHASP copied to clipboard

Makerfabs MaTouch TFT Parallel 5" Support - Initial ini included!

Open jonofmac opened this issue 7 months ago • 15 comments

Hello, I took a stab at creating the .ini file for the MakerFabs S3 TFT Parallel 5" touch screen device.

Product Link: https://www.makerfabs.com/matouch-esp32-s3-parallel-tft-with-touch-5.html

I dug through the schematic and example code and built a .ini file that appears to function for the most part. I am getting some minor screen glitches that I need to figure out, but maybe someone more experienced can help me with it. Touch screen works. Screen works 99% (randomly glitches every few seconds). Wifi works.

makerfabs-s3-tft50-parallel.ini

;***************************************************;
;   Makerfabs ESP32-S3 Parallel TFT With Touch 5"   ;
;               - 5" RGB Parallel TFT               ;
;               - GT911 touch controller            ;
;***************************************************;

[env:makerfabs-s3-tft50-parallel]
extends = arduino_esp32s3_v2, flash_16mb
board = esp32-s3-devkitc-1
board_build.arduino.memory_type = qio_opi

build_flags =
    -D HASP_MODEL="Makerfabs ESP32-S3 Parallel TFT With Touch 5.0"
    ${arduino_esp32s3_v2.build_flags}
    ${esp32s3.ps_ram}

;region -- ArduinoGFX build options ------------------------
    -D HASP_USE_ARDUINOGFX=1
    -D HASP_LV_USE_SW_ROTATE=1
    -D TFT_WIDTH=800
    -D TFT_HEIGHT=480
    ; Bus Settings
    -D TFT_DE=40
    -D TFT_VSYNC=41
    -D TFT_HSYNC=39
    -D TFT_PCLK=42
    -D TFT_R0=45
    -D TFT_R1=48
    -D TFT_R2=47
    -D TFT_R3=21
    -D TFT_R4=14
    -D TFT_G0=5
    -D TFT_G1=6
    -D TFT_G2=7
    -D TFT_G3=15
    -D TFT_G4=16
    -D TFT_G5=4
    -D TFT_B0=8
    -D TFT_B1=3
    -D TFT_B2=46
    -D TFT_B3=9
    -D TFT_B4=1
    -D TFT_BCKL=10
    ; Panel Settings
    -D TFT_HSYNC_POLARITY=0
    -D TFT_HSYNC_FRONT_PORCH=8
    -D TFT_HSYNC_PULSE_WIDTH=4
    -D TFT_HSYNC_BACK_PORCH=8
    -D TFT_VSYNC_POLARITY=0
    -D TFT_VSYNC_FRONT_PORCH=8
    -D TFT_VSYNC_PULSE_WIDTH=4
    -D TFT_VSYNC_BACK_PORCH=8
    -D TFT_PCLK_ACTIVE_NEG=1
    -D TFT_PREFER_SPEED=16000000
    -D TFT_AUTO_FLUSH=1
    -D TFT_BACKLIGHT_ON=0
    ; Touch Settings
    -D TOUCH_WIDTH=800
    -D TOUCH_HEIGHT=480
    -D TOUCH_DRIVER=0x911
    -D TOUCH_SCL=18
    -D TOUCH_SDA=17
    -D TOUCH_IRQ=-1
    -D TOUCH_RST=38
    -D I2C_TOUCH_ADDRESS=0x5D
    -D I2C_TOUCH_FREQUENCY=400000
;endregion

lib_deps =
    ${arduino_esp32s3_v2.lib_deps}
    ${arduinogfx.lib_deps}
    Arduino_RPi_DPI_RGBPanel_mod
    ${goodix.lib_deps}

jonofmac avatar Apr 29 '25 18:04 jonofmac

An update: the components seem to work. Glitches seem to only happen while I'm actively touching the screen. It kind of looks like the screen loses sync between the different color channels. Attaching good and bad frame. I tried dropping the screen frequency and that just completely broke the display.

Image Image

jonofmac avatar Apr 29 '25 19:04 jonofmac

How can I recreate this? Can you upload your pages.json here?

marsman7 avatar May 01 '25 11:05 marsman7

I made a pages file that does a good job of glitching the screen without any user input. You'll see:

  • Screen tearing on motion
  • Color glitching/shifting for a frame
  • Image bouncing around (like the origin is shifting)
  • Stuttering (this might be CPU load related, not sure what realistic FPS to expect is)

As a note: I saw this behavior when interacting with the display. This page is able to create the same glitches without any user input required. Not sure if it's a CPU load thing, but I was seeing the same glitches even on simple screens, and entering the wifi password.

Edit: I've tried the following settings changes

  1. Increase clock to 240 MHz: No change
  2. Decrease clock to 80 MHz: Glitching appears worse/more consistent
  3. Set HASP_USE_ARDUINOGFX=0: No change
  4. Tried increasing porch values (honestly no idea what these do, but some googling suggested this affects screen drawing). Increasing these made the glitching MUCH worse
  5. Tried decreasing porch values: Still glitches, but the drawing has "ghost" frames. Clearly this is wrong.
  6. Decrease TFT preferred speed: Breaks drawing altogether. I just get solid RGB colors on the display
  7. Flipped polarity of VSYNC and HSYNC: Surprisingly, no change at all.
  8. Found the panel datasheet: https://github.com/Makerfabs/Matouch_ESP32-S3_Parallel_TFT_with_Touch_5/blob/main/datasheet/FTD50B7008-D.pdf and making the settings match this results in a non functional display. For some reason changing the preferred speed to anything but 16M seems to just break the panel.
{"page":0,"comment":"Page 0"}
{"id":1,"obj":"spinner","x":20,"y":240,"w":236,"h":236,"angle":45,"line_color10":"#ffffff","pad_top":8,"pad_right":8,"pad_left":8,"pad_bottom":8,"type":2,"line_width":15,"line_width10":15}
{"id":2,"obj":"spinner","x":80,"y":300,"w":121,"h":121,"angle":45,"line_color10":"#ffffff","pad_top":8,"pad_right":8,"pad_left":8,"pad_bottom":8,"speed":600,"type":2,"line_width":15,"line_width10":15}
{"id":3,"obj":"spinner","x":20,"y":0,"w":240,"h":243,"angle":45,"line_width":50,"line_width10":50,"line_rounded10":false,"line_color10":"#ff0000","pad_top":8,"pad_right":8,"pad_left":8,"pad_bottom":8,"type":2}
{"id":4,"obj":"spinner","x":280,"y":0,"w":238,"h":238,"direction":true,"angle":45,"line_width":50,"line_width10":50,"line_rounded10":false,"line_color10":"#00ff00","pad_top":8,"pad_right":8,"pad_left":8,"pad_bottom":8,"speed":1300,"type":2}
{"id":5,"obj":"spinner","x":540,"y":0,"w":240,"h":236,"direction":true,"angle":100,"line_width":70,"line_width10":70,"line_rounded10":false,"line_color10":"#0000ff","pad_top":8,"pad_right":8,"pad_left":8,"pad_bottom":8,"speed":600,"type":2}
{"id":6,"obj":"cpicker","x":580,"y":260,"w":200,"h":200}
{"id":7,"obj":"spinner","x":300,"y":240,"w":240,"h":232,"angle":200,"line_width":50,"line_width10":50,"line_rounded10":false,"pad_top":8,"pad_right":8,"pad_left":8,"pad_bottom":8,"speed":1300,"type":2}

https://github.com/user-attachments/assets/bf5b22bb-4727-4d8e-ae08-7c96c34998d2

jonofmac avatar May 01 '25 16:05 jonofmac

I have a Elecrow 5 inch HMI with ESP32-S3. No problems with your pages.json.

marsman7 avatar May 01 '25 16:05 marsman7

Interesting, are you using a custom .ini file? Can you point me to the .ini file you're using? Maybe i have an issue with my config somewhere else rather than panel settings.

jonofmac avatar May 01 '25 16:05 jonofmac

i use the "elecrow-s3-8048c050_4MB" from crowpanel-hmi.ini. But other TFT use other settings.

marsman7 avatar May 01 '25 17:05 marsman7

Try lowering TFT_PREFER_SPEED to 8, 10, 12, 14 Mjz... some experimentation could be required. I think the frequency is too high for pushing that much pixel changes rapidly. The ESP32 isn't great at fast animations at high speeds, and the board design also matters. It could be Electromagnetic interference (EMI)... To me it looks like the pixel clock gets out of sync or can't keep up, resulting in missed data and glitches.

fvanroie avatar May 01 '25 18:05 fvanroie

Try lowering TFT_PREFER_SPEED to 8, 10, 12, 14 Mjz... some experimentation could be required. I think the frequency is too high for pushing that much pixel changes rapidly. The ESP32 isn't great at fast animations at high speeds, and the board design also matters. It could be Electromagnetic interference (EMI)... To me it looks like the pixel clock gets out of sync or can't keep up, resulting in missed data and glitches.

I've tried several different preferred speeds, but anything except 16 MHz breaks the display and I just get red, green, blue, black rotating. No idea why. I've tried 14, 12, 10, 8, 6, 4, 2 MHz, and it's the same behavior for ALL of it. Almost like the S32 device is just creating some default output when the clock doesn't line up with something?

Here's the panel's datasheet for timing. Image

    -D TFT_HSYNC_POLARITY=0
    -D TFT_HSYNC_FRONT_PORCH=40
    -D TFT_HSYNC_PULSE_WIDTH=48
    -D TFT_HSYNC_BACK_PORCH=88
    -D TFT_VSYNC_POLARITY=0
    -D TFT_VSYNC_FRONT_PORCH=13
    -D TFT_VSYNC_PULSE_WIDTH=3
    -D TFT_VSYNC_BACK_PORCH=32
    -D TFT_PCLK_ACTIVE_NEG=1
    -D TFT_PREFER_SPEED=16000000

This results in a black display. Toggling the polarities is making no difference either. I ntoiced the pulse width DOES make a difference on if I get an image or not, though. Playing with any of the 3 polarities makes no discernible difference.

jonofmac avatar May 01 '25 18:05 jonofmac

From other configs/displays I typically use these values from the datasheet:

  • Maximum HSYNC/VSYNC Front Porch
  • Typical HSYNC/VSYNC Pulse Width
  • Typical HSYNC Back Porch
  • Half of Typical DCLK Frequency

So try:

    -D TFT_HSYNC_POLARITY=0
    -D TFT_HSYNC_FRONT_PORCH=255  // can lower this later to optimize
    -D TFT_HSYNC_PULSE_WIDTH=48
    -D TFT_HSYNC_BACK_PORCH=88
    -D TFT_VSYNC_POLARITY=0
    -D TFT_VSYNC_FRONT_PORCH=255  // can lower this later to optimize
    -D TFT_VSYNC_PULSE_WIDTH=3
    -D TFT_VSYNC_BACK_PORCH=32
    -D TFT_PCLK_ACTIVE_NEG=1
    -D TFT_PREFER_SPEED=15000000  // or 16Mhz if that works better

This is all experimental and each device is different. Extending the Front Porch values might help keep the ESP and display in sync better.

fvanroie avatar May 01 '25 18:05 fvanroie

The settings resulted in a solid white display. I changed speed back to 16M, still got white. It's worth noting that every time I flash, I unplug and replug the USB to do a full power cycle on the display, because I noticed sometimes settings don't seem to affect the display output until I do that.

  1. So I rolled the front porchs back to what was "sort of" working and increased the front porches to the 255 limit: White display.
  2. Tried 200: White display
  3. Tried 175: White display
  4. Tried 150: Image, but glitching about as much as before
  5. Tried 128: Image, but it glitches about as much as before (using same settings as I posted above for other settings)
  6. Tried 64: Same as above

So now I figured I should try increasing the back porch values. So I'll leave front at 64 since that leaves some margin with where I was getting white screens. So now varying back porch on horizontal

  1. 8: What I've been using. It works but glitches
  2. 88 (per datasheet)): No noticeable change from 8.

Now I change vsync back porch:

  1. 8: What I've been using. Works but glitches
  2. 32 (per datasheet): Same as above. No noticeable difference

Now I try changing the pulse width of hsync:

  1. 4: Works but glitches.
  2. 48 (Per datasheet): White display
  3. 40: White display
  4. 32: White display
  5. 24: White display
  6. 16: White display
  7. 8: Functional image, but glitching remains as constant as original settings
  8. 1: Functional image, but glitching remains as constant as original settings
  9. 1, but I flipped the HSYNC polarity to see if it changes anything: Exactly the same behavior as above 8.

Now I try changing the pulse width of vsync:

  1. 3 (per datasheet): Works but glitches
  2. 255: Solid color screen rotating through white, black, red, green, and blue
  3. 128: Same as above
  4. 64: Image works. I am seeing glitching, but the good news is I'm not seeing the image bouncing up and down during the glitch, it's just color glitching or going solid black
  5. 64, but with the vsync polarity = 1 instead of 0: Same as above. So roll polarity back to 0 for next.
  6. 32: The vertical bouncing/glitching is back.
  7. 16: Same as above.
  8. 48: Same as above
  9. 56: Less vertical bouncing, but not none.

I don't believe the HSYNC or VSYNC polarity does anything. I'm not very familiar with this interface, but what I can find googling seems to show that you either use the HSYNC and VSYNC pins or you use the DE pin to control data latching, so since DE is defined, I guess that makes sense why HSYNC and VSYNC seem to do nothing. I figured I'd try using the SYNC pins instead of DE since the schematic shows it's pinned out, but that did not compile (complained about no DE definition).

TLDR: Not any real meaningful changes after turning every knob. It almost seems like 16 MHz is just too fast for the display. But I don't understand why anytime I slow the clock down, i get no image.

I tried changing the clock to 12 MHz as my only change: white screen.

I don't get it.... Not sure if it matters, but I am using 0.7.0-rc13 branch.

jonofmac avatar May 01 '25 19:05 jonofmac

I don't think it has to do with openHASP firmware, other sketches with the same parameters will give the same results.

Their example code uses:

   800 /* width */, 0 /* hsync_polarity */, 8 /* hsync_front_porch */, 4 /* hsync_pulse_width */, 8 /* hsync_back_porch */,
   480 /* height */, 0 /* vsync_polarity */, 8 /* vsync_front_porch */, 4 /* vsync_pulse_width */, 8 /* vsync_back_porch */,
   1 /* pclk_active_neg */, 16000000 /* prefer_speed */, true /* auto_flush */);

so lower porches to 8 and slightly higher pulse width of 4.

fvanroie avatar May 01 '25 20:05 fvanroie

I don't think it has to do with openHASP firmware, other sketches with the same parameters will give the same results.

Their example code uses:

800 /* width /, 0 / hsync_polarity /, 8 / hsync_front_porch /, 4 / hsync_pulse_width /, 8 / hsync_back_porch /, 480 / height /, 0 / vsync_polarity /, 8 / vsync_front_porch /, 4 / vsync_pulse_width /, 8 / vsync_back_porch /, 1 / pclk_active_neg /, 16000000 / prefer_speed /, true / auto_flush */);

so lower porches. to 8.. and slightly higher pulse width of 4.

This is what I originally copied from to get the settings provided in the original post. Wonder if I just have a dud part or something.

jonofmac avatar May 01 '25 20:05 jonofmac

Try the examples from their Github, if those don't work... it could be a hardware issue.

fvanroie avatar May 01 '25 20:05 fvanroie

Ugh. The demo code works. The hard part is that there's just not enough refreshes to really break it.

I wrote some basic code to bounce 2 squares around the screen as quick as it can (but still quite slow because their tasks have really slow ticks).

This certainly seems to be something specific to openhasp.

I do see some screen tearing on this example code, but none of the weird color glitching issues, though.

jonofmac avatar May 01 '25 20:05 jonofmac

I am running the Elecrow 5" and also see tearing... Version | 0.7.0-rc12 cd34d89 elecrow-s3-8048c050_4MB

@marsman7 did you do anything special to get yours working relaibly? I am not compiling anything just using the web installed to load one of the pre-compiled binaries.

TommySharpNZ avatar May 22 '25 03:05 TommySharpNZ