From 73fc5f6ae7e04ff38cc670d544978843cdd9bb9f Mon Sep 17 00:00:00 2001 From: "Enric M. Calvo" Date: Tue, 8 Mar 2011 10:05:47 +0100 Subject: [PATCH] Meaningful units for msp temp&batt sensors --- examples/ipv6/z1-websense/Makefile | 3 +++ examples/ipv6/z1-websense/z1-websense.c | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/examples/ipv6/z1-websense/Makefile b/examples/ipv6/z1-websense/Makefile index cefb94f5d..4809f8dfd 100644 --- a/examples/ipv6/z1-websense/Makefile +++ b/examples/ipv6/z1-websense/Makefile @@ -22,3 +22,6 @@ connect-router: $(CONTIKI)/tools/tunslip6 connect-router-cooja: $(CONTIKI)/tools/tunslip6 sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 aaaa::1/64 + +CUSTOM_RULE_LINK=1 +%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@ -lm diff --git a/examples/ipv6/z1-websense/z1-websense.c b/examples/ipv6/z1-websense/z1-websense.c index 9220d43b9..6cfab692d 100644 --- a/examples/ipv6/z1-websense/z1-websense.c +++ b/examples/ipv6/z1-websense/z1-websense.c @@ -50,6 +50,11 @@ #include +float floor(float x){ + if(x>=0.0f) return (float) ((int)x); + else return (float) ((int)x-1); +} + PROCESS(web_sense_process, "Sense Web Demo"); AUTOSTART_PROCESSES(&web_sense_process); @@ -110,10 +115,14 @@ PT_THREAD(send_values(struct httpd_state *s)) /* Default page: show latest sensor values as text (does not require Internet connection to Google for charts). */ blen = 0; + float voltage = (get_battery()*2.500*2)/4096; + float temperaturev = (get_temp()*2.500)/4096; + float temperature = (temperaturev-0.986)*282; ADD("

Current readings

\n" - "Battery: %u
" - "Temperature: %u° C", - get_battery(), get_temp()); + "Battery: %ld.%03d V
" + "Temperature: %ld.%03d ° C", + (long) voltage, (unsigned) ((voltage-floor(voltage))*1000), + (long) temperature, (unsigned) ((temperature-floor(temperature))*1000)); SEND_STRING(&s->sout, buf); } else if(s->filename[1] == '0') {