/***************************************************************************
 *   Copyright (C) 30.4.2004 by                                           *
 *   Matthias Kranz (matthias.kranz@ifi.lmu.de)                            *
 *   Paul Holleis (paul.holleis@ifi.lmu.de)                                *
 *                                                                         *
 *   header file for standard SmartITs definitions.                        *
 *                                                                         *
 *                                                                         *
 *   This program 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 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program 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 this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 **************************************************************************/
/******************************************************************************
 * defines
 *****************************************************************************/
#ifndef __GP2D120
  #define __GP2D120
#endif

/// Maximum value returned by the sharp gp2d120 sensor.
#define GP2D120_MAX 1024
/// Minimum value returned by the sharp gp2d120 sensor.
#define GP2D120_MIN 0
/******************************************************************************
 * global variables
 *****************************************************************************/

/******************************************************************************
 * function signatures
 *****************************************************************************/
long read_gp2d120_raw();

/******************************************************************************
 * Code
 *****************************************************************************/
/**
 * Reads the sharp gp2d120 distance sensor and returns the raw sensor value.
 * \return the current raw sensor value, with GP2D120_MIN =< sensor value =< 
 *         GP2D120_MIN.
 */
long read_gp2d120_raw() 
{
	long distance_raw = 0;
	// adc channel 2 (port a2) for the new distscroller board, 0 for the old.
	set_adc_channel(2);
	delay_ms(2);
	distance_raw = read_adc();
	return(distance_raw);
}
