Merge branch 'master' of git@github.com:enricmcalvo/contiki-2.x

This commit is contained in:
Enric M. Calvo 2011-03-07 16:35:12 +01:00
commit 9c2f335e57
3 changed files with 42 additions and 6 deletions

View file

@ -3,7 +3,7 @@ TARGET=z1
endif
CONTIKI_PROJECT = test-phidgets blink test-adxl345 tmp102-test test-battery test-sht11 #test-potent
CONTIKI_SOURCEFILES += cc2420-arch.c sensors.c sht11.c
CONTIKI_SOURCEFILES += cc2420-arch.c sensors.c sht11.c potentiometer-sensor.c
PROJECT_SOURCEFILES = i2cmaster.c tmp102.c adxl345.c battery-sensor.c sky-sensors.c #potentiometer-sensor.c
APPS=serial-shell

35
examples/z1/test-battery_mv.c Executable file
View file

@ -0,0 +1,35 @@
#include "contiki.h"
#include "dev/battery-sensor.h"
#include <stdio.h> /* For printf() */
float floor(float x){
if(x>=0.0f){ return (float) ((int)x);}
else {return(float)((int)x-1);}
}
/*---------------------------------------------------------------------------*/
PROCESS(aplicacio, "Aplicacio de prova");
AUTOSTART_PROCESSES(&aplicacio);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(aplicacio, ev, data)
{
PROCESS_BEGIN();
SENSORS_ACTIVATE(battery_sensor);
while (1)
{
uint16_t bateria = battery_sensor.value(0);
float mv = (bateria*2.500*2)/4096;
printf("Battery: %i (%ld.%03d mV)\n", bateria, (long) mv, (unsigned) ((mv-floor(mv))*1000));
}
SENSORS_DEACTIVATE(battery_sensor);
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View file

@ -5,7 +5,7 @@
/*---------------------------------------------------------------------------*/
PROCESS(aplicacio, "Aplicacio de prova");
PROCESS(aplicacio, "Testing Potentiometer");
AUTOSTART_PROCESSES(&aplicacio);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(aplicacio, ev, data)
@ -13,13 +13,14 @@ PROCESS_THREAD(aplicacio, ev, data)
PROCESS_BEGIN();
SENSORS_ACTIVATE(potentiometer_sensor);
// INSERT LINE HERE TO ENABLE POTENTIOMETER
while (1)
{
uint16_t v = potentiometer_sensor.value(0);
uint16_t value
//INSERT LINE HERE TO READ POTENTIOMETER VALUE
printf("Potentiometer Value: %i\n", v);
}