diff options
author | Yojiro Uo <yuo@cvs.openbsd.org> | 2010-04-15 09:40:47 +0000 |
---|---|---|
committer | Yojiro Uo <yuo@cvs.openbsd.org> | 2010-04-15 09:40:47 +0000 |
commit | 236bc00af72440eff6bb011c46f762ba0b328804 (patch) | |
tree | 9b3f5932ecc1e4929555301508648cdb20a8f7c4 /sys | |
parent | b6e74e9da5f39c93529339997a12966381c39109 (diff) |
use SENSOR_HUMIDITY instead of SENSOR_PERCENT.
and add LED blink routine.
ok jsg@, deraadt@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/usb/utrh.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/sys/dev/usb/utrh.c b/sys/dev/usb/utrh.c index b19761e1282..ef7f4e0c0e0 100644 --- a/sys/dev/usb/utrh.c +++ b/sys/dev/usb/utrh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utrh.c,v 1.3 2010/02/18 23:34:05 deraadt Exp $ */ +/* $OpenBSD: utrh.c,v 1.4 2010/04/15 09:40:46 yuo Exp $ */ /* * Copyright (c) 2009 Yojiro UO <yuo@nui.org> @@ -154,9 +154,9 @@ utrh_attach(struct device *parent, struct device *self, void *aux) sc->sc_sensor[UTRH_TEMP].type = SENSOR_TEMP; sc->sc_sensor[UTRH_TEMP].flags = SENSOR_FINVALID; - strlcpy(sc->sc_sensor[UTRH_HUMIDITY].desc, "humidity", + strlcpy(sc->sc_sensor[UTRH_HUMIDITY].desc, "RH", sizeof(sc->sc_sensor[UTRH_HUMIDITY].desc)); - sc->sc_sensor[UTRH_HUMIDITY].type = SENSOR_PERCENT; + sc->sc_sensor[UTRH_HUMIDITY].type = SENSOR_HUMIDITY; sc->sc_sensor[UTRH_HUMIDITY].flags = SENSOR_FINVALID; sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[UTRH_TEMP]); @@ -238,6 +238,15 @@ utrh_refresh(void *arg) struct utrh_softc *sc = arg; unsigned int temp_tick, humidity_tick; int temp, rh; + uint8_t ledbuf[7]; + + /* turn on LED 1*/ + bzero(ledbuf, sizeof(ledbuf)); + ledbuf[0] = 0x3; + ledbuf[1] = 0x1; + if (uhidev_set_report(&sc->sc_hdev, UHID_FEATURE_REPORT, + ledbuf, sc->sc_flen)) + printf("LED request failed\n"); /* issue query */ uint8_t cmdbuf[] = {0x31, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00}; @@ -248,6 +257,12 @@ utrh_refresh(void *arg) /* wait till sensor data are updated, 1s will be enough */ tsleep(&sc->sc_sensortask, 0, "utrh", (1*hz)); + /* turn off LED 1 */ + ledbuf[1] = 0x0; + if (uhidev_set_report(&sc->sc_hdev, UHID_FEATURE_REPORT, + ledbuf, sc->sc_flen)) + printf("LED request failed\n"); + temp_tick = (sc->sc_ibuf[2] * 256 + sc->sc_ibuf[3]) & 0x3fff; humidity_tick = (sc->sc_ibuf[0] * 256 + sc->sc_ibuf[1]) & 0x0fff; |