summaryrefslogtreecommitdiff
path: root/src/driver/hdc1080.cc
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-12-08 18:58:17 +0100
committerDaniel Friesel <derf@finalrewind.org>2021-12-08 18:58:17 +0100
commita2316cb4cf92ba507f07b654f153682ed587605c (patch)
tree1c01c9f627ab5196c531ec6e71d067d6bb1cc1cf /src/driver/hdc1080.cc
parent7baef4fb7bbbce9d802099548aebc8a3450c6481 (diff)
hdc1080: add explicit measure() function
Diffstat (limited to 'src/driver/hdc1080.cc')
-rw-r--r--src/driver/hdc1080.cc14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/driver/hdc1080.cc b/src/driver/hdc1080.cc
index af828fd..2ac983d 100644
--- a/src/driver/hdc1080.cc
+++ b/src/driver/hdc1080.cc
@@ -11,14 +11,15 @@
#include "driver/soft_i2c.h"
#endif
-float HDC1080::getTemp()
+void HDC1080::measure()
{
txbuf[0] = 0x00;
-
i2c.xmit(address, 1, txbuf, 0, rxbuf);
+}
- arch.delay_ms(10);
-
+float HDC1080::getTemp()
+{
+ txbuf[0] = 0x00;
i2c.xmit(address, 0, txbuf, 2, rxbuf);
return (((unsigned int)rxbuf[0] << 8) | rxbuf[1]) * .00251770019531250000 - 40.;
@@ -27,11 +28,6 @@ float HDC1080::getTemp()
float HDC1080::getRH()
{
txbuf[0] = 0x01;
-
- i2c.xmit(address, 1, txbuf, 0, rxbuf);
-
- arch.delay_ms(10);
-
i2c.xmit(address, 0, txbuf, 2, rxbuf);
return (((unsigned int)rxbuf[0] << 8) | rxbuf[1]) * .00152587890625000000;