Skip to main content
EHolm.2
Associate
April 13, 2022
Question

TouchGFX hardware buttons. ButtonController vs Interrupts

  • April 13, 2022
  • 4 replies
  • 1730 views

I currently use the STM32 ButtonController class to poll external GPIO Buttons. Is this the best way to implement Hardware Buttons or would GPIO Interrupts with a signal being sent to the Presenter be a more efficient solution?

This topic has been closed for replies.

4 replies

Peter BENSCH
ST Technical Moderator
April 13, 2022

If you send data directly to the presenter, i.e. past the model and view, you no longer follow the MVP model. This would make it much more difficult to migrate to other hardware (display, etc.) at a later date.

It should be better if you set a flag in the callback with the button interrupt, which you then evaluate in the model, but which then amounts to polling again.

Does it answer your question?

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
EHolm.2
EHolm.2Author
Associate
April 13, 2022

Hi Peter,

Thanks for the respose.

I should have been more clear. I meant I would pass it to the Presenter via the Model. The Model would simply wait for a FreeRTOS Message containing the ButtonPressed signal and then call e.g.

if (osMessageQueueGet(INPUT_QueueHandle, &inputData, 0, 0) == osOK) {
 modelListener->ButtonPressed(inputData);
}

I guess this comes down to whether the FreeRTOS osMessageQueueGet is more efficient than the TouchGFX ButtonController polling.

Are you saying that interrupts with RTOS Message Queue is more efficient than the ButtonController class?

Cheers,

Peter BENSCH
ST Technical Moderator
April 13, 2022

I see. However, I cannot confirm that sending data with the RTOS Message Queue is more efficient than the ButtonController class, because I have not yet done any timing or other research on this.

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
MM..1
Super User
April 13, 2022

If you say about human press buttons, class is OK.

For hw sourced inputs is more eff interrupts...