2010-12-16 23:01:29 -04:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 3; indent-tabs-mode: t -*-
|
|
|
|
/*
|
2011-07-30 17:35:36 -03:00
|
|
|
AP_RangeFinder_MaxsonarXL.cpp - Arduino Library for Sharpe GP2Y0A02YK0F
|
2010-12-16 23:01:29 -04:00
|
|
|
infrared proximity sensor
|
|
|
|
Code by Jose Julio and Randy Mackay. DIYDrones.com
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
2010-12-22 21:23:10 -04:00
|
|
|
Sparkfun URL: http://www.sparkfun.com/products/9491
|
|
|
|
datasheet: http://www.sparkfun.com/datasheets/Sensors/Proximity/XL-EZ0-Datasheet.pdf
|
2011-07-30 17:35:36 -03:00
|
|
|
|
2010-12-16 23:01:29 -04:00
|
|
|
Sensor should be connected to one of the analog ports
|
2011-07-30 17:35:36 -03:00
|
|
|
|
2010-12-16 23:01:29 -04:00
|
|
|
Variables:
|
|
|
|
int raw_value : raw value from the sensor
|
2010-12-22 21:23:10 -04:00
|
|
|
int distance : distance in cm
|
2010-12-16 23:01:29 -04:00
|
|
|
int max_distance : maximum measurable distance (in cm)
|
|
|
|
int min_distance : minimum measurable distance (in cm)
|
2011-07-30 17:35:36 -03:00
|
|
|
|
2010-12-16 23:01:29 -04:00
|
|
|
Methods:
|
|
|
|
read() : read value from analog port and returns the distance (in cm)
|
2011-07-30 17:35:36 -03:00
|
|
|
|
2010-12-16 23:01:29 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
// AVR LibC Includes
|
|
|
|
#include "WConstants.h"
|
|
|
|
#include "AP_RangeFinder_MaxsonarXL.h"
|
|
|
|
|
2011-01-03 00:17:43 -04:00
|
|
|
// Constructor //////////////////////////////////////////////////////////////
|
2011-07-30 17:35:36 -03:00
|
|
|
|
2011-11-12 23:16:31 -04:00
|
|
|
AP_RangeFinder_MaxsonarXL::AP_RangeFinder_MaxsonarXL(AP_AnalogSource *source,
|
|
|
|
ModeFilter *filter) :
|
|
|
|
RangeFinder(source, filter)
|
2010-12-16 23:01:29 -04:00
|
|
|
{
|
2011-01-03 00:17:43 -04:00
|
|
|
max_distance = AP_RANGEFINDER_MAXSONARXL_MAX_DISTANCE;
|
2010-12-16 23:01:29 -04:00
|
|
|
min_distance = AP_RANGEFINDER_MAXSONARXL_MIN_DISTANCE;
|
|
|
|
}
|
|
|
|
|
2011-01-03 00:17:43 -04:00
|
|
|
// Public Methods //////////////////////////////////////////////////////////////
|