function CMETER
% CMETER('Command');
%
% Send commands to the PhotoResearch PR-650 colorimeter.
%
% 	OBSOLETE. Please use PsychSerial.mex instead.
% 	As far as I know, all functions performed by CMETER can now be
% 	accomplished by PsychSerial.mex. We will retain CMETER.mex for a while, 
% 	so as not to break old programs,
% 	but it will go away someday. Denis 7/13/00.
%  
% status = CMETER('Init')
%		The status is 0 if OK, -1 if not OK.
%		On the PC, you can also provided a com port name as an optional
%		second argument. The portName is 'COM2' by default. It can also 
%		be 'COM1', 'COM3', 'COM4', etc.,	if the cmeter is actually connected 
%		to one of these other ports.
%
% status = CMETER('Measure',[timeout])
%		The routine returns after taking a measurement or after timeout.
%		Default timeout is 30 sec.
%
%		The status 0 if OK, -1 if no response (timeout),
%		and the measurement quality code otherwise.
%		See Colorimeter manual page B-27 for quality codes.
%
% spectrum = CMETER('Spectrum')
%   Obtains the spectral data from the last measurement taken.
%   Converts from power density to power by multiplying raw
%   returned values by the meter's wavelength spacing.
%   OUTPUT
%			Spectral data in the form of a 100 row, 2 column matrix.
%			First column is the wavelength in nm.
%			Second column is the intensity at each wavelength.
%			Range of wavelengths is 380 to 780 in 4 nm steps.
%
% status = CMETER('SetUnits',units)
%		Sets the type of units for returned luminosity data.
% 	INPUT
%			0 - English units: footLamberts and footcandles.
%			1 - Metric(SI) units: cd*m-2 and lux
%		OUTPUT
%			status - 0 if OK, something else if not.
%
% status = CMETER('SetParams',synch,integration,avgcnt)
%		Sets the synch, integration time, and averaging count
%		for the colorimeter.
%
%   A problem is that these get reset each time CMSetUnits
%		is called.  This needs to be fixed before this routine
%		is of much use.  Probably the correct thing to do is to store
%   some globals in a single driver routine and interface to this
%   with various M-files.
%		OUTPUT
%			status - 0 if OK, return code if not OK
%
% response = CMETER('Cmd','command string')
%		Sends the command string to the colorimeter.
% 	INPUT
%			Command string (see p. B-8 ff of the operating manual).
%		OUTPUT
%			String returned by the meter in response to the command.
%
%			Note: This function will not return the spectral data properly 
%     because the default timeout value is too short to allow
%     completion of returning all the data.  Use CMSpectrum to get
%     spectral data.
%
% XYZ = CMETER('XYZ')
%		Send a command to the colorimeter to return the 1931 CIE X, Y, and Z data.
%		Y is specified in cd/m^2.
%
% Yxy = CMETER('Yxy')
% 	Send a command to the colorimeter to return the Luminance (1931 CIE Y)
% 	and the 1931 CIE x and y.
% 	Y is specified in cd/m^2.
%
% Ytd = CM('Ytd')
%	 	Send a command to the colorimeter to return the Luminance (1931 CIE Y)
% 	and the Correlated Color Temperature in Kelvins (t) and the 
% 	deviation of color coordinates from in ideal Planckian radiator
% 	in 1960 CIE u-v units (d) (+ indicates the coordinates lie above
% 	the Planckian locus).
%
% Yuv = CM('Yuv')
% 	Send a command to the colorimeter to return the Luminance (1931 CIE Y)
% 	and the 1976 CIE u' and v' data.
% 	Y is specified in cd/m^2.
%
% CMETER('CTS',value)
% 	Reset or set the CTS line on the serial port.  Value can be 0 or 1.
%
% NOTE:  This routine sometimes gets munged in Matlab's memory.  The symptom
% is that the Matlab interpreter cannot find it.  We haven't been able to
% track down the problem, but typing "clear mex" usually fixes it. Presumably
% we have some sort of pointer error somewhere.
%
% (Note from xmz: I haven't noticed this on the Windows platform. I guess if it
% is a pointer error in the Cmeter code, it will eventually show up ...)

%
% 12/4/96  dhb  Updated help.
% 9/25/98  xmz	Added a few comments about the PC version.
% 7/13/00  dgp  Note obsolescence.
