How to save an area from a TFT screen connected to a MCU?

Thread Starter

Pepe333

Joined Feb 12, 2018
86
Hi everyone!,
I am working with the STM32 MCU family. I have some TFT with different graphics drivers (1.8 "ST7735 - 2.4" ILI9341). I tried the wiring and everything works fine.
To draw text on a background image, I want to save the background image area to redraw it when I delete the text. None of the graphics drivers has this option. I am thinking of using an external SRAM, an SPI.

Do you think it is a good idea? Is there a better way to do this?
 

MrChips

Joined Oct 2, 2009
21,326
You need to tell us more.
Which STM32 MCU are you using?
What is the pixel size of the display?
What is the area and pixel depth that you need to save?

If you use the STM32F746 DISCO there are three graphics layers that you can have. This can do what you are seeking.
 

jpanhalt

Joined Jan 18, 2008
9,706
I use a PIC instead of STM. My entire screen (132x64) can be mapped to a FIFO. In practice, I only mapped the left half to a FIFO. Nothing goes to that part of the screen that is not in the FIFO. I can erase any part and redraw it. It just happens that the left half is a graph. I erase the graphical data and redraw it for scrolling but leave the coordinates to save a little time. The right half is data (temperature, time, time to go, etc.) that I erase only line by line, but I could erase the whole thing if I wanted to. The half and half division of the screen is arbitrary. There is only one controller for the entire screen.

The FIFO does not add much to the delay. In fact for development, I had to add lengthy delays to get the screen to blink so I could see things were going as I wanted. Interface is SPI and it is running at only 4 MHz. The SPI interface does not allow me to read the screen. For another project with parallel interface and a character screen, I did not use FIFO, and simply read what was there.

I am not sure what you are trying to do or how your screen/STM works (i.e., I do not have layers to pay with). Read modify, write is only possible on my LCD display, if you can read it. There is no way to "OR" an image to the display without reading it. That is, if I could read the display RAM, I could OR it. Alternatively, I could OR the data in the FIFO, but you cannot write to a byte without changing affecting bit.
 

MrChips

Joined Oct 2, 2009
21,326
I don't do PICs but this is where the STM excels.
STM has bit-addressing operations. You can access (read/write) individual bits.
STM uses DMA which frees up the CPU.
STM has Chrom-ART which supplies hardware accelerator for graphics operations such as bit-blt, alpha blending, text anti-aliasing, colour conversion, two foreground and one background layer.
 

jpanhalt

Joined Jan 18, 2008
9,706
@MrChips
That is very interesting about the STM MCU. It s easy to see how one could do layers with a PIC, but it would be a huge memory hog. Addressing individual pixels is a different issue. Is it done in just one operation? Are you still limited to 8 bits per SPI exchange?

With an 8-bit PIC, it is a function of the display controller. Currently, my display uses an ST7567 (non-readable w/SPI) controller. Addressing a pixel would require setting row/page (1 instruction), column (requires 9 bits so 2 instructions), and byte (minimum of 3 instructions = 2 for constructing the byte + 1 for changing from command to data) plus calls, returns, and the actual SPI instructions. If you need to read the buffer to find out what's in the byte, there would be even more instructions.
 

Thread Starter

Pepe333

Joined Feb 12, 2018
86
You need to tell us more.
Which STM32 MCU are you using?
What is the pixel size of the display?
What is the area and pixel depth that you need to save?

If you use the STM32F746 DISCO there are three graphics layers that you can have. This can do what you are seeking.
I use a serie 3 MCU (STM32F3). It hasnt ART, I think.
The pixel is 2 bytes each, the resolution is 320x240.
I want to save all the screen in case I need it.
 

MrChips

Joined Oct 2, 2009
21,326
I use a serie 3 MCU (STM32F3). It hasnt ART, I think.
The pixel is 2 bytes each, the resolution is 320x240.
I want to save all the screen in case I need it.
320 x 240 x 2bytes = 150Kb
Any particular reason why you are stuck with STM32F3 while STM32F746 will give you so much more enhanced performance?
 

MrChips

Joined Oct 2, 2009
21,326
Right now I am programming STM32F407VGT6 which has 16-channel ADC and costs US$12.
Basing your decision on chip cost alone is misguided because you are going to spend much more in order to implement your objectives.
 

Thread Starter

Pepe333

Joined Feb 12, 2018
86
Right now I am programming STM32F407VGT6 which has 16-channel ADC and costs US$12.
Basing your decision on chip cost alone is misguided because you are going to spend much more in order to implement your objectives.
I mean series STM32F3 has 4(four) ADCs and 4(four) Comparators, and those Comp can work in window mode... the 407 cant do that.
The F303 I'm using cost about 1,5$.
If you are planning make a device to market, you'll choose a 1,5$ cost before a 12$ one.
Maybe is a misguided selection, but the final number of components on a design is very important to. Every component waste time in production and is a possible cause for failures.
If I had choose a F400 series, I'll need a lot of extra components (opamps, comps, etc), more time to design, to test, etc... so, where is te save?

The solution of add a sram chip cost 0,20$ and the time to develope a routine to read and write (not much at all).

...following the criteria of the 12$, we would all drive a BMW series 5. :)
 
Top