aboutsummaryrefslogtreecommitdiffstats
path: root/src/hih61xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hih61xx.c')
-rw-r--r--src/hih61xx.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/hih61xx.c b/src/hih61xx.c
index 2a61d3b..732b697 100644
--- a/src/hih61xx.c
+++ b/src/hih61xx.c
@@ -7,15 +7,16 @@
#include "hih61xx.h"
+#include "deftypes.h"
-extern int file;
+extern uint16 devicef;
extern void bus_err(int ern);
extern void print_help(void);
unsigned char buf[5];
-
+
-void hih61xx_print_all(void)
+void hih61xx_print_all(void)
{
printf(
"00: Relative Humidity [%%] (reg: 0x00)\n"
@@ -27,34 +28,30 @@ void hih61xx_print_all(void)
void hih61xx_conf_set(const char *opts) {}
-void hih61xx_get_data(void)
+void hih61xx_get_data(void) //# Get measurement data from device
{
buf[0] = 0x00;
- if(write(file, buf, 1) != 1) //Start measure
- {
+ if(write(devicef, buf, 1) != 1){ //# Start the measurement
bus_err(errno);
}
- usleep(60*1000); // Wait 60ms for measurement
+ usleep(60*1000); //# Wait 60ms for measurement
- if(read(file, buf, 4) != 4) //Read the data
- {
+ if(read(devicef, buf, 4) != 4){ //# Read the data
bus_err(errno);
}
}
-unsigned char hih61xx_read_status(void)
-{
- return ((buf[0] & 0xc0) >> 6);
+unsigned char hih61xx_read_status(void){ //# Get device status
+ return ((buf[0] & 0xc0) >> 6); //# He ???
}
-float hih61xx_read_humidity(float offset)
-{
+float hih61xx_calc_humidity(float offset){ //# Measure
unsigned int raw = 0;
float humidity;
@@ -100,7 +97,7 @@ void hih61xx_read_all(const char *opts)
if(opts != NULL)
{
char *ptr;
- printf("00:%f\n", hih61xx_read_humidity(strtof(opts, &ptr)));
+ printf("00:%f\n", hih61xx_calc_humidity(strtof(opts, &ptr)));
ptr++; // One (,) character allowed for delimiter
@@ -108,7 +105,7 @@ void hih61xx_read_all(const char *opts)
}
else
{
- printf("00:%f\n", hih61xx_read_humidity(0.0));
+ printf("00:%f\n", hih61xx_calc_humidity(0.0));
printf("01:%f\n", hih61xx_read_temp(0.0));
}
@@ -130,7 +127,7 @@ void hih61xx_read_one(const char *opts)
switch (id)
{
case 0x00:
- printf("00:%f\n", hih61xx_read_humidity(strtof(ptr, NULL)));
+ printf("00:%f\n", hih61xx_calc_humidity(strtof(ptr, NULL)));
break;
case 0x01:
printf("01:%f\n", hih61xx_read_temp(strtof(ptr, NULL)));