00001 /*! \file WaspSensorEvent.h 00002 \brief Library for managing the Prototyping Sensor Board 00003 00004 Copyright (C) 2009 Libelium Comunicaciones Distribuidas S.L. 00005 http://www.libelium.com 00006 00007 This program is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU Lesser General Public License as published by 00009 the Free Software Foundation, either version 2.1 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 00020 Version: 0.1 00021 00022 Design: David Gascón 00023 00024 Implementation: Alberto Bielsa, Manuel Calahorra 00025 00026 */ 00027 00028 /*! \def WaspSensorPrototyping_h 00029 \brief The library flag 00030 00031 */ 00032 #ifndef WaspSensorPrototyping_h 00033 #define WaspSensorPrototyping_h 00034 00035 00036 /****************************************************************************** 00037 * Includes 00038 ******************************************************************************/ 00039 00040 #include <inttypes.h> 00041 00042 00043 /****************************************************************************** 00044 * Definitions & Declarations 00045 ******************************************************************************/ 00046 00047 /*! \def SENS_RELAY_ON 00048 \brief Sensor Board Relay Power Mode. ON in this case 00049 00050 */ 00051 /*! \def SENS_RELAY_OFF 00052 \brief Sensor Board Relay Power Mode. OFF in this case 00053 00054 */ 00055 #define SENS_RELAY_ON 0 00056 #define SENS_RELAY_OFF 1 00057 00058 /*! \def RELAY_PIN 00059 \brief Digital pin used for managing the relay 00060 00061 */ 00062 #define RELAY_PIN DIGITAL2 00063 00064 /****************************************************************************** 00065 * Class 00066 ******************************************************************************/ 00067 00068 //! WaspSensorPrototyping Class 00069 /*! 00070 WaspSensorPrototyping Class defines all the variables and functions used for managing the Prototyping Sensor Board 00071 */ 00072 class WaspSensorPrototyping 00073 { 00074 private: 00075 00076 public: 00077 00078 //! class constructor 00079 /*! 00080 It initializes the different digital pins 00081 \param void 00082 \return void 00083 */ 00084 WaspSensorPrototyping(); 00085 00086 //! It sets board power mode, setting ON/OFF 3v3 and 5V switches 00087 /*! 00088 \param uint8_t mode : SENS_ON or SENS_OFF 00089 \return void 00090 */ 00091 void setBoardMode(uint8_t mode); 00092 00093 //! It sets relay power mode, setting ON/OFF its switch 00094 /*! 00095 \param uint8_t mode : SENS_ON or SENS_OFF 00096 \return void 00097 */ 00098 void setRelayMode(uint8_t mode); 00099 00100 //! It reads the Analogic-to-Digital Converter 00101 /*! 00102 \param void 00103 \return the value returned by the conversor 00104 */ 00105 float readADC(); 00106 00107 //! It sets the load resistor value 00108 /*! 00109 \param float resistor : the value to set the load resistor to (range [0-100] KOhms) 00110 \return void 00111 */ 00112 void setLoadResistor(float resistor); 00113 00114 //! It sets the amplifier gain 00115 /*! 00116 \param float gain : the gain to set the amplifier to (range [1-11]) 00117 \return void 00118 */ 00119 void setAmplifierGain(float gain); 00120 00121 //! It reads an analog sensor and returns its measured value in Volts 00122 /*! 00123 \param uint8_t pin : specifies the analog pin where the sensor is connected 00124 \return the measured value in Volts (range [0-3.3] Volts) 00125 */ 00126 float readAnalogSensor(uint8_t pin); 00127 }; 00128 00129 extern WaspSensorPrototyping SensorProto; 00130 00131 #endif
1.5.6