Mathieu Gauquelin
Mathieu Gauquelin

Reputation: 625

Refresh GUI graphs and take account of GUI modifications during the refresh (text, edit, popup uicontrol)

I come here today because I am developping a GUI on Matlab 2007b (with GUIDE) in which I control some electronic equipments (oscilloscope, function generator => frequency, timebase, trigger, a lot of thing) and in this one I get the curves display on the oscilloscope screen to display them on my GUI on an axe. The oscilloscope refresh the signals according to the trigger, and I know I can't do the same thing on my GUI (the time to get the signal from the oscilloscope is pretty long compare to the trigger period).

What I wish is the next thing: I open my GUI, launch a infinite while loop in which I call the function which refresh my curves on my axes (so get the signals from the oscilloscope, and update the axe) and refresh each time is possible. BUT, what I wish also is that the user can always interact with my GUI : change the frequency of the signal on a generator, change the timebase of the oscilloscope, etc. Unfortunately (but logically), when I launch my while loop, I can't do anything more with my GUI.

Is it possible to do it? Interact with my GUI and call the callbacks functions associated to object the user is interacted with, wherease there is a "background" function which is executed? For information, I refresh my graphs getting the data from an oscilloscopa via the ethernet link.

Maybe it is about the BusyAction and Interruptible value of the object? Or maybe it is only possible with a timer? I never do such thing before so I looked for information on internet but it seems to be a little complicated.

Just a little advice could be the difference to unlock me. I thank you in advance for your help.

If I didn't give enough information, don't hesitate to tell me.

PS: here there is an image of my GUI and the axe above in which there is 2 curves I want to refresh each time is possible.

First tab of my GUI

Upvotes: 0

Views: 68

Answers (1)

Suever
Suever

Reputation: 65430

The only reliable way to accomplish this is to use a timer to periodically poll the oscilloscope and update your plots. Then, when the timer is not executing, anyone can interact with any of the controls in your GUI.

t = timer('TimerFcn', @checkOscilloscope, 'ExecutionMode', 'FixedRate', 'Period', 0.1);
start(t);

function checkOscilloscope(tmr, evnt)
    % Do your check of the oscilloscope here

    % Update plots

    % Force a redraw
    drawnow
end

Upvotes: 0

Related Questions