From 07d921b08e4be475e737f34f5a334f7526128d8a Mon Sep 17 00:00:00 2001 From: "Enric M. Calvo" Date: Fri, 4 Mar 2011 15:54:21 +0100 Subject: [PATCH 1/2] Modified Makefile and test-potent.c for ICTPWSN --- examples/z1/Makefile | 2 +- examples/z1/test-potent.c | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/z1/Makefile b/examples/z1/Makefile index 27edd50ed..941441db1 100644 --- a/examples/z1/Makefile +++ b/examples/z1/Makefile @@ -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 diff --git a/examples/z1/test-potent.c b/examples/z1/test-potent.c index 5bf58abbe..9c0263c35 100644 --- a/examples/z1/test-potent.c +++ b/examples/z1/test-potent.c @@ -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); } From c5548c5ca925c14df433c0deb0e11719084320ea Mon Sep 17 00:00:00 2001 From: "Enric M. Calvo" Date: Fri, 4 Mar 2011 15:58:09 +0100 Subject: [PATCH 2/2] added mV test-battery file --- examples/z1/test-battery_mv.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 examples/z1/test-battery_mv.c diff --git a/examples/z1/test-battery_mv.c b/examples/z1/test-battery_mv.c new file mode 100755 index 000000000..555932e47 --- /dev/null +++ b/examples/z1/test-battery_mv.c @@ -0,0 +1,35 @@ +#include "contiki.h" +#include "dev/battery-sensor.h" +#include /* 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(); +} +/*---------------------------------------------------------------------------*/ +