cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX hardware buttons. ButtonController vs Interrupts

EHolm.2
Associate II

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?

4 REPLIES 4
Peter BENSCH
ST Employee

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.

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,

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
Chief II

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

For hw sourced inputs is more eff interrupts...