annotate 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 |
|
rev |
line source |
samer@2
|
1 % timed_action - return action function that checks the time
|
samer@2
|
2 %
|
samer@2
|
3 % timed_action ::
|
samer@2
|
4 % (A1, A2, ... => B1, B2, ...) ~'some action',
|
samer@6
|
5 % options {
|
samer@6
|
6 % print :: bool/false ~'if true, then print timing error on action';
|
samer@6
|
7 % errorfn :: (time => real) ~'action to compute timing error from scheduled time'
|
samer@6
|
8 % }
|
samer@2
|
9 % -> timed_action({A1,A2,...},{B1,B2,...}).
|
samer@2
|
10 function a0=timed_action(x,varargin)
|
samer@37
|
11 opts=options('print',0,'errorfn',@(t)nows-t,varargin{:});
|
samer@2
|
12 if opts.print, a0=@aa_print; else a0=@aa; end
|
samer@2
|
13 errfn=opts.errorfn;
|
samer@0
|
14
|
samer@2
|
15 function varargout=aa_print(t0,varargin),
|
samer@2
|
16 varargout{1}=errfn(t0);
|
samer@2
|
17 [varargout{2:nargout}]=x(varargin{:});
|
samer@2
|
18 fprintf('timed_action: error=%g\n',varargout{1});
|
samer@2
|
19 end
|
samer@2
|
20 function varargout=aa(t0,varargin),
|
samer@2
|
21 varargout{1}=errfn(t0);
|
samer@2
|
22 [varargout{2:nargout}]=x(varargin{:});
|
samer@0
|
23 end
|
samer@0
|
24 end
|