Mercurial > hg > ishara
view sched/timed_action.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | beb8a3f4a345 |
children |
line wrap: on
line source
% timed_action - return action function that checks the time % % timed_action :: % (A1, A2, ... => B1, B2, ...) ~'some action', % options { % print :: bool/false ~'if true, then print timing error on action'; % errorfn :: (time => real) ~'action to compute timing error from scheduled time' % } % -> timed_action({A1,A2,...},{B1,B2,...}). function a0=timed_action(x,varargin) opts=options('print',0,'errorfn',@(t)nows-t,varargin{:}); if opts.print, a0=@aa_print; else a0=@aa; end errfn=opts.errorfn; function varargout=aa_print(t0,varargin), varargout{1}=errfn(t0); [varargout{2:nargout}]=x(varargin{:}); fprintf('timed_action: error=%g\n',varargout{1}); end function varargout=aa(t0,varargin), varargout{1}=errfn(t0); [varargout{2:nargout}]=x(varargin{:}); end end