Index: /trunk/mfiles/GetNXT2Color.m
===================================================================
--- /trunk/mfiles/GetNXT2Color.m	(revision 904)
+++ /trunk/mfiles/GetNXT2Color.m	(revision 904)
@@ -0,0 +1,48 @@
+function out = GetNXT2Color( f_sensorport, varargin )
+%GETNXT2COLOR Summary of this function goes here
+%   Detailed explanation goes here
+
+%% check parameters
+
+  if nargin > 1
+    handle = varargin{1};
+  else
+    handle = COM_GetDefaultNXT;
+  end%if
+  
+%% call NXT_GetInputValues
+  
+    in = NXT_GetInputValues( f_sensorport, handle );
+    
+%% check for valid date, re-request if necessary
+  
+    startTime = clock();
+    timeOut = 0.1; % in seconds
+    % loop until valid
+    while (~in.Valid) && (etime(clock, startTime) < timeOut)
+      in = NXT_GetInputValues(f_sensorport, handle);
+    end%while
+    
+    if strcmp(in.TypeName,'NO_SENSOR')
+      error('No sensor set up for that port')
+    end%if
+    
+%% format output
+
+    if strcmp(in.TypeName, 'COLORFULL') && strcmp(in.ModeName,'RAWMODE')
+      colors = {'BLACK';'BLUE';'GREEN';'YELLOW';'RED';'WHITE'};
+      try
+        out = colors{ in.ScaledVal };
+      catch
+        out = 'UNKNOWN';
+      end%try
+    else
+      if strcmp(in.ModeName,'RAWMODE') && ( strcmp(in.TypeName,'COLORRED') || strcmp(in.TypeName,'COLORGREEN') || strcmp(in.TypeName,'COLORBLUE') )
+        out = floor( in.ScaledVal / 1024 * 100 );
+      else
+        error('Invalid type/mode combination.  Try using NXT_GetInputValues.')
+      end%if
+    end
+
+end
+
Index: /trunk/mfiles/OpenNXT2Color.m
===================================================================
--- /trunk/mfiles/OpenNXT2Color.m	(revision 904)
+++ /trunk/mfiles/OpenNXT2Color.m	(revision 904)
@@ -0,0 +1,39 @@
+function OpenNXT2Color(port, type, varargin)
+%OPENCOLOR Summary of this function goes here
+%   Detailed explanation goes here
+
+%% check parameters
+
+  % check if handle is given; if not use default one
+  if nargin > 2
+    handle = varargin{1};
+  else
+    handle = COM_GetDefaultNXT;
+  end%if
+  
+  % also accept strings as input
+  if ischar(port)
+    port = str2double(port);
+  end%if
+  
+%% check and set mode
+
+  sensormode = 'RAWMODE';
+  if strcmp(type, 'LIGHTRED') || strcmp(type, 'LIGHT')
+    sensortype = 'COLORRED';
+  elseif strcmp(type, 'LIGHTGREEN')
+    sensortype = 'COLORGREEN';
+  elseif strcmp(type, 'LIGHTBLUE')
+    sensortype = 'COLORBLUE';
+  elseif strcmp(type, 'COLOR')
+    sensortype = 'COLORFULL';
+  else
+    error('Invalid mode.  Must be LIGHT, LIGHTRED, LIGHTGREEN, LIGHTBLUE or COLOR.')
+  end%if
+  
+%% call NXT_SetInputMode function
+
+  NXT_SetInputMode( port, sensortype, sensormode, 'dontreply', handle );
+  
+end%function
+
Index: /trunk/mfiles/GetColor.m
===================================================================
--- /trunk/mfiles/GetColor.m	(revision 902)
+++ /trunk/mfiles/GetColor.m	(revision 904)
@@ -66,4 +66,10 @@
 %   specified, the default handle will be used (call |COM_SetDefaultNXT| to
 %   set one).
+%
+% Limitations
+%   It's by design that the white LED of the Color sensors cannot be turned
+%   off by calling |CloseSensor|. It's always on when the sensor is
+%   connected. The V2 hardware version of the sensor performs significantly
+%   better than the V1 version.
 %
 % Example
