WaspSensorEvent Class Reference

WaspSensorEvent Class. More...

#include <WaspSensorEvent.h>


Public Member Functions

 WaspSensorEvent ()
 class constructor
void setBoardMode (uint8_t mode)
 It sets ON/OFF the 3V3/5V switches.
void setThreshold (uint8_t sensor, float threshold)
 It sets threshold configuring digipots.
float readValue (uint8_t sensor)
 It reads the value measured by the sensor.
void attachInt ()
 It attaches the interruption.
void detachInt ()
 It detaches the interruption.
uint8_t loadInt ()
 It loads the parallel shift register to check the sensor that has generated the interruption.

Data Fields

uint8_t intFlag
 Variable : specifies the sensor that has generated the interruption.

Private Member Functions

void setDigipot0 (uint8_t address, float value)
 It sets the Digipot0 threshold.
void setDigipot1 (uint8_t address, float value)
 It sets the Digipot1 threshold.


Detailed Description

WaspSensorEvent Class.

WaspSensorEvent Class defines all the variables and functions used for managing the Event Sensor Board

Definition at line 94 of file WaspSensorEvent.h.


Constructor & Destructor Documentation

WaspSensorEvent::WaspSensorEvent (  ) 

class constructor

It initializes the different digital pins

Parameters:
void 
Returns:
void

Definition at line 31 of file WaspSensorEvent.cpp.

References DIGITAL0, DIGITAL1, DIGITAL2, DIGITAL3, DIGITAL4, DIGITAL5, DIGITAL6, DIGITAL7, DIGITAL8, DIGITAL9, digitalWrite(), INPUT, LOW, OUTPUT, pinMode(), and SENS_PW_3V3.

Here is the call graph for this function:


Member Function Documentation

void WaspSensorEvent::setDigipot0 ( uint8_t  address,
float  value 
) [private]

It sets the Digipot0 threshold.

Parameters:
uint8_t address : digipo0 address
uint8_t value : threshold
Returns:
void

Definition at line 265 of file WaspSensorEvent.cpp.

References B00000000, TwoWire::begin(), TwoWire::beginTransmission(), WaspPWR::closeI2C(), delay(), TwoWire::endTransmission(), PWR, TwoWire::send(), and Wire.

Referenced by setThreshold().

00266 {
00267         float thres=0.0;
00268         uint8_t threshold=0;
00269                 
00270         thres=(3.3-value);
00271         thres *=128;
00272         thres /=3.3;
00273         threshold = (uint8_t) thres;
00274         Wire.begin();
00275         delay(100);
00276         Wire.beginTransmission(address);
00277         Wire.send(B00000000);
00278         Wire.send(threshold);
00279         Wire.endTransmission();
00280         PWR.closeI2C(); 
00281 }

Here is the call graph for this function:

Here is the caller graph for this function:

void WaspSensorEvent::setDigipot1 ( uint8_t  address,
float  value 
) [private]

It sets the Digipot1 threshold.

Parameters:
uint8_t address : digipo1 address
uint8_t value : threshold
Returns:
void

Definition at line 246 of file WaspSensorEvent.cpp.

References B00010000, TwoWire::begin(), TwoWire::beginTransmission(), WaspPWR::closeI2C(), delay(), TwoWire::endTransmission(), PWR, TwoWire::send(), and Wire.

Referenced by setThreshold().

00247 {
00248 
00249         float thres=0.0;
00250         uint8_t threshold=0;
00251                 
00252         thres=(3.3-value);
00253         thres *=128;
00254         thres /=3.3;
00255         threshold = (uint8_t) thres;
00256         Wire.begin();
00257         delay(100);
00258         Wire.beginTransmission(address);
00259         Wire.send(B00010000);
00260         Wire.send(threshold);
00261         Wire.endTransmission();
00262         PWR.closeI2C(); 
00263 }

Here is the call graph for this function:

Here is the caller graph for this function:

void WaspSensorEvent::setBoardMode ( uint8_t  mode  ) 

It sets ON/OFF the 3V3/5V switches.

Parameters:
uint8_t mode : SENS_ON or SENS_OFF
Returns:
void

Definition at line 58 of file WaspSensorEvent.cpp.

References digitalWrite(), HIGH, LOW, RTC, RTC_ON, SENS_OFF, SENS_ON, SENS_PW_3V3, and WaspRTC::setMode().

00059 {
00060         switch( mode )
00061         {
00062                 case    SENS_ON :       digitalWrite(SENS_PW_3V3,HIGH);
00063                                         // Sets RTC on to enable I2C
00064                                         RTC.setMode(RTC_ON);
00065                                         break;
00066                 case    SENS_OFF:       digitalWrite(SENS_PW_3V3,LOW);
00067                                         break;
00068         }
00069 }

