Azzera filtri
Azzera filtri

Starting a timer within a timer (using Guide)

3 visualizzazioni (ultimi 30 giorni)
Jay
Jay il 24 Giu 2020
Modificato: Jay il 24 Giu 2020
Hello All,
This is a bare bones version of a script associated with a GUI using guide
As you can see, i am trying to use a Push button to create 2 timers, and then start 1 of them.
After a delay (30s in this case) the 1st timer runs, stops itself, and starts the 2nd timer, which in turn stops itself and restarts the 1st timer.
The goal is to have them bounce back and forth until I tell them to stop with another push button.
This may seems silly, but I have my reasons which i wont get into.
My issue seems to be related to how the handles and such are passed thru the timer object to the actual timer function (I think), and then from one timer to the other.
It will run the 1st timer function, but wont actually stop the timer object
Then the 2nd timer function wont restart the 1st timer, because the 1st timer is still active.
I have read thru many questions and answers tyring different things along the way, but nothing works.
I am all ears to suggestions
function AIMStartButton_Callback(hObject, eventdata, handles)
handles.ReadLoopTimer1 = timer('Name','ReadLoopTimer1','StartDelay',30,'TasksToExecute',1,'ExecutionMode','fixedSpacing','TimerFcn',{@ReadLoop1,hObject});
handles.ReadLoopTimer2 = timer('Name','ReadLoopTimer2','StartDelay',30,'TasksToExecute',1,'ExecutionMode','fixedSpacing','TimerFcn',{@ReadLoop2,hObject});
start(handles.ReadLoopTimer1);
guidata(hObject, handles);
function ReadLoop1(hObject, eventdata, hFigure)
handles = guidata(hFigure);
start(handles.ReadLoopTimer2);
stop(handles.ReadLoopTimer1);
function ReadLoop2(hObject, eventdata, hFigure)
handles = guidata(hFigure);
start(handles.ReadLoopTimer1);
stop(handles.ReadLoopTimer2);

Risposte (0)

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by