Hello Laser,
I think it would be much easier to use GUIX timer in this case:
case GX_SIGNAL(ID_START_TIMER_BUTTON, GX_EVENT_CLICKED):
{
gx_system_timer_start(widget, 1, initial_timeout, repeat_timeout);
break;
}
case GX_EVENT_TIMER:
{
if (1 == event_ptr->gx_event_payload.gx_event_timer_id)
{
gx_prompt_text_set(p_prompt, p_text);
}
}
Bear in mind that p_text must be a pointer to null-terminated character array (i.e. array symbol itself without index) which is statically allocated. This is necessary for 2 reasons:
- GUIX uses deferred drawing, so the gx_prompt_text_set only changes the relevant property in the control structure. The actual redrawing takes place after event handler has finished executing. If you pass a pointer to string created on the stack, it will no longer be valid when drawing context is executed.
- This API permanently attaches contents at the pointer destination to the string visible in the prompt widget. Further on, when you modify this string and drawing function is executed, your prompt will be re-drawn with the new string even though you didn't call the gx_prompt_text_set function.
The timeout units for GUIX timers are 20ms. If repeat timeout is 0 the timer will stop after initial timeout is reached. You can also manually stop the timer using gx_system_timer_stop(widget, 1), provided this call is made from the owner's event handler.
If you really need to use GPT, send a message to GUIX when timeout occurs instead of updating GUIX content from within ISR (90% of the functions can only be called within initialization and threads and not from the ISR). Use the following snippet to create and send a message to GUIX from your callback function:
GX_EVENT gxe = {0};
gxe.gx_event_type = GX_FIRST_APP_EVENT;
gx_system_event_send(&gxe);
This will send an event of type GX_FIRST_APP_EVENT to the window that currently has focus. In the event handler for that window, you should create a case for when event_ptr->gx_event_type is GX_FIRST_APP_EVENT and that's where your prompt should be updated.
Regards