Adding Buzzer sound in Button (TouchGfx)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-13 9:36 AM
I am currently using the touch gfx button with its callback function to call PWM code to execute when I press the button on the GUI as shown below.
#include <main.h>
#include "cmsis_os.h"
extern TIM_HandleTypeDef htim4;
void MAINViewBase::buttonCallbackHandler(const touchgfx::AbstractButton& src)
{
if (&src== &button1)
{
TIM4->CCR2 = 50;
HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_2);
osDelay(50);
HAL_TIM_PWM_Stop(&htim4, TIM_CHANNEL_2);
//Interaction1
//When button1 clicked change screen to SETTINGS
//Go to SETTINGS with screen transition towards East
application().gotoSETTINGSScreenSlideTransitionEast();
}
}
But I have to add this function manually every time I make any change in the GUI which is kind of repetitive to do, Is there any method of adding a custom Button function where I can write this code as default with the button?
- Labels:
-
STM32CubeMX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-13 10:18 AM
Change your handler to
to virtual function call and in func buzz start no delay... stop place on timed handler or next screen onload part.
Delays in code result to block gui ...
Too you can use next interaction to start screen change when this ends...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-13 10:47 AM
You can create a custom button class that inherits from the Button class in TouchGFX.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-13 10:49 AM
If it's possible ,could you please write that here?
