필터 지우기
필터 지우기

Starting a timer within a timer (using Guide)

조회 수: 3 (최근 30일)
Jay
Jay 2020년 6월 24일
편집: Jay 2020년 6월 24일
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);

답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by