Updating items on screen while scanning event handler.

Fully featured ARM compilers available on Windows, Linux, and macOS.
Post Reply
Author
Message
d_scheider
Posts: 7
Joined: 02 Dec 2022 16:27

Updating items on screen while scanning event handler.

#1 Post by d_scheider » 11 Mar 2023 14:54

Is there a way to periodically update items such as progress bars after the main_screen_show function has finished running? Normally, all activity stops while the event handler waits for an event to be activated. Is there a way to trigger an event without user input, if there is no activity for a couple of seconds?

frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: Updating items on screen while scanning event handler.

#2 Post by frank.malik » 13 Mar 2023 13:39

Hello d_scheider,

I'm not sure if I understand your issue correctly.
You can update any component any time with the vtft_draw_component function.
I have made a very simple example for the progress bar. Maybe it helps you to understand the concept.

viewtopic.php?f=147&t=79511
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

d_scheider
Posts: 7
Joined: 02 Dec 2022 16:27

Re: Updating items on screen while scanning event handler.

#3 Post by d_scheider » 15 Mar 2023 14:22

I guess I should have included more details. All I'm really trying to do is run a loop while allowing user input to change values. This is easy to do with physical buttons:

while (1){
play sound;
if (PORTB = 0x01) {Volume++;} //Button maps to volume up
else if (PORTB = 0x02) {Volume--;} //Button maps to volume down
else if (PORTB = 0x03) {break;} //Button maps exit
}

However, this does not work with on screen buttons in NECTO Designer, because all buttons are mapped to functions, not variables or hex values. Trying to run a continuous loop will disable event handling section, because the program is tied up in the loop. Is there a way to include checking the event handler in the loop, or break from the loop, check event handling, then return to the loop?

frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: Updating items on screen while scanning event handler.

#4 Post by frank.malik » 16 Mar 2023 09:15

Hello,

I think I've got your point and the solution might be to call vtft_process(&vtft)

Here is an extract from my application. It runs a motor, updates the screen with the speed information,
and checks the start/stop button at the same time. I removed some non-relevant parts, so this code is
not compile-clean.

Code: Select all

extern bool StartStopButton_start ;
/**
 * @brief Application task function.
 */
void application_task()
{
    float motor_speed_hz = 0;
    status_reg_t status ;
    
    if ( StartStopButton_start ) 
    {
        brushless23_pwm_set_duty_cycle ( &brushless23, 0.60 );
        if ( BRUSHLESS23_OK == brushless23_get_motor_speed ( &brushless23, &motor_speed_hz ) )
        {
            print_status("Speed: xxHz");
        }

    } else {
        brushless23_pwm_set_duty_cycle ( &brushless23, 0.00 );
        
    }
    if ( BRUSHLESS23_OK == brushless23_get_status_reg ( &brushless23, &status ) )
    {
        bl23_screen_set_indicator(OVERCURRENT, (status.field.ISD == 1)) ;
        bl23_screen_set_indicator(START_ERROR, (status.field.ST_FAIL == 1)) ;
    }
}

/**
 * @brief Application main function.
 */
void main()
{
    application_init();
    while (1)
    {
        vtft_process(&vtft);
        // Your code here
        application_task();
    }
}
The variable StartStopButton_start will be set in the respective xxxxxx_screen.c program part, depending on the button event.
I hope this helps.
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

d_scheider
Posts: 7
Joined: 02 Dec 2022 16:27

Re: Updating items on screen while scanning event handler.

#5 Post by d_scheider » 21 Mar 2023 15:01

Thanks, that works perfectly.

Post Reply

Return to “PIC32 AI Compilers”