From 41eeba97cad83136b3c41b5415316e0f9c95f1ea Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Tue, 5 Dec 2006 20:51:03 +0000 Subject: [PATCH] Removing Sonar library as per Tom Igoe's suggestion. --- targets/libraries/Sonar/Sonar.cpp | 82 ------------------- targets/libraries/Sonar/Sonar.h | 40 --------- .../libraries/Sonar/examples/sonar/sonar.pde | 22 ----- targets/libraries/Sonar/keywords.txt | 22 ----- 4 files changed, 166 deletions(-) delete mode 100755 targets/libraries/Sonar/Sonar.cpp delete mode 100755 targets/libraries/Sonar/Sonar.h delete mode 100644 targets/libraries/Sonar/examples/sonar/sonar.pde delete mode 100644 targets/libraries/Sonar/keywords.txt diff --git a/targets/libraries/Sonar/Sonar.cpp b/targets/libraries/Sonar/Sonar.cpp deleted file mode 100755 index 59b856f05..000000000 --- a/targets/libraries/Sonar/Sonar.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - Sonar.cpp - Parallax PING))) Ultrasonic Sensor Library - Copyright (c) 2006 David A. Mellis. All right reserved. - - 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. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - For more information on the Parallax PING))) Ultrasonic Sensor, see: - http://www.parallax.com/detail.asp?product_id=28015 -*/ - -/****************************************************************************** - * Includes - ******************************************************************************/ - -#include "WConstants.h" -#include "Sonar.h" - -/****************************************************************************** - * Definitions - ******************************************************************************/ - -/****************************************************************************** - * Constructors - ******************************************************************************/ - -Sonar::Sonar(uint8_t signal) -{ - _pinSignal = signal; -} - -/****************************************************************************** - * User API - ******************************************************************************/ - -unsigned long Sonar::readMicroseconds() -{ - pinMode(_pinSignal, OUTPUT); - - // The PING))) is triggered by a HIGH pulse of 2 or more microseconds. - // We give a short LOW pulse beforehand to ensure a clean HIGH pulse. - digitalWrite(_pinSignal, LOW); - delayMicroseconds(2); - digitalWrite(_pinSignal, HIGH); - delayMicroseconds(5); - digitalWrite(_pinSignal, LOW); - - // The same pin is used to read the signal from the PING))): a HIGH - // pulse whose duration is the time from the sending of the ping to - // to reception of the echo. - pinMode(_pinSignal, INPUT); - - return pulseIn(_pinSignal, HIGH); -} - -unsigned long Sonar::readInches() -{ - // According to Parallax's datasheet for the PING))), there are - // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per - // second). This gives the distance travelled by the ping, outbound - // and return, so we divide by 2 to get the distance of the obstacle. - // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf - return readMicroseconds() / 74 / 2; -} - -unsigned long Sonar::readCentimeters() -{ - // 73.746 microseconds per inch works out to about 29 microseconds per - // centimeter (there are 2.54 centimeters per inch). - return readMicroseconds() / 29 / 2; -} diff --git a/targets/libraries/Sonar/Sonar.h b/targets/libraries/Sonar/Sonar.h deleted file mode 100755 index 3dee8c55c..000000000 --- a/targets/libraries/Sonar/Sonar.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Sonar.h - Parallax PING))) Ultrasonic Sensor Library - Copyright (c) 2006 David A. Mellis. All right reserved. - - 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. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - For more information on the Parallax PING))) Ultrasonic Sensor, see: - http://www.parallax.com/detail.asp?product_id=28015 -*/ - -#ifndef Sonar_h -#define Sonar_h - -#include - -class Sonar -{ - private: - uint8_t _pinSignal; - public: - Sonar(uint8_t); - unsigned long readMicroseconds(); - unsigned long readInches(); - unsigned long readCentimeters(); -}; - -#endif - diff --git a/targets/libraries/Sonar/examples/sonar/sonar.pde b/targets/libraries/Sonar/examples/sonar/sonar.pde deleted file mode 100644 index 36e487a15..000000000 --- a/targets/libraries/Sonar/examples/sonar/sonar.pde +++ /dev/null @@ -1,22 +0,0 @@ -#include - -Ultrasound ultrasound(2); - -void setup() -{ - Serial.begin(9600); -} - -void loop() -{ - Serial.print("Ping took: "); - Serial.print(ultrasound.readMicroseconds()); - Serial.print(" us. Distance is: "); - Serial.print(ultrasound.readCentimeters()); - Serial.print(" cm, "); - Serial.print(ultrasound.readInches()); - Serial.print(" in."); - Serial.println(); - - delay(1000); -} diff --git a/targets/libraries/Sonar/keywords.txt b/targets/libraries/Sonar/keywords.txt deleted file mode 100644 index 20fa05706..000000000 --- a/targets/libraries/Sonar/keywords.txt +++ /dev/null @@ -1,22 +0,0 @@ -####################################### -# Syntax Coloring Map For Ultrasound -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -Sonar KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -readMicroseconds KEYWORD2 -readInches KEYWORD2 -readCentimeters KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### -