Index: /trunk/mfiles/GetEOPD.m
===================================================================
--- /trunk/mfiles/GetEOPD.m	(revision 904)
+++ /trunk/mfiles/GetEOPD.m	(revision 904)
@@ -0,0 +1,121 @@
+function [calcedDist rawVal] = GetEOPD(port, handle)
+% Reads the current value of the HiTechnic EOPD sensor
+%
+% Syntax
+%   ||
+%
+%   ||
+%
+% Description
+%   |angularVelocity = GetGyro(port)| returns the current rotational speed detected by
+%   the HiTechnic Gyroscopic sensor. Maximum range is from -360 to 360 degrees per second
+%   (according to HiTechnic documentation), however greater values have
+%   been observed. Returned values are accurate to +/- 1 degree.
+%
+%   Integration over time gives the rotational position (in degrees). Tests give quite good
+%   results.  The given port number specifies the connection port. The value port can be
+%   addressed by the symbolic constants |SENSOR_1|, |SENSOR_2|, |SENSOR_3| and |SENSOR_4| analog to
+%   the labeling on the NXT Brick.
+%
+%   Before using this function, the EOPD sensor must be initialized using |OpenEOPD| 
+%   and should be calibrated using |CalibrateEOPD|. Otherwise, only raw
+%   values will be usable.
+%
+%   The last optional argument can be a valid NXT handle. If none is
+%   specified, the default handle will be used (call |COM_SetDefaultNXT| to
+%   set one).
+%
+% Example
+%+   OpenEOPD(SENSOR_2);
+%+   %todo
+%+   
+%+   CloseSensor(SENSOR_2);
+%
+% See also: OpenEOPD, CalibrateEOPD, CloseSensor, NXT_SetInputMode, NXT_GetInputValues
+%
+% Signature
+%   Author: Linus Atorf (see AUTHORS)
+%   Date: 2010/09/17
+%   Copyright: 2007-2010, RWTH Aachen University
+%
+;
+% ***********************************************************************************************
+% *  This file is part of the RWTH - Mindstorms NXT Toolbox.                                    *
+% *                                                                                             *
+% *  The RWTH - Mindstorms NXT Toolbox is free software: you can redistribute it and/or modify  *
+% *  it under the terms of the GNU General Public License as published by the Free Software     *
+% *  Foundation, either version 3 of the License, or (at your option) any later version.        *
+% *                                                                                             *
+% *  The RWTH - Mindstorms NXT Toolbox is distributed in the hope that it will be useful,       *
+% *  but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS  *
+% *  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
+% *                                                                                             *
+% *  You should have received a copy of the GNU General Public License along with the           *
+% *  RWTH - Mindstorms NXT Toolbox. If not, see <http://www.gnu.org/licenses/>.                 *
+% ***********************************************************************************************
+
+
+
+% see private/createEmptyHandleStruct for hardcoded DEFAULT OFFSET VALUES
+
+
+%% Parameter check
+
+    % NXT handle given?
+    if ~exist('handle', 'var')
+        handle = COM_GetDefaultNXT();
+    end
+
+    % we have to check port number here as an exception (we usually don't
+    % do it, as it gets checked by NXT_ "lower level" functions later on
+    % anyway), because we use port as an index in handle.GyroSensorOffset()
+    
+    % except strings as input
+    if ischar(port)
+        port = double(port);
+    end%if
+    if port < 0 || port > 3 
+        error('MATLAB:RWTHMindstormsNXT:Sensor:invalidPort', 'NXT InputPort must be between 0 and 3 (use constants 0SENSOR_1 to SENSOR_4)', port);
+    end%if
+    
+%% Obtain EOPD calibration
+
+    % save to use the port now...
+    tmp = handle.GyroSensorOffset(port);
+    % tmp(1) = offset, tmp(2) = bool initialized
+    if ~tmp(2)
+        warning('MATLAB:RWTHMindstormsNXT:Sensor:gyroNotCalibrated', 'The HiTechnic Gyro sensor on this port has not been calibrated yet. Use CalibrateGyro() after OpenGyro() or disable this warning by calling  warning(''off'', ''MATLAB:RWTHMindstormsNXT:Sensor:gyroNotCalibrated'')');
+    end%if
+    offset = tmp(1);
+    
+%% Call NXT_GetInputValues function
+    in = NXT_GetInputValues(port, handle);
+
+%% Check valid-flag, re-request data if necessary
+    if ~in.Valid
+        % init timeout-counter
+        startTime = clock();
+        timeOut = 0.5; % in seconds
+        % loop until valid
+        %invalidCountGetGyro = 0;
+        while (~in.Valid) && (etime(clock, startTime) < timeOut)
+            in = NXT_GetInputValues(port, handle);
+            %invalidCountGetGyro = invalidCountGetGyro + 1;
+        end%while
+        %invalidCountGetGyro
+        % check if everything is ok now...
+        if ~in.Valid
+            warning('MATLAB:RWTHMindstormsNXT:Sensor:invalidData', ...
+                   ['Returned sensor data marked invalid! ' ...
+                    'Make sure the sensor is properly connected and configured to a supported mode. ' ...
+                    'Disable this warning by calling  warning(''off'', ''MATLAB:RWTHMindstormsNXT:Sensor:invalidData'')']);
+        end%if
+    end%if
+    
+    
+%% Finally, return gyro data after offset substraction
+    % do stuff here
+    angularVelocity = double(in.RawADVal);
+      
+    
+end%function
Index: /trunk/mfiles/OpenColor.m
===================================================================
--- /trunk/mfiles/OpenColor.m	(revision 902)
+++ /trunk/mfiles/OpenColor.m	(revision 904)
@@ -23,4 +23,11 @@
 %
 %
