cancel
Showing results for 
Search instead for 
Did you mean: 

External events as triggers

Roger3
Associate

Hello dear

It would be very nice to give us a simple example to explain all your codes to order to change a widget on a screen.

You tellus to use "TouchGFX HAL Development" in your example gpio https://support.touchgfx.com/docs/development/board-bring-up/example-gpio/ but where is it possible to put it?

Thank you for you aid.

Roger

16 REPLIES 16

The function is inside e.g. stm32_hal_gpio.h. Just include stm32h7xx_hal.h in the case of h7.

This is for the H7 assigning the value 1 to key (which can now be used in designer interactions "Hardware button pressed")

#include <stm32h7xx_hal.h>
#include <platform/driver/button/ButtonController.hpp>
 
class H7B3ButtonController : public touchgfx::ButtonController
{
    virtual void init() {  }
    virtual bool sample(uint8_t& key)
    {
      if (HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) != GPIO_PIN_RESET)
      {
        key = 1;
        return true;
      }
      return false;
    }
private:
};

/Martin

Thanks Martin,

I have added directly stm32_hal_gpio.h file and it creates compilation error. After your answer I have added stm32f4xx_hal.h and now it is working perfectly.

Great =) Let me explain why:

//stm32h7xx_hal.h
/* Includes ------------------------------------------------------------------*/
#include "stm32h7xx_hal_conf.h"

//stm32h7xx_hal_conf.h
#define HAL_GPIO_MODULE_ENABLED
 
#ifdef HAL_GPIO_MODULE_ENABLED
  #include "stm32h7xx_hal_gpio.h"
#endif /* HAL_GPIO_MODULE_ENABLED */

 Doing it this way will include other required symbols that you won't get by just including gpio.h, for instance.

//stm32h7xx_hal_gpio.h
/* IO operation functions *****************************************************/
GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);
void HAL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);

/Martin

Really Thanks Martin. You have given clear idea.

Hi Matin,

Thanks for the advice. Eventually I learned how to use the debugger.

The Hardware integration on STM32F769 with TouchGFX – Webinar code helped eventually finding the problem. I have found the solution on their LED part. I am not very familiar with the queue concept, so it took me a while to realise I was not getting the message from the queue as you suggested.

I have used the following code as a task in the main:

gui_msg_q = xQueueGenericCreate(1, 1, 0);

if(HAL_GPIO_ReadPin(User_Button_GPIO_Port, User_Button_Pin) == GPIO_PIN_SET )

      {

             // Send empty message. Queue item implicitly means PRESSED.

             msg = 1;

             printf("btn on\n");

      }

      else

      {             msg = 0;

             printf("btn off\n");

      }

      if (gui_msg_q)

                          {

                                 xQueueSend(gui_msg_q, &msg, 0);

                          }

On the view I received the queue message with the following code :

      if ( xQueueReceive(gui_msg_q, &msg, 0) == pdTRUE )

      {

                          switch(msg)

                          {

                                 case 0:

                                       animation1.setBitmap(Bitmap(BITMAP_BUTTON_BLANK_GRAY_ICON_ID));

                                        animation1.invalidate();

                                        break;

                                 case 1:

                                       animation1.setBitmap(Bitmap(BITMAP_BUTTON_BLANK_RED_ICON_ID));

                                        animation1.invalidate();

                                        vQueueDelete(gui_msg_q);

                                        break;

                                 default:

                                        break;

                          }

                    }

I am sure for experts like yourself it can be done in a better way but at least I found a starting point to for learning.

I am not sure I understand your comment about the portability.

In the Model I put :

void Model::btnPressed()

{

   modelListener->btnPressed();

}

And the presenter has :

void Screen1Presenter::btnPressed()

{

      view.advanceAnimation();

}

and the first sample above in the viewer is in the following function void Screen1View::advanceAnimation()

Any comment for improvement is more than welcome.

Well done for finding the right information and integrating it =) That's the way to go and learn!

Re: portability - Say you wanted to run the code from the designer in the simulator what would happen, if we consider that the simulator already runs on an operating system? (windows) and has no way currently of abstracting something like task and a physical LED?

FLuba.1
Associate III

Hi, there's a video about this subject on youtube(there's part 1 & 2). Link part 1 :  https://www.youtube.com/watch?v=ufvJ5bcesL8

Link part 2: https://www.youtube.com/watch?v=QgEDSjvGAlk

The website of TouchGFX also adresses this subject, but the video is better. Link TouchGFX : https://support.touchgfx.com/4.21/docs/development/scenarios/example-gpio