/*! \file include/proximity.h */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * 2000.01.02 - Carsten Mller * * Proximity Driver for legOS 0.2.3 * * 2013.10.10 - Zhengrong Zang * * - Use IR and light sensor as a proximity sensor for brickOS 0.9 * */ #ifndef __proximity_h__ #define __proximity_h__ #ifdef __cplusplus extern "C" { #endif #ifdef CONF_DSENSOR_PROXIMITY /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// #define PROXIMITY_THRESHOLD 0x20 // Default proximity threshold value #define TRANSMITTING 1 // Transmitting phase #define IDLE 0 // Idle phase // processed proximity sensor #define PROXIMITY_1 (ds_proximitys[0]) //!< proximity sensor on input 1 #define PROXIMITY_2 (ds_proximitys[1]) //!< proximity sensor on input 2 #define PROXIMITY_3 (ds_proximitys[2]) //!< proximity sensor on input 3 /////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////// unsigned threshold; //!< Threshold to detect objects in proximity sensor volatile int clock_pahse; // Indicator of Transmitter (TRANSMITTING | IDLE) volatile int detecting; // Detection Indicator /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// // The initializer // starts the transmitter and the counter threads extern int ds_proximity_on(volatile unsigned *sensor, unsigned threshhold); // Stop all threads extern int ds_proximity_off(void); // the Transmitter thread // transmitts as much IR signals as possible int transmitter(int agrc,char **argv); // The Counter thread - // counts Light Peeks during transmission phase of the transmitter thread // the counts are stored in ProximityCounter int count_reflections(int argc,char ** argv); #endif // CONF_DSENSOR_PROXIMITY #ifdef __cplusplus } #endif #endif // __proximity_h__