cancel
Showing results for 
Search instead for 
Did you mean: 

Background redraw problem

guidoglorioso01
Associate II

Hi, i am making a project with the ST NUCLEO F401Re using a TFT display of MCUFRIEND (not so good display), and the implementation is running with touchGFX 4.22.0.

The display works with data serial using 8 pins of data and 4 to control (just for context).

I have been making the entire UI and it works fine, but the problem is each time i need to swap from one screen to other, the refresh delays quite much in update all the screen (you can see the screen updating from top to buttom maybe like half second or less).

I am not sure but i think the problem might be my display. 

For other side i noticed that if i am in one screen, and change widgets like buttoms, slider and so one the response is good and one cant notice the refresh.

Because i have the same background in all the screens (i attached the images of some of them) i was wondering if it is posible to not update the bockground but the widgets and texts only .

 

guidoglorioso01_0-1696780507394.png

guidoglorioso01_1-1696780517356.png

guidoglorioso01_2-1696780534651.png

guidoglorioso01_3-1696780552366.png

If someone have any idea or suggestion it will be very appriciate.

 

More info about the project:

Display

I am using a TFT display of 3,5'' and 380x420 dimensions . The product was made by a company called "MCUFRIEND" and its a module with a touch screen, TFT displays and SD card slot (wich i am not using).

The display works with paralel 8 data pins, being the data format of 16 bits (most of the comands are 8 bits but to write on the display you send 16bits data).

guidoglorioso01_0-1696960296409.png

guidoglorioso01_1-1696960325947.png

To control the display i have been working with MCUFRIEND library which is used for many types of displays controlers. In my case i found that i my controler was an RM68140.

The touchscreen has a 4 wire controller, so it´s use 2 wires for each axes. For other side, the display also have 5 pins to control betwen comands and other kinds of data. Because the board use the same 4 pins to check the touch screen and controll the display, is necesary to make an multiplexation betwen each function. (I make it changing pins direction, readding the ADC to know the position press and going back to display control).

I addapted the code to works with my controller and only use the drivers functions that i need for my aplication (so i reduce code and ejecution times).

The drivers i use are the following (i only add waht i think is relevant code, but if you need all the code or another function tell me and i add the rest).

// Function that i pass to touchGFX to write on the display.

void drawRGBBitmap(uint16_t x, uint16_t y, uint16_t *bitmap, uint16_t w, uint16_t h){
    setAddrWindow(x, y, x + w - 1, y + h - 1);
    CS_ACTIVE;
    WriteCmd(_MW);
    uint8_t hi , lo;
    uint16_t cant;
    const uint32_t total_data = h * w;
    for(cant = 0;cant < total_data ;cant++) {
hi = bitmap[cant] >> 8;
lo = bitmap[cant] & 0xFF;
write8(hi);
write8(lo);
}
    CS_IDLE;
}

#define write8(x) { write_8(x); WRITE_DELAY; WR_STROBE; WR_IDLE; }

#define CS_ACTIVE PIN_LOW(CS_PORT, CS_PIN)
#define CS_IDLE PIN_HIGH(CS_PORT, CS_PIN)

#define WR_STROBE { WR_ACTIVE; WR_IDLE; } 
#define WRITE_DELAY { WR_ACTIVE; }

#define WR_ACTIVE PIN_LOW(WR_PORT, WR_PIN)

There is an init function and so on but i think they don´t have any to do with my actual problem.

Note that i know (now) that spi is better than this scheme to send data , i really do, but now i am working with that display and i could not change it. 

TOUCHGFX info:

About touchGFX i am using none transition betwen screens

guidoglorioso01_2-1696961811267.png

And for the background i make an container so i garante that al the backgrounds are the same.

guidoglorioso01_3-1696961912999.png

RTOS SO

I know that i have mentioned this at begging, but i am using RTOS to work with TouchGFX. Those are the task and configurations that i have make:

//TASKS CREATES

xTaskCreate(TouchGFXSYNC_process, "GFX SYNC", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL);
xTaskCreate(Touchscreen_process, "UPD TS", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL);
xTaskCreate(TouchGFX_Task, "UPD GFX", 2000, NULL, tskIDLE_PRIORITY + 2, NULL);

// TASKS

void TouchGFXSYNC_process(void *arguments){
extern void touchgfxSignalVSync(void);
 
while(1){
touchgfxSignalVSync();
vTaskDelay(pdMS_TO_TICKS(5));  
}
}
 
void Touchscreen_process(void *arguments){
 
while(1){
mde_TS(); // State Machine to work with the touch controll reducing debouncng and so on.
vTaskDelay(pdMS_TO_TICKS(10));
}
}
// Conection with TOUCHGFX drivers
static uint8_t isTransmittingData = 0;
 
uint32_t touchgfxDisplayDriverTransmitActive(void)
{
return isTransmittingData;
}
 
void touchgfxDisplayDriverTransmitBlock(uint8_t* pixels, uint16_t x, uint16_t y, uint16_t w, uint16_t h)
{
isTransmittingData = 1;
drawRGBBitmap(x,y,pixels, w, h);
isTransmittingData = 0;
DisplayDriver_TransferCompleteCallback();
}
 
I do not tell it sooner beause i also try the display without FreeRTOS and the results were the same so i discard this as a problem.

I think i tell you all the relevant but if i forgot something don't hesitateto tell me i will add all you need.

Best regards Guido

14 REPLIES 14

As i responded to @AScha.3 , i did not checked the timming. I will do it in next days.

I think a good option is to not update al the screen so i reduce the number of pixel i have to send. But i have no idea if it is posible to do with TouchGFX.

Thanks for your help!

while(1){
    touchgfxSignalVSync();
    vTaskDelay(pdMS_TO_TICKS(5));  
}

Change vTaskDelay(pdMS_TO_TICKS(1));  or 

taskYIELD();

@Panchev68 well changing that time i gain some time in each transition. Anyway the laggi animation persists. Thanks for the advise.

@MM..1 The time of write8() is 78 clock cycles. In this case is about 0.976uS for each 8 bit write. 
Analysing the time per line update the measure was about 3,18mS.

So in this case (380 pixels hight display) is 1,2 seconds, wich correspond to refresh update that i see

So in 380 hight displays is 1,2 seconds wich correspond to refresh update that i see.

For good displaying you need pixel16bit transfer around on 10MHz . You now have 0,5MHz. Required speed up 20x

But primary i dont understand your 78clock cycles ? 

Secondary your MCU is underpower for your LCD size. Partial buffer with some DMA is solution.

 

and your code is undersized uint16

 

uint16_t cant;
    const uint32_t total_data = h * w;
    for(cant = 0;cant < total_data ;cant++)