summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-03-08 15:35:48 +0100
committerDaniel Friesel <derf@finalrewind.org>2020-03-08 15:35:48 +0100
commit098fd9b55d055204b811317f2e117232637a48ab (patch)
tree1758a617818eb306cb90c1b4938e64cf917b1eae
parentf6e7d4fd15bc1adb538d4b4f053a7ac43f8bb2fe (diff)
HDC1080: Add heater toggle
-rw-r--r--include/driver/hdc1080.h1
-rw-r--r--src/driver/hdc1080.cc14
2 files changed, 14 insertions, 1 deletions
diff --git a/include/driver/hdc1080.h b/include/driver/hdc1080.h
index f6f278c..6a510a0 100644
--- a/include/driver/hdc1080.h
+++ b/include/driver/hdc1080.h
@@ -15,6 +15,7 @@ class HDC1080 {
float getRH();
unsigned int getManufacturerID();
void init();
+ void heater(bool on);
};
extern HDC1080 hdc1080;
diff --git a/src/driver/hdc1080.cc b/src/driver/hdc1080.cc
index 8da2ba7..26c97ef 100644
--- a/src/driver/hdc1080.cc
+++ b/src/driver/hdc1080.cc
@@ -39,10 +39,22 @@ unsigned int HDC1080::getManufacturerID()
return (unsigned int)rxbuf[0] << 8 | rxbuf[1];
}
+void HDC1080::heater(bool on)
+{
+ txbuf[0] = 0x02;
+ i2c.xmit(address, 1, txbuf, 2, rxbuf);
+ if (on) {
+ txbuf[1] = rxbuf[0] | (1<<5);
+ } else {
+ txbuf[1] = rxbuf[0] & ~(1<<5);
+ }
+ i2c.xmit(address, 2, txbuf, 0, rxbuf);
+}
+
void HDC1080::init()
{
txbuf[0] = 0x02;
- txbuf[1] = 0x08;
+ txbuf[1] = 0x00;
txbuf[2] = 0x00;
i2c.xmit(address, 3, txbuf, 0, rxbuf);
arch.delay_ms(15);