2024-07-21 10:51 AM - edited 2024-07-21 10:57 AM
Hello everyone,
I added two buttons (the button type is shown in the attached picture) to my UI, each controlling two relays with the STM32F7 Disco. When I maintain a click on one of the buttons, both buttons turn off and become unresponsive. I need to reset the board to make them functional again.
Can anyone explain why the UI behaves this way and suggest a solution?
Thanks,
BR,
Nourhene.
2024-07-26 02:04 AM
Hello @NB1 ,
In your code, how do you handle the switching between the buttons? I think it would be way easier to just use the Toggle Button widget in the TouchGFX designer which already implements the behavior you are looking for.
Please give it a try and test if the same issue still exists
Best regards,
2024-07-26 08:51 AM
Hello @Mohammad MORADI ESFAHANIASL,
Thank you for your response. I believe we are discussing the same widget. I am also using the button you mentioned, but the code I generated is slightly different from the code provided in this link: Toggle Button.
My question is: Could this difference be the reason for the issues I'm experiencing with my buttons?
Here is my generated code:
#include <gui_generated/screen1_screen/Screen1ViewBase.hpp>
#include <touchgfx/Color.hpp>
#include <images/BitmapDatabase.hpp>
Screen1ViewBase::Screen1ViewBase()
{
__background.setPosition(0, 0, 800, 480);
__background.setColor(touchgfx::Color::getColorFromRGB(0, 0, 0));
add(__background);
toggleButton1.setXY(345, 215);
toggleButton1.setBitmaps(touchgfx::Bitmap(BITMAP_ALTERNATE_THEME_IMAGES_WIDGETS_TOGGLEBUTTON_MEDIUM_ROUNDED_ON_NORMAL_ID), touchgfx::Bitmap(BITMAP_ALTERNATE_THEME_IMAGES_WIDGETS_TOGGLEBUTTON_MEDIUM_ROUNDED_OFF_LIGHT_ID));
add(toggleButton1);
}
Screen1ViewBase::~Screen1ViewBase()
{
}
void Screen1ViewBase::setupScreen()
{
}
2024-07-30 01:24 AM
I can see that you have assigned to action to your button.
How do you control the communication between the toggle and your relays?