Welcome! Log In Create A New Profile

Advanced

Questions about connecting a 4.0" SPI color touch display with a ST7796S controller/driver IC and without own µC

Posted by hcet14 
Hello,
I'm planning to connect this 4.0inch SPI Module ST7796 to my printer.
My SKR2 has a stm32f429vgt6. Is that µC powerful enough to do the task and still working reliable to control the printer?
I would like to watch the workload of the µC. Does anybody know, if marlin can show that?

Is there anybody here, who has experience with those displays used with marlin?

Thanks in advance.
hcet14

Edited 1 time(s). Last edit at 09/18/2022 11:41AM by hcet14.
Re: Showing µC workload
September 17, 2022 11:24AM
Since its not an operating system running tasks, there is no cpu workload as such.....

you can enable MAX7219_DEBUG_PROFILE after attaching a MAX7219 8x8 led display

#define MAX7219_DEBUG_PROFILE       6  // Display the fraction of CPU time spent in profiled code on this LED matrix
                                         // row. By default idle() is profiled so this shows how "idle" the processor is.
                                         // See class CodeProfiler.


Marlin already supports a ST7796 at 480x320 the MKS_TS35_V2_0
these are orriginally found on MKS Robin Nano V2 & V3 motherboards.
v2 being a 72MHz STM32F103VE
v3 being a 168MHz STM32F407VG
SKR2 is 168Mhz STM32F429VG

So it should work fine. just dont expect full screen animation type speeds

Edited 2 time(s). Last edit at 09/17/2022 11:34AM by Dust.
Re: Showing µC workload
September 17, 2022 11:52AM
Also note, this linked display is just that a display.

It has no touch interface.

Marlin expects a touch interface with this type of display (at least currently)
Re: Showing µC workload
September 18, 2022 11:50AM
Quote
Dust
Since its not an operating system running tasks, there is no cpu workload as such.....

you can enable MAX7219_DEBUG_PROFILE after attaching a MAX7219 8x8 led display

#define MAX7219_DEBUG_PROFILE       6  // Display the fraction of CPU time spent in profiled code on this LED matrix
                                         // row. By default idle() is profiled so this shows how "idle" the processor is.
                                         // See class CodeProfiler.

Thanks, I didn't know about MAX7219 matrix displays. Just ordered one. Funny, with all the crises nowadays, ebay is cheaper and faster then aliexpress.

Quote
Dust
Also note, this linked display is just that a display.

I know. That's why I choose this display. I don't like the idea of having a display with its own FW. One FW to worry about is more than enough eye popping smiley

Quote
Dust
It has no touch interface.

No, I bought a MSP4021. MSP4020 has no touch.

Quote
Dust
Marlin expects a touch interface with this type of display (at least currently)

The used touch IC is XPT2046. I'm pretty shure marlin is supporting that one.

Too bad there is no option to display the µC load of my SKR2 on the display.

Thanks a lot Dust. You showed me new features of marlin.

Here is the only example (I attatched the English translation) , which I was able to find to connect such a similar display. I'm just concerned about the added load to my STM32F429VG.

My next question would be, if there is a way to use a touch display with an encoder (I mean both at the same time). What I read so far, no way. This goes in that direction, but works just with 'intelligent' displays. Maybe I end up with an FR.

Kind regards, hcet14
Attachments:
open | download - Connecting TFT 2.8 screen to SKR V1.3 (MARLIN) board_simplyfied.pdf (3.32 MB)
email from jmz52
September 18, 2022 12:14PM
During my resarch for a display, that I would like to use with my printer (regarding expense and features) I stumbled over jmz52. I found out his email and asked him this and he was so kind to answer:

Hello jmz52,

I read a lot of threads from you. I guess, you may have some experience with displays used with marlin.

