Changeset - 82502877a218
[Not reviewed]
default
0 2 0
mkroening@CL-ENS241-07.cedarville.edu - 12 years ago 2013-02-14 15:14:30
mkroening@CL-ENS241-07.cedarville.edu
Altitude added
2 files changed with 11 insertions and 0 deletions:
0 comments (0 inline, 0 general)
slave/slave/lib/sensors.c
Show inline comments
 
@@ -7,6 +7,7 @@
 
 
 
#include <inttypes.h>
 
#include <math.h>
 
#include <avr/io.h>
 
#include <avr/interrupt.h>
 
#include "../config.h"
 
@@ -46,6 +47,7 @@ int32_t b6;
 
uint32_t b7;
 
int32_t trueTemp;
 
int32_t pressure;
 
uint32_t altitude;
 
 
 
 
@@ -179,6 +181,9 @@ void sensors_readPressure()
 
	x1 = (x1 * 3038) >> 16;
 
	x2 = (-7357 * pressure) >> 16;
 
	pressure += (x1 + x2 + 3791) >> 4;				//This is the final value for our pressure
 
	
 
	altitude = 44330 * (1 - pow((pressure / 101325), (1 / 5.255)));
 
	//altitude = (float)44330 * (1 - pow(((float) pressure/101325), 0.190295));
 
}
 
 
void sensors_readHumid()
 
@@ -239,4 +244,9 @@ uint8_t sensors_getLight(void)		// Gets 
 
int8_t sensors_getBatt(void)		// Gets battery voltage from variable
 
{
 
	return batt;
 
}
 
 
uint32_t sensors_getAltitude(void)
 
{
 
	return altitude;
 
}
 
\ No newline at end of file
slave/slave/lib/sensors.h
Show inline comments
 
@@ -24,5 +24,6 @@ int32_t sensors_getPressure(void);	// Ge
 
uint16_t sensors_getHumid(void);	// Gets humidity from variable
 
uint8_t sensors_getLight(void);		// Gets lux from variable
 
int8_t sensors_getBatt(void);		// Gets battery voltage from variable
 
uint32_t sensors_getAltitude(void);		// Gets altitude from variable
 
 
#endif /* SENSORS_H_ */
 
\ No newline at end of file
0 comments (0 inline, 0 general)