Meaningful units for msp temp&batt sensors
This commit is contained in:
parent
127a3d03ad
commit
73fc5f6ae7
2 changed files with 15 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -50,6 +50,11 @@
|
|||
#include <stdio.h>
|
||||
|
||||
|
||||
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("<h1>Current readings</h1>\n"
|
||||
"Battery: %u<br>"
|
||||
"Temperature: %u° C",
|
||||
get_battery(), get_temp());
|
||||
"Battery: %ld.%03d V<br>"
|
||||
"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') {
|
||||
|
|
Loading…
Reference in a new issue