Changeset 502
- Timestamp:
- 12/05/08 16:07:15 (4 years ago)
- Location:
- trunk/mfiles
- Files:
-
- 4 modified
-
Contents.m (modified) (1 diff)
-
GetLight.m (modified) (2 diffs)
-
GetSound.m (modified) (2 diffs)
-
GetSwitch.m (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/mfiles/Contents.m
r501 r502 1 1 % RWTH - Mindstorms NXT Toolbox 2 % Version 2.03 0 4-Dec-20082 % Version 2.03 05-Dec-2008 3 3 % Files 4 4 % CalibrateColor - Enables calibration mode of the HiTechnic color sensor -
trunk/mfiles/GetLight.m
r307 r502 30 30 % Signature 31 31 % Author: Linus Atorf, Alexander Behrens (see AUTHORS) 32 % Date: 200 7/10/1532 % Date: 2008/12/05 33 33 % Copyright: 2007-2008, RWTH Aachen University 34 34 % … … 60 60 in = NXT_GetInputValues(port, handle); 61 61 62 %% Check valid-flag, re-request data if necessary 63 if ~in.Valid 64 % init timeout-counter 65 startTime = clock(); 66 timeOut = 0.1; % in seconds 67 % loop until valid 68 while (~in.Valid) && (etime(clock, startTime) < timeOut) 69 in = NXT_GetInputValues(port, handle); 70 end%while 71 %TODO please note that we DO NOT warn or do anything else if this 72 %procedure above times out -- that seems ok, since we didn't do 73 %that before (old ver. up to 2.02) either... 74 % in that case, the returned value will probably be invalid... 75 % dangerous. 76 % solutions: either WARN, or return NaN... 77 end%if 78 62 79 %% Return normalized sound value (0...1023 / 10 Bit) 63 80 light = double(in.NormalizedADVal); -
trunk/mfiles/GetSound.m
r307 r502 30 30 % Signature 31 31 % Author: Linus Atorf, Alexander Behrens (see AUTHORS) 32 % Date: 200 7/10/1532 % Date: 2008/12/05 33 33 % Copyright: 2007-2008, RWTH Aachen University 34 34 % … … 59 59 %% Call NXT_GetInputValues function 60 60 in = NXT_GetInputValues(f_sensorport, handle); 61 62 %% Check valid-flag, re-request data if necessary 63 if ~in.Valid 64 % init timeout-counter 65 startTime = clock(); 66 timeOut = 0.1; % in seconds 67 % loop until valid 68 while (~in.Valid) && (etime(clock, startTime) < timeOut) 69 in = NXT_GetInputValues(f_sensorport, handle); 70 end%while 71 %TODO please note that we DO NOT warn or do anything else if this 72 %procedure above times out -- that seems ok, since we didn't do 73 %that before (old ver. up to 2.02) either... 74 % in that case, the returned value will probably be invalid... 75 % dangerous. 76 % solutions: either WARN, or return NaN... 77 end%if 78 61 79 62 80 %% Return normalized sound value (0...1023 / 10 Bit) -
trunk/mfiles/GetSwitch.m
r307 r502 31 31 % Signature 32 32 % Author: Linus Atorf, Alexander Behrens (see AUTHORS) 33 % Date: 200 7/10/1533 % Date: 2008/12/05 34 34 % Copyright: 2007-2008, RWTH Aachen University 35 35 % … … 76 76 in = NXT_GetInputValues(f_sensorport, handle); 77 77 78 %% Check valid-flag, re-request data if necessary 79 if ~in.Valid 80 % init timeout-counter 81 startTime = clock(); 82 timeOut = 0.1; % in seconds 83 % loop until valid 84 while (~in.Valid) && (etime(clock, startTime) < timeOut) 85 in = NXT_GetInputValues(f_sensorport, handle); 86 end%while 87 %TODO please note that we DO NOT warn or do anything else if this 88 %procedure above times out -- that seems ok, since we didn't do 89 %that before (old ver. up to 2.02) either... 90 % in that case, the returned value will probably be invalid... 91 % dangerous. 92 % solutions: either WARN, or return NaN... 93 end%if 94 78 95 %% Do threshold decision 79 96 % 511 should be ok, being right in the middle between both "peaks"
