Added the battery indicator to the sensors API

This commit is contained in:
adamdunkels 2010-01-15 08:51:21 +00:00
parent 2f19892f74
commit e455ef3533
2 changed files with 12 additions and 8 deletions

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* @(#)$Id: sht11-sensor.c,v 1.1 2010/01/14 20:16:33 adamdunkels Exp $ * @(#)$Id: sht11-sensor.c,v 1.2 2010/01/15 08:51:21 adamdunkels Exp $
*/ */
#include <stdlib.h> #include <stdlib.h>
@ -59,7 +59,10 @@ value(int type)
/* Total Solar Radiation. */ /* Total Solar Radiation. */
case SHT11_SENSOR_HUMIDITY: case SHT11_SENSOR_HUMIDITY:
return sht11_humidity(); return sht11_humidity();
}
case SHT11_SENSOR_BATTERY_INDICATOR:
return sht11_sreg() & 0x40? 1: 0;
}
return 0; return 0;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -76,7 +79,7 @@ status(int type)
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
configure(int type, void *c) configure(int type, int c)
{ {
switch(type) { switch(type) {
case SENSORS_ACTIVE: case SENSORS_ACTIVE:

View file

@ -27,14 +27,14 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* *
* $Id: sht11-sensor.h,v 1.1 2010/01/14 20:16:33 adamdunkels Exp $ * $Id: sht11-sensor.h,v 1.2 2010/01/15 08:51:21 adamdunkels Exp $
* *
* ----------------------------------------------------------------- * -----------------------------------------------------------------
* *
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
* Created : 2010-01-08 * Created : 2010-01-08
* Updated : $Date: 2010/01/14 20:16:33 $ * Updated : $Date: 2010/01/15 08:51:21 $
* $Revision: 1.1 $ * $Revision: 1.2 $
*/ */
#ifndef __SHT11_SENSOR_H__ #ifndef __SHT11_SENSOR_H__
@ -44,8 +44,9 @@
extern const struct sensors_sensor sht11_sensor; extern const struct sensors_sensor sht11_sensor;
#define SHT11_SENSOR_TEMP 0 #define SHT11_SENSOR_TEMP 0
#define SHT11_SENSOR_HUMIDITY 1 #define SHT11_SENSOR_HUMIDITY 1
#define SHT11_SENSOR_BATTERY_INDICATOR 2
#endif /* __SHT11-SENSOR_H__ */ #endif /* __SHT11-SENSOR_H__ */