using a timer in GUI
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Daniel
el 15 de Ag. de 2016
Hi, I have a GUI to manage UART communication. I want to use a timer as follows: if i haven't got the answer for what i requested, in 4ms time ,then re-send the request (for example).
I tried several timer configuration and for each i get an error message:"error while evaluating timerfcn for timer 'timer-x' , where x is keep changing.
i tried: in openingFcn:
handles.timer1 - timer('executionmode',fixedrate','period',0.005,'timerfcn',@(src,event)NameOfFunc(src,event,handles));
in the desierd callback :
start(handles.timer1)
in the function
function NameOfFunc(src,event,handles)
DO SOMETHING
end
i get error (this time) error while evaluating timerfcn for timer 'timer-6' i also tried defining the timer as a global parameter
2 comentarios
Respuesta aceptada
Sean de Wolski
el 15 de Ag. de 2016
Editada: Sean de Wolski
el 15 de Ag. de 2016
function NameOfFun()
do something
end
Needs to take in the two inputs that come by default, src, evt.
function NameOfFun(src,evt)
do something
end
If you also want to pass in handles, like in your original, it needs to take in three inputs.
8 comentarios
Sean de Wolski
el 18 de Ag. de 2016
This error
function my_timer(mytimer,evt,handles) %as you suggested
DATA_SAVE_CallBack(handles.DATA_SAVE,eventdata,handles)
end
error:"error while evaluating TimerFCN...
undefind function or variable 'eventdata'"
is happening because the variable is named evt not eventdata.
The handles are stored as part of the figure's data. in order to update them after appending timer1 you need to run:
guidata(handles.figure1,handles)
to update the state. This is what happens in the OpeningFcn.
If your user interface is not that complex, and you're on R2016a, then give app designer a try. It manages data in a much clearer, easier, and more modern way.
>> appdesigner
Más respuestas (0)
Ver también
Categorías
Más información sobre Dialog Boxes en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!