Skip to content

Commit 066c3e2

Browse files
authored
Merge pull request #25 from OlfactoryBehaviorLab/scope_poll
Update oscilloscope poll/update rate when start/stop is called
2 parents a0c91f4 + 89e47d4 commit 066c3e2

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

Functions/Modules/Analog Input/BpodAnalogIn.m

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -892,11 +892,26 @@ function scope(obj)
892892
drawnow;
893893
end
894894

895-
function scope_StartStop(obj)
896-
% scope_StartStop() toggles data acquisition by the scope()
897-
% GUI. It is called by a start button on the GUI, but it can also be
898-
% called from a user protocol file to start analog data logging with
899-
% online monitoring.
895+
function scope_StartStop(obj, varargin)
896+
% scope_StartStop This function toggles data acquisition when using the oscilloscope functionality of the AnalogIn module.
897+
% The function is called by the start button on the oscilloscope GUI, but can also be called from a
898+
% user protocol to start recording data with online monitoring via the GUI.
899+
900+
% :param update_frequency: Update frequency, in seconds (s), for the oscilloscope GUI during data acquisition, defaults to 0.05 (50 ms)
901+
% :type update_frequency: float, optional
902+
903+
904+
% Default GUI update time is 0.05s
905+
default_update_time = 0.05;
906+
update_frequency = 0;
907+
908+
ip = inputParser;
909+
valid_update_time = @(time) isfloat(time) && isscalar(time) && (time > 0); % Update time must be a float, scalar, and greater than zero
910+
addOptional(ip, 'update_frequency', default_update_time, valid_update_time); % update_frequency is optional, if the passed value is invalid, the default is used
911+
912+
parse(ip, varargin{:}); % parse the args
913+
update_frequency = ip.Results.update_frequency; % assuming all is well, grab the value from the parser
914+
900915
scopeReady = 1;
901916
if ~isfield(obj.UIhandles, 'OscopeFig')
902917
scopeReady = 0;
@@ -927,7 +942,7 @@ function scope_StartStop(obj)
927942
end
928943
obj.UIdata.SweepPos = 1;
929944
obj.startUSBStream;
930-
obj.Timer = timer('TimerFcn',@(h,e)obj.updatePlot(), 'ExecutionMode', 'fixedRate', 'Period', 0.05);
945+
obj.Timer = timer('TimerFcn',@(h,e)obj.updatePlot(), 'ExecutionMode', 'fixedRate', 'Period', update_frequency);
931946
start(obj.Timer);
932947
else
933948
stop(obj.Timer);

0 commit comments

Comments
 (0)