My printer is still a pretty rudimentary thing. I would like to attach a MSP4021 display (http://www.lcdwiki.com/4.0inch_SPI_Module_ST7796). You can get these 4.0" displays with ST7796S or ILI9488.
I didn't find good info in the net. bmk74 wrote this (https://3dtoday.ru/blogs/bmk74/podklyucenie-ekrana-tft-28-k-plate-skr-v13-marlin), which is quite interesting (I guess he is a fellow countryman of you, I'm from Germany and prefer to be unknown (well, what I can do) in the net). If you know some sources in the net about those displays and marlin, please tell me.
You stated here (https://github.com/MarlinFirmware/Marlin/issues/24150#issuecomment-1180364182), ILI9486 does not support 16-bit color when using SPI interface. I agree.
Would you recommend a display with ST7796S to use with marlin and a SKR2 (STM32f429VGTT6)? Page 279 of the ST7796S datasheet (see attachment) says, 565 mode is possible with 3-SPI connection. What about controller load? Do you have any experience?
If you would recommend the display, could you help me with Marlin/Configuration.h and Marlin/src/inc/Conditionals_LCD.h, if I have questions?

If I get a MSP4021 working perfectly with marlin, I'll make a repository on github.

If you are not interested at all, please tell me to stop!

This was his answer. Thanks a lot again:

Hi,

> I read a lot of threads from you. I guess, you may have some experience with displays used with marlin.
Well, that's one way to put it smiling smiley

> If you know some sources in the net about those displays and marlin, please tell me.
There only sources I know of are that ones I've wrote myself, but that
are more about newly implemented functionality and not about
configuration parameters one need to enable in Configuration.h file
[github.com]
[github.com]
[3dtoday.ru] - that one
is in Russian
[github.com] - this one for the
first implementation of upscaled 12864 interface on TFT screen. It is
still supported as TFT_CLASSIC_UI but I would recommend the
TFT_COLOR_UI option instead.


> Would you recommend a display with ST7796S to use with marlin and a SKR2 (STM32f429VGTT6)?
Definitely. If you want to use a 480x320 TFT screen with SPI interface
then the ST7796S is the only controller you should be looking for.
It is fully supported in Marlin from the moment the pull request
#18130 was merged.

MKS Robin Nano board versions 2.x and 3.x are using 3.5" touch screens
with standard EXP1 EXP2 interfaces.
The screen is based on the ST7796S controller, so it is safe to assume
that both F103 and F407 have enough compute power to handle the
screen.
The MKS TS35 is NOT a smart screen and does not have it's own MCU.

"MKS TS35 3.5 touch screen for MKS Robin Nano" is available as a
standalone product.
MKS claims it to be compatible with MKS Robin E3P and MKS SGen_L boards
[aliexpress.com]

According to the schematic the MKS TS35 had onboard 5V to 3.3V
converter, so the lack of 3.3V on EXP2.10 pin of SKR2 board should not
be a problem.
[github.com]
Rest of the ping in EXP1 and EXP2 connectors have the very same
functions on both boards.
[github.com]
[github.com]

> If you would recommend the display, could you help me with Marlin/Configuration.h and Marlin/src/inc/Conditionals_LCD.h, if I have questions?
You will need to define number of TFT and touch-specific pins in
pins_BTT_SKR_V2_0_common.h
Most of them can be copied directly from pins_MKS_ROBIN_NANO_V3_common.h
The '#define TOUCH_BUTTONS_HW_SPI_DEVICE' is board specific but
according to these pins files the SKR2 and MKS Robin Nano uses the
same SPI1 device of the MCU.

All the settings you need are in Configuration.h file. You can either
use the "#define MKS_TS35_V2_0" option if you age going to use MKS
screen or specify set of custom parameters
#define TFT_GENERIC
(optional) #define TFT_DRIVER ST7796 - saves few bytes by skipping
screen autodetection
#define TFT_INTERFACE_SPI
#define TFT_RES_480x320
#define TFT_COLOR_UI
Depending on how your screen is mounted you might want to change the
"#define TFT_ROTATION" option as well.

Should you have any other questions, feel free to contact me via gmail
address - the message via github was not delivered.

Regards, jmz52
jmz
Re: Showing µC workload
September 20, 2022 02:59AM
Quote
Dust
Marlin expects a touch interface with this type of display (at least currently)

Touch is optional, you can use TFT screen with encoder.
Touch controls will not be displayed if touch support is not enabled in Configuration.h.
Unfortunately I can't recall if this space will be automatically used to display extra line of the menus or if you 'll need to tweak some #define to have this extra line.

P.S. I was away for quite some time and this behavior might be changed/broken, but initial implementation of color UI for TFT screens supported all three variants of controls - touch only, both touch and encoder and encoder only.
jmz
Re: Showing µC workload
September 20, 2022 03:10AM
Quote
hcet14
The used touch IC is XPT2046. I'm pretty shure marlin is supporting that one.
It is supported.

Quote
hcet14
My next question would be, if there is a way to use a touch display with an encoder (I mean both at the same time). What I read so far, no way. This goes in that direction, but works just with 'intelligent' displays. Maybe I end up with an FR.

As I wrote in my previous post you can use both touch and encoder for TFT screen.
You need to make sure that pins you are connections your encoder to are not pulled down on your board. Otherwise you will get incorrect readings of encoder's state.

Edited 1 time(s). Last edit at 09/20/2022 03:14AM by jmz.
Re: Showing µC workload
September 20, 2022 02:37PM
Quote
jmz
Touch is optional, you can use TFT screen with encoder.
Mmmmhh
Quote
jmz
Touch controls will not be displayed if touch support is not enabled in Configuration.h.
What is "Touch controls"? I have no idea. Do you have a picture of that? define touch controls?
Quote
jmz
Unfortunately I can't recall if this space will be automatically used to display extra line of the menus or if you 'll need to tweak some #define to have this extra line.
Ok. I'll probably come back, if I get that thing running.
Quote
jmz
P.S. I was away for quite some time and this behavior might be changed/broken, but initial implementation of color UI for TFT screens supported all three variants of controls - touch only, both touch and encoder and encoder only.
Ok, I'll see.
Quote
jmz
Quote
hcet14
The used touch IC is XPT2046. I'm pretty shure marlin is supporting that one.
It is supported.
I thought so.
Quote
hcet14
My next question would be, if there is a way to use a touch display with an encoder (I mean both at the same time). What I read so far, no way. This goes in that direction, but works just with 'intelligent' displays. Maybe I end up with an FR.
Quote
jmz
As I wrote in my previous post you can use both touch and encoder for TFT screen.
Ok, I didn't know that. I understood touch screen and encoder disturb each other.
Quote
jmz
You need to make sure that pins you are connections your encoder to are not pulled down on your board. Otherwise you will get incorrect readings of encoder's state.
If I have time next weekend, I'll draw a first schematic. Maybe disabling the encoder with CS from XPT2046.

Thank you jmz.

Kind regards, hcet14

Edited 3 time(s). Last edit at 09/20/2022 03:39PM by hcet14.
jmz
Re: Showing µC workload
September 20, 2022 03:48PM
Quote
hcet14
What is "Touch controls"? I have no idea. Do you have a picture of that? define touch controls?
There are some image sin this thread - [github.com]
It's for 320x240 UI but the general idea is the same

On menu screens there are 6 lines of text and navigation buttons (previous page, back to previous level, next page)
If "TOUCH_SCREEN" option is not enabled these controls will not be displayed and 7-th line of text can be displayed in this unused area.

Same for other screens - cancel, accept , decrease and increase buttons are only shown is TOUCH_SCREEN is defined.
Slider will still be displayed, as it is used to show range of possible values and current position.
But you will not be able to touch slider for fast parameter adjustment without TOUCH_SCREEN.

Quote
hcet14
Ok, I didn't know that. I understood touch screen and encoder disturb each other.
It is quite the opposite actually. Touch screen mimics the encoder, so the main part of Marlin's code remains independent of type of screen and controls used.
Re: Showing µC workload
September 24, 2022 12:07PM
Sorry jmz, my work load was pretty high and so I didn't had time to answer.
But, I tried to find clues in the internet, when I had some time. I wasn't very successful.

Quote
jmz
There are some image sin this thread - [github.com]
It's for 320x240 UI but the general idea is the same.

ok, I read that one already. That's why I sent you an email in the first place.

Quote
jmz
On menu screens there are 6 lines of text and navigation buttons (previous page, back to previous level, next page)
If "TOUCH_SCREEN" option is not enabled these controls will not be displayed and 7-th line of text can be displayed in this unused area.

ok, you are talking about this?


Quote
jmz
Same for other screens - cancel, accept , decrease and increase buttons are only shown is TOUCH_SCREEN is defined.
Slider will still be displayed, as it is used to show range of possible values and current position.
But you will not be able to touch slider for fast parameter adjustment without TOUCH_SCREEN.

I don't understand. what you mean? Please explain this a little further. Sorry. I don't understand. Are there any sources in the internet, where i could read?

Quote
jmz
It is quite the opposite actually. Touch screen mimics the encoder, so the main part of Marlin's code remains independent of type of screen and controls used.

Good, that you mention that. That is my main problem! To understand what's going on with touch screens and encoders. What do you mean, when you say "touch screen mimics the encoder"?
Can you please explain, how the SPI signals from touch controller and hard wired encoder signals interfere in marlin firmware?

Thanks a lot for your reply.

hcet14
Re: Showing µC workload
September 25, 2022 11:23AM
Quote
jmz
It is quite the opposite actually. Touch screen mimics the encoder, so the main part of Marlin's code remains independent of type of screen and controls used.

Is there anyone in the forum who could explain to me how touch screen and encoder could disturb each other in marlin firmware?
How is this working together in marlin fw? I still miss the basics eye popping smiley

Thanks in advance.
hcet14
Re: Showing µC workload
September 25, 2022 12:00PM
@jmz
What do you think about disabling BTN_ENC with PENIRQ from xpt2046? So the encoder is disconnected when the touch screen is used. No signals from the encoder could go to marlin code and interfere with the touch signals.

Kind regards, hcet14
Finally got my hands on MKS TS35.
It is a 3.5" TFT screen with 480x320 resolution with ST7796S controller, touch panel and encoder.

Images on the left are for Marlin without "#define TOUCH_SCREEN" option.
As you can see the main screen is missing touchable SD card and menu icons and menu navigation screen has 7th line.

Images on the right are for Marlin with "#define TOUCH_SCREEN" option.
There are touchable elements on main screen and 7th line of menu navigation is replaced by touchable controls (previous page, back, next page)

Encoder is enables in both configurations.


I see that this topic is about the MKS TS35-R V2.0 touch screen when used with the latest Marlin Firmware. Did you know that great improvements are coming to HAL SPI so that virtually every printer controller board can drive SPI TFTs? For example, the new Marlin FW supports not only the SKR2 (STM32F4xx) but also LPC176x and ESP32 for high capacity SPI TFTs! Please check out my pull request on Marlin official as well as the (currently) Marlin FW fork:

[github.com]
[github.com]

Give it an honest try! With my ingenuity and your help, we can make Marlin the best open-source and free printer FW available.


Martin Turski, company owner of EirDev

Support me in my duties! Improve the world through scientific accuracy and ingenuity.
Sorry, only registered users may post in this forum.

Click here to login