İmplementing a Pause button
Show older comments
hello everyoneş
İ have a start push button whicjh is basically recording the position, date and 'time' when the mouse is on pointer/mouse cursor is on the canvas.
İt is on this format
ex:(X, Y, time) = (237, 393, 12-May-2022 13:03:55, 2&1!, AA4)
(X, Y, time) = (505, 437, 12-May-2022 13:03:55, 2&1!, AA4)
(X, Y, time) = (616, 452, 12-May-2022 13:03:56, 2&1!, AA4)
İ am more interested in the seconds. İs there anyway seconds can just be recorded?
İ would like to buid a Pause pushbutton that will pause just the 'time' to move (because the experiment is long so sometimes the user will need a break). İ dont have any idea on how to do it. Also what could be challenging is that i dont know how i could handle the 'Enable','off' and 'Enable','on' of the Start and stop callbacks
.
% --- Executes on button press in Start_button.
function Start_button_Callback(hObject, eventdata, handles)
% hObject handle to Start_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.fileID = fopen('Start_Stop.txt','w');
handles.t = timer('ExecutionMode', 'fixedRate', ...
'Period', 0.5, ...
'TasksToExecute', Inf, ...
'TimerFcn', {@timerCallback, handles.finger});
start(handles.t);
set(handles.Start_button,'Enable','off'); % -> Disable the button
guidata(hObject,handles);% -----> do this to save the updated handles object
function timerCallback(~,~,f)
handles = guidata(f);
%fprintf(fileID,'(X, Y, time) = (%g, %g, %s)\n', get(0, 'PointerLocation'), datetime('now'));
fprintf(handles.fileID,'(X, Y, time) = (%g, %g, %s, %s, %s)\n', get(0, 'PointerLocation'), datetime('now'), ...
handles.amplitude{handles.exp_counter},handles.f_df{handles.exp_counter});
%fprintf('calling timer callback\n');
function Stop_button_Callback(hObject, eventdata, handles)
% hObject handle to Stop_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles = guidata(hObject);
stop(handles.t) %whenever we want to stop.
fclose(handles.fileID);
set(handles.Start_button,'Enable','on'); % -> Enable the button
guidata(hObject,handles);
% --- Executes on button press in pause_button.
function pause_button_Callback(hObject, eventdata, handles)
% hObject handle to Stop_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
guidata(hObject,handles);
Accepted Answer
More Answers (0)
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!