+% Limitations
+%   It's by design that the white LED of the Color sensors cannot be turned
+%   off by calling |CloseSensor|. It's always on when the sensor is
+%   connected. The V2 hardware version of the sensor performs significantly
+%   better than the V1 version.
+% 
+%
 % Examples
 %+   OpenColor(SENSOR_2);
@@ -28,5 +35,5 @@
 %+   CloseSensor(SENSOR_2);
 %
-% See also: GetColor, CloseSensor, COM_ReadI2C, NXT_LSGetStatus, NXT_LSRead
+% See also: GetColor, CloseSensor, OpenColorNXT2, GetColorNXT2, COM_ReadI2C
 %
 % Signature
Index: /trunk/mfiles/OpenEOPD.m
===================================================================
--- /trunk/mfiles/OpenEOPD.m	(revision 904)
+++ /trunk/mfiles/OpenEOPD.m	(revision 904)
@@ -0,0 +1,98 @@
+function OpenEOPD(port, range, handle)
+% Initializes the HiTechnic EOPD sensor, sets correct sensor mode
+%
+% Syntax
+%   |OpenEOPD(port, range)|
+%
+%   |OpenEOPD(port, range, handle)|
+%
+% Description
+%   |OpenEOPD(port, range)| initializes the HiTechnic EOPD sensor on the specified sensor
+%   port. This sensor can be used to accurately detect objects and small
+%   changes in distance to a target. It works by measuring the light
+%   returned from its own light source, so it can also be used to detect
+%   the "shinyness" and color of a surface.
+%
+%   |range| can be set to either |'SHORT'|, which covers a range of about
+%   10cm, or it can be set to |'LONG'|, which enables increased sensitivity
+%   for up to 20cm.
+%
+%   The value |port| can be addressed by the symbolic constants
+%   |SENSOR_1| , |SENSOR_2|, |SENSOR_3| and |SENSOR_4| analog to the labeling on the NXT Brick.
+%
+%   Before the sensor can be used, |CalibrateEOPD| should be called,
+%   otherwise only raw values will be usable.
+%
+%   The last optional argument can be a valid NXT handle. If none is
+%   specified, the default handle will be used (call |COM_SetDefaultNXT| to
+%   set one).
+%
+% Note:
+%   For more details on calibration, see help text and examples of
+%   |CalibrateEOPD|.
+%
+%   Since each EOPD sensor uses a slightly different pulse frequency for
+%   the LED, multiple sensor can be used at once without influencing each
+%   other.
+%
+% Examples
+%+   OpenEOPD(SENSOR_2);
+%+   %todo!
+%+
+%+   CloseSensor(SENSOR_2);
+%
+% See also: CalibrateEOPD, GetEOPD, CloseSensor, NXT_SetInputMode, NXT_GetInputValues
+%
+% Signature
+%   Author: Linus Atorf (see AUTHORS)
+%   Date: 2009/09/17
+%   Copyright: 2007-2010, RWTH Aachen University
+%
+;
+% ***********************************************************************************************
+% *  This file is part of the RWTH - Mindstorms NXT Toolbox.                                    *
+% *                                                                                             *
+% *  The RWTH - Mindstorms NXT Toolbox is free software: you can redistribute it and/or modify  *
+% *  it under the terms of the GNU General Public License as published by the Free Software     *
+% *  Foundation, either version 3 of the License, or (at your option) any later version.        *
+% *                                                                                             *
+% *  The RWTH - Mindstorms NXT Toolbox is distributed in the hope that it will be useful,       *
+% *  but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS  *
+% *  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
+% *                                                                                             *
+% *  You should have received a copy of the GNU General Public License along with the           *
+% *  RWTH - Mindstorms NXT Toolbox. If not, see <http://www.gnu.org/licenses/>.                 *
+% ***********************************************************************************************
+
+
+% see private/createEmptyHandleStruct for hardcoded DEFAULT OFFSET VALUES
+
+
+%% Parameter check
+
+    % NXT handle given?
+    if ~exist('handle', 'var')
+        handle = COM_GetDefaultNXT();
+    end
+
+    % also accept strings as input
+    if ischar(port)
+        port = str2double(port);
+    end%if
+
+    if ~strcmpi(range, 'SHORT') && ~strcmpi(range, 'LONG')
+        error('MATLAB:RWTHMindstormsNXT:Sensor:invalidMode', 'EOPD sensor range has to be ''SHORT'' or ''LONG''!');
+    end
+    
+    if strcmpi(range, 'SHORT')
+        type = 'LIGHT_INACTIVE';
+    else
+        type = 'LIGHT_ACTIVE';
+    end%if
+    
+    
+    NXT_SetInputMode(port , type, 'RAWMODE', 'dontreply', handle);
+    % give sensor some bootup time
+    pause(0.1);
+
+end%function
