VISHAY CNY70 reflective sensor library

Dependents:   FRC_2018 0hackton_08_06_18 lib_FRC_2019 lib_FRC_2019 ... more

Committer:
haarkon
Date:
Mon May 21 16:13:34 2018 +0000
Revision:
1:95219d950eeb
Parent:
0:94ce69cee360
Child:
2:9dec6e856355
Cosmetic modification (still untested)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
haarkon 0:94ce69cee360 1 /**
haarkon 0:94ce69cee360 2 * @author Hugues Angelis
haarkon 0:94ce69cee360 3 *
haarkon 0:94ce69cee360 4 * @section LICENSE
haarkon 0:94ce69cee360 5 *
haarkon 0:94ce69cee360 6 * Copyright (c) 2010 ARM Limited
haarkon 0:94ce69cee360 7 *
haarkon 0:94ce69cee360 8 * Permission is hereby granted, free of charge, to any person obtaining a copy
haarkon 0:94ce69cee360 9 * of this software and associated documentation files (the "Software"), to deal
haarkon 0:94ce69cee360 10 * in the Software without restriction, including without limitation the rights
haarkon 0:94ce69cee360 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
haarkon 0:94ce69cee360 12 * copies of the Software, and to permit persons to whom the Software is
haarkon 0:94ce69cee360 13 * furnished to do so, subject to the following conditions:
haarkon 0:94ce69cee360 14 *
haarkon 0:94ce69cee360 15 * The above copyright notice and this permission notice shall be included in
haarkon 0:94ce69cee360 16 * all copies or substantial portions of the Software.
haarkon 0:94ce69cee360 17 *
haarkon 0:94ce69cee360 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
haarkon 0:94ce69cee360 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
haarkon 0:94ce69cee360 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
haarkon 0:94ce69cee360 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
haarkon 0:94ce69cee360 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
haarkon 0:94ce69cee360 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
haarkon 0:94ce69cee360 24 * THE SOFTWARE.
haarkon 0:94ce69cee360 25 *
haarkon 0:94ce69cee360 26 * @section DESCRIPTION
haarkon 0:94ce69cee360 27 *
haarkon 0:94ce69cee360 28 * VISHAY CNY70 Analog reflective sensor library
haarkon 0:94ce69cee360 29 *
haarkon 0:94ce69cee360 30 * @note this library provide a simple equivalent of the reading the voltage of
haarkon 0:94ce69cee360 31 * an analog input.
haarkon 0:94ce69cee360 32 */
haarkon 0:94ce69cee360 33
haarkon 0:94ce69cee360 34 #ifndef CNY70_H
haarkon 0:94ce69cee360 35 #define CNY70_H
haarkon 0:94ce69cee360 36
haarkon 0:94ce69cee360 37 /**
haarkon 0:94ce69cee360 38 * Includes
haarkon 0:94ce69cee360 39 */
haarkon 0:94ce69cee360 40 #include "mbed.h"
haarkon 0:94ce69cee360 41
haarkon 0:94ce69cee360 42 /**
haarkon 0:94ce69cee360 43 * CNY70 Sensor
haarkon 0:94ce69cee360 44 */
haarkon 0:94ce69cee360 45 class CNY70 {
haarkon 0:94ce69cee360 46
haarkon 0:94ce69cee360 47 public :
haarkon 0:94ce69cee360 48
haarkon 0:94ce69cee360 49 /**
haarkon 0:94ce69cee360 50 * Constructor.
haarkon 0:94ce69cee360 51 *
haarkon 0:94ce69cee360 52 * @param vmes is the Mbed pin used to connect with CNY70 sensor
haarkon 0:94ce69cee360 53 */
haarkon 0:94ce69cee360 54 CNY70(PinName vmes);
haarkon 0:94ce69cee360 55
haarkon 0:94ce69cee360 56 /**
haarkon 0:94ce69cee360 57 * Return the voltage on the CNY70 output pin
haarkon 0:94ce69cee360 58 *
haarkon 0:94ce69cee360 59 * @return : a voltage between 0 and 3.3V
haarkon 0:94ce69cee360 60 */
haarkon 1:95219d950eeb 61 double getVoltage (void);
haarkon 1:95219d950eeb 62
haarkon 1:95219d950eeb 63 /**
haarkon 1:95219d950eeb 64 * A short hand of getVoltage
haarkon 1:95219d950eeb 65 */
haarkon 1:95219d950eeb 66 operator double();
haarkon 1:95219d950eeb 67
haarkon 0:94ce69cee360 68
haarkon 0:94ce69cee360 69 protected :
haarkon 0:94ce69cee360 70
haarkon 0:94ce69cee360 71 AnalogIn _sensor ;
haarkon 0:94ce69cee360 72
haarkon 0:94ce69cee360 73 };
haarkon 0:94ce69cee360 74 #endif //CNY70_H