00001 /*! \file WaspSensorEvent.h 00002 \brief Library for managing the Event 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 00029 /*! \def WaspSensorEvent_h 00030 \brief The library flag 00031 00032 */ 00033 #ifndef WaspSensorEvent_h 00034 #define WaspSensorEvent_h 00035 00036 /****************************************************************************** 00037 * Includes 00038 ******************************************************************************/ 00039 #include <inttypes.h> 00040 00041 /****************************************************************************** 00042 * Definitions & Declarations 00043 ******************************************************************************/ 00044 00045 /*! \def SENS_SOCKET4 00046 \brief Sensor sockets. Socket number 4 in this case 00047 00048 */ 00049 /*! \def SENS_SOCKET3 00050 \brief Sensor sockets. Socket number 3 in this case 00051 00052 */ 00053 /*! \def SENS_SOCKET6 00054 \brief Sensor sockets. Socket number 6 in this case 00055 00056 */ 00057 /*! \def SENS_SOCKET5 00058 \brief Sensor sockets. Socket number 5 in this case 00059 00060 */ 00061 /*! \def SENS_SOCKET1 00062 \brief Sensor sockets. Socket number 1 in this case 00063 00064 */ 00065 /*! \def SENS_SOCKET2 00066 \brief Sensor sockets. Socket number 2 in this case 00067 00068 */ 00069 /*! \def SENS_SOCKET7 00070 \brief Sensor sockets. Socket number 7 in this case 00071 00072 */ 00073 /*! \def SENS_SOCKET8 00074 \brief Sensor sockets. Socket number 8 in this case 00075 00076 */ 00077 #define SENS_SOCKET4 1 00078 #define SENS_SOCKET3 2 00079 #define SENS_SOCKET6 4 00080 #define SENS_SOCKET5 8 00081 #define SENS_SOCKET1 16 00082 #define SENS_SOCKET2 32 00083 #define SENS_SOCKET7 64 00084 #define SENS_SOCKET8 128 00085 00086 /****************************************************************************** 00087 * Class 00088 ******************************************************************************/ 00089 00090 //! WaspSensorEvent Class 00091 /*! 00092 WaspSensorEvent Class defines all the variables and functions used for managing the Event Sensor Board 00093 */ 00094 class WaspSensorEvent 00095 { 00096 private: 00097 00098 //! It sets the Digipot0 threshold 00099 /*! 00100 \param uint8_t address : digipo0 address 00101 \param uint8_t value : threshold 00102 \return void 00103 */ 00104 void setDigipot0(uint8_t address, float value); 00105 00106 //! It sets the Digipot1 threshold 00107 /*! 00108 \param uint8_t address : digipo1 address 00109 \param uint8_t value : threshold 00110 \return void 00111 */ 00112 void setDigipot1(uint8_t address, float value); 00113 00114 public: 00115 00116 //! Variable : specifies the sensor that has generated the interruption 00117 /*! 00118 It specifies the socket that has generated the interruption, activating the corresponding flag position using the 'SENS_SOCKETX' definitions (X range [1-8]) 00119 \sa SENS_SOCKET4, SENS_SOCKET3, SENS_SOCKET6, SENS_SOCKET5, SENS_SOCKET1, SENS_SOCKET2, SENS_SOCKET7, SENS_SOCKET8 00120 */ 00121 uint8_t intFlag; 00122 00123 //! class constructor 00124 /*! 00125 It initializes the different digital pins 00126 \param void 00127 \return void 00128 */ 00129 WaspSensorEvent(); 00130 00131 //! It sets ON/OFF the 3V3/5V switches 00132 /*! 00133 \param uint8_t mode : SENS_ON or SENS_OFF 00134 \return void 00135 */ 00136 void setBoardMode(uint8_t mode); 00137 00138 //! It sets threshold configuring digipots 00139 /*! 00140 \param uint8_t sensor : specifies the socket to set the threshold to ('SENS_SOCKETX') 00141 \param float threshold : the threshold to set (0-3.3V) 00142 \return void 00143 */ 00144 void setThreshold(uint8_t sensor, float threshold); 00145 00146 //! It reads the value measured by the sensor 00147 /*! 00148 \param uint8_t sensor : specifies the socket ('SENS_SOCKETX') 00149 \return the value read 00150 */ 00151 float readValue(uint8_t sensor); 00152 00153 //! It attaches the interruption 00154 /*! 00155 \param void 00156 \return void 00157 */ 00158 void attachInt(); 00159 00160 //! It detaches the interruption 00161 /*! 00162 \param void 00163 \return void 00164 */ 00165 void detachInt(); 00166 00167 //! It loads the parallel shift register to check the sensor that has generated the interruption 00168 /*! 00169 \param void 00170 \return the flag to check the sensor that has generated the interruption 00171 */ 00172 uint8_t loadInt(); 00173 }; 00174 00175 extern WaspSensorEvent SensorEvent; 00176 00177 #endif 00178
1.5.6