Here is the call graph for this function:

void WaspSensorEvent::setThreshold ( uint8_t  sensor,
float  threshold 
)

It sets threshold configuring digipots.

Parameters:
uint8_t sensor : specifies the socket to set the threshold to ('SENS_SOCKETX')
float threshold : the threshold to set (0-3.3V)
Returns:
void

Definition at line 76 of file WaspSensorEvent.cpp.

References B0101000, B0101010, B0101100, SENS_SOCKET1, SENS_SOCKET2, SENS_SOCKET3, SENS_SOCKET4, SENS_SOCKET5, SENS_SOCKET6, setDigipot0(), and setDigipot1().

00077 {
00078         switch( sensor )
00079         {
00080                 case    SENS_SOCKET1    :       setDigipot1(B0101000,threshold);
00081                                                 break;
00082                 case    SENS_SOCKET2    :       setDigipot0(B0101000,threshold);
00083                                                 break;
00084                 case    SENS_SOCKET3    :       setDigipot0(B0101100,threshold);
00085                                                 break;
00086                 case    SENS_SOCKET4    :       setDigipot1(B0101100,threshold);
00087                                                 break;
00088                 case    SENS_SOCKET5    :       setDigipot0(B0101010,threshold);
00089                                                 break;
00090                 case    SENS_SOCKET6    :       setDigipot1(B0101010,threshold);
00091                                                 break;
00092         }
00093 }

Here is the call graph for this function:

float WaspSensorEvent::readValue ( uint8_t  sensor  ) 

It reads the value measured by the sensor.

Parameters:
uint8_t sensor : specifies the socket ('SENS_SOCKETX')
Returns:
the value read

Definition at line 96 of file WaspSensorEvent.cpp.

References ANALOG1, ANALOG2, ANALOG3, ANALOG4, ANALOG5, ANALOG6, ANALOG7, analogRead(), DIGITAL5, digitalRead(), SENS_SOCKET1, SENS_SOCKET2, SENS_SOCKET3, SENS_SOCKET4, SENS_SOCKET5, SENS_SOCKET6, SENS_SOCKET7, and SENS_SOCKET8.

00097 {
00098         uint16_t aux=0;
00099         switch( sensor )
00100         {
00101                 case    SENS_SOCKET1    :       aux=analogRead(ANALOG1);
00102                                                 break;
00103                 case    SENS_SOCKET2    :       aux=analogRead(ANALOG2);
00104                                                 break;
00105                 case    SENS_SOCKET3    :       aux=analogRead(ANALOG4);
00106                                                 break;
00107                 case    SENS_SOCKET4    :       aux=analogRead(ANALOG3);
00108                                                 break;
00109                 case    SENS_SOCKET5    :       aux=analogRead(ANALOG6);
00110                                                 break;
00111                 case    SENS_SOCKET6    :       aux=analogRead(ANALOG7);
00112                                                 break;
00113                 case    SENS_SOCKET7    :       aux=digitalRead(DIGITAL5);
00114                                                 return aux;
00115                                                 break;
00116                 case    SENS_SOCKET8    :       aux=analogRead(ANALOG5);
00117                                                 break;
00118         }
00119         return  (aux*3.3)/1023;
00120 }

Here is the call graph for this function:

void WaspSensorEvent::attachInt ( void   ) 

It attaches the interruption.

Parameters:
void 
Returns:
void

Definition at line 127 of file WaspSensorEvent.cpp.

References digitalWrite(), enableInterrupts(), HIGH, SENS_INT, and SENS_INT_ENABLE.

00128 {
00129         digitalWrite(SENS_INT_ENABLE,HIGH); 
00130         enableInterrupts(SENS_INT);
00131 }

Here is the call graph for this function:

void WaspSensorEvent::detachInt ( void   ) 

It detaches the interruption.

Parameters:
void 
Returns:
void

Definition at line 138 of file WaspSensorEvent.cpp.

References digitalWrite(), disableInterrupts(), LOW, SENS_INT, and SENS_INT_ENABLE.

00139 {
00140         digitalWrite(SENS_INT_ENABLE,LOW); 
00141         disableInterrupts(SENS_INT);
00142 }

Here is the call graph for this function:

uint8_t WaspSensorEvent::loadInt (  ) 

It loads the parallel shift register to check the sensor that has generated the interruption.

Parameters:
void 
Returns:
the flag to check the sensor that has generated the interruption

Definition at line 151 of file WaspSensorEvent.cpp.

References delay(), digitalRead(), digitalWrite(), HIGH, intFlag, LOW, SENS_INT_CLK_INH, SENS_INT_CLK_REG, SENS_INT_DO, and SENS_INT_ENABLE.

00152 {
00153         uint8_t a=0;
00154         uint8_t aux=0;
00155         
00156         intFlag=0;
00157         
00158         /*
00159         delay(1);
00160         digitalWrite(SENS_INT_ENABLE, LOW);  //disable tri-state buffer 
00161         delay(10);
00162         digitalWrite(SENS_INT_CLK_INH, LOW);
00163         delay(1);
00164         
00165         for(int a=0;a<8;a++)
00166         {
00167                 if( digitalRead(SENS_INT_DO) ) 
00168                 {
00169                         intFlag |= (1<<a);
00170                 }
00171                 delay(1);
00172                 digitalWrite(SENS_INT_CLK_REG,LOW);
00173                 delay(2);
00174                 digitalWrite(SENS_INT_CLK_REG, HIGH);
00175                 delay(1);
00176         }
00177         */
00178         
00179         delay(1);
00180         digitalWrite(SENS_INT_ENABLE, LOW);  
00181         delay(10);
00182         digitalWrite(SENS_INT_CLK_INH, LOW);
00183         delay(1);
00184 
00185         if(digitalRead(SENS_INT_DO)) intFlag |= 1;
00186         delay(2);
00187 
00188         digitalWrite(SENS_INT_CLK_REG, HIGH);
00189         delay(1);
00190         if(digitalRead(SENS_INT_DO)) intFlag |= 2;
00191         delay(1);
00192         digitalWrite(SENS_INT_CLK_REG, LOW);
00193         delay(2);
00194 
00195         digitalWrite(SENS_INT_CLK_REG, HIGH);
00196         delay(1);
00197         if(digitalRead(SENS_INT_DO)) intFlag |= 4;
00198         delay(1);
00199         digitalWrite(SENS_INT_CLK_REG, LOW);
00200         delay(2);
00201 
00202         digitalWrite(SENS_INT_CLK_REG, HIGH);
00203         delay(1);
00204         if(digitalRead(SENS_INT_DO)) intFlag |= 8;
00205         delay(1);
00206         digitalWrite(SENS_INT_CLK_REG, LOW);
00207         delay(2);
00208 
00209         digitalWrite(SENS_INT_CLK_REG, HIGH);
00210         delay(1);
00211         if(digitalRead(SENS_INT_DO)) intFlag |= 16;
00212         delay(1);
00213         digitalWrite(SENS_INT_CLK_REG, LOW);
00214         delay(2);
00215       
00216         digitalWrite(SENS_INT_CLK_REG, HIGH);
00217         delay(1);
00218         if(digitalRead(SENS_INT_DO)) intFlag |= 32;
00219         delay(1);
00220         digitalWrite(SENS_INT_CLK_REG, LOW);
00221         delay(2);
00222       
00223         digitalWrite(SENS_INT_CLK_REG, HIGH);
00224         delay(1);
00225         if(digitalRead(SENS_INT_DO)) intFlag |= 64;
00226         delay(1);
00227         digitalWrite(SENS_INT_CLK_REG, LOW);
00228         delay(2);
00229 
00230         digitalWrite(SENS_INT_CLK_REG, HIGH);
00231         delay(1);
00232         if(digitalRead(SENS_INT_DO)) intFlag |= 128;
00233         delay(1);
00234         digitalWrite(SENS_INT_CLK_REG, LOW);
00235         delay(2);
00236         
00237         delay(200);
00238         digitalWrite(SENS_INT_ENABLE, HIGH);
00239         digitalWrite(SENS_INT_CLK_INH, HIGH);
00240         
00241         return intFlag;
00242 }

Here is the call graph for this function:


Field Documentation

Variable : specifies the sensor that has generated the interruption.

It specifies the socket that has generated the interruption, activating the corresponding flag position using the 'SENS_SOCKETX' definitions (X range [1-8])

See also:
SENS_SOCKET4, SENS_SOCKET3, SENS_SOCKET6, SENS_SOCKET5, SENS_SOCKET1, SENS_SOCKET2, SENS_SOCKET7, SENS_SOCKET8

Definition at line 121 of file WaspSensorEvent.h.

Referenced by loadInt().


The documentation for this class was generated from the following files:

Generated on Tue Jul 20 09:31:03 2010 for WaspmoteAPI by  doxygen 1.5.6