2020-04-01 05:34 AM
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
Solved! Go to Solution.
2020-04-01 05:54 AM
Hi Roger,
Let me just paste some of the code here from that article:
#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:
};
...
H7B3ButtonController bc;
void TouchGFXHAL::initialize()
{
TouchGFXGeneratedHAL::initialize();
hal.setButtonController(&bc);
}
In this code you're defining a class that inherits from ButtonController and implementing the sample() function so that it reads a GPIO port where a button is connected. You can define this class anywhere you want in your program structure. Add the line hal.setButtonController(&bc) inside the initialize() function of your TouchGFXHAL.cpp.
When you configure your HAL via setButtonController() function to use the ButtonController you just defined to distribute the value returned from sample() to the active application. And by telling .touchgfx file about it you can now use that value as a tigger in an interaction
/Martin
2020-04-01 05:54 AM
Hi Roger,
Let me just paste some of the code here from that article:
#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:
};
...
H7B3ButtonController bc;
void TouchGFXHAL::initialize()
{
TouchGFXGeneratedHAL::initialize();
hal.setButtonController(&bc);
}
In this code you're defining a class that inherits from ButtonController and implementing the sample() function so that it reads a GPIO port where a button is connected. You can define this class anywhere you want in your program structure. Add the line hal.setButtonController(&bc) inside the initialize() function of your TouchGFXHAL.cpp.
When you configure your HAL via setButtonController() function to use the ButtonController you just defined to distribute the value returned from sample() to the active application. And by telling .touchgfx file about it you can now use that value as a tigger in an interaction
/Martin
2020-04-01 07:51 AM
hello dear Martin
Sorry but a lot of problems
2020-04-01 08:39 AM
Hey Roger,
Don't worry! Everything OK now?
/Martin
2020-04-05 02:27 AM
Hello everyone,
It doesnt seem to be a popluar subject for the tutors although very important.
I am doing something similar but still learning how to do it. So far the closest example I found is the following https://www.youtube.com/watch?v=jQO7zhX0e0Q&t=2819s
On thouchgfx I have created an image with 2 possible led images gray and red.
On the viewer code I have added the followinng where animation1 is the name of the top led image.
void Screen1View::advanceAnimation()
{
uint8_t msg = 0;
if (xQueueReceive(gui_msg_q, &msg, 0) == pdTRUE)
{
animation1.setBitmap(Bitmap(BITMAP_BUTTON_BLANK_GRAY_ICON_ID));
animation1.invalidate();
}
else
{
animation1.setBitmap(Bitmap(BITMAP_BUTTON_BLANK_RED_ICON_ID));
animation1.invalidate();
}
}
When I press the button the virtual led turns from grey to red. But doesnt go back to gray once the button is released.
While I am trying to solve it any help is welcome
2020-04-06 12:44 AM
Did you try debugging? Are you even hitting both parts if your if statement? Debug further down into the task that samples the button GPIO and sends the message. Also, it seems like you're missing something. You need to send a signal from your task on both PRESSED and RELEASED and in your view you're just checking if there's something in the queue.
Also, try not to have target specific code directly in your view to make it more portable (use a signal on your modelListener, e.g modelListener->buttonPressed() which you respond to in your presenter - Then you can abstract this functionality to work in a simulator as well)
/Martin
2020-04-13 07:41 AM
Hey @Martin KJELDSEN ,
I am very new to C++.
I am trying to use push button of STM32F429 Discovery kit to change screen. I have configured correctly with given article. Defined ButtonController class properly.
I just want to know how below line will work.
if (HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) != GPIO_PIN_RESET)
As HAL_GPIO_ReadPin() function is defined in stm32f4xx_hal_gpio.c
and #defines are also defined in perticular .h files.
So how can I include that in MyButtonController.cpp file?
After compiling it is showing an error,
'GPIOC' was not declared in this scope likewise same error for other defines and functions.
Can you help me please to figure out this issue?
2020-04-14 06:41 AM
Did you take that code directly from the article? GPIO Port C Pin 13 is for the STM32H7B-DISCO _specifically_, so it won't work for any other board unless they have the same button connceted to the same GPIO.
You need to get the schematics for the 429-disco kit and check which GPIO the button is connected to.
/Martin
2020-04-14 06:46 AM
Thanks for your quick reply Martin.
As you have said, I have checked properly in the 429-disco kit schematics for GPIO button and correctly configured through CubeMX.
I have a different issue with #defines used in .h header files. I didn't get that thing.
2020-04-15 04:41 AM
I have a issue with including header files. And I am getting compiling error for HAL_GPIO_ReadPin() function.
Error is 'HAL_GPIO_ReadPin' was not declared in this scope.
After changing this function with BSP_PB_GetState() and include respective <stm32f429i_discovery.h> header file.
Now my function is working perfectly.
But I didn't get how can I use HAL_GPIO_ReadPin() function?