2025-07-31 2:20 AM
I was looking around to see if it was possible to drive the backlight of the display directly in TouchGFX code without having to pass the information to the backend to toggle it.
I'm currently turning off/on the backlight with
case CMD_BL_SET_HIGH:
HAL_GPIO_WritePin(LCD_BL_ENABLE_GPIO_Port, LCD_BL_ENABLE_Pin, GPIO_PIN_SET);
break;
case CMD_BL_SET_LOW:
HAL_GPIO_WritePin(LCD_BL_ENABLE_GPIO_Port, LCD_BL_ENABLE_Pin, GPIO_PIN_RESET);
break;
What I would like to do is to:
It seems it could be achieved with TouchGFX Touch Controller, but I'm not sure
My current approach is to have a message with a queue to another task running that triggers the HAL_GPIO_WritePin
Any idea?
2025-08-07 2:55 AM
Hello @nico23 ,
Could you tell us why you want to call this without passing through the model? Because I wouldn't recommend it.
TouchGFX is designed around the Model-View-Presenter (MVP) pattern, which separates UI logic from hardware control. Direct hardware access from the frontend (View) breaks this separation. The recommended approach is to use the Model class as the interface to hardware peripherals. The Model’s tick() function is called every frame, allowing it to handle hardware events and notify the UI through the Presenter.
I invite you to look at our documentation and also our board specific demos (BSD) to see examples.
2025-08-07 5:00 AM
Hi @Osman
Thanks for the answer. I'm still using the View-Presenter-Model, but to avoid setting up a new task/queue to send data to/from the Model and backend, I have implemented the function above as a function of the Model.
I have added a variable that returns the time of the latest touch in the STM32TouchController and checks if the display is already in standby. If not, it turns off the backlight with the HAL commands
2025-08-11 7:24 AM
Ok I see, so you want to make this totally outside from the TouchGFX application is that correct? You can copy/paste what is in the sampleTouch function to your program, outside from your TouchGFX application if you want.
2025-08-11 8:01 AM
You little mix names. Standby mode is low power mode for MCU and wake result to reset MCU = run application from start...
If you only on off backlight hal gpio wite is no blocking and can place on any part of code... no MVP no queue
Too as on off yo ucan manage PWM over tim output , but here pin used for backlight require be one timer channel pin.