diff options
author | Landry Breuil <landry@cvs.openbsd.org> | 2018-12-10 13:35:55 +0000 |
---|---|---|
committer | Landry Breuil <landry@cvs.openbsd.org> | 2018-12-10 13:35:55 +0000 |
commit | 4177fb5112f3f803be4d251a9223094ac2d8978d (patch) | |
tree | 6e46e46d083710560c4f74d49bf77b36fae31acf /usr.sbin/sensorsd | |
parent | afa9c9390f3483b5b3a1443435f3c55d0b5aecae (diff) |
Add a velocity sensor type (displayed as m/s)
Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.
ok mpi@ kettenis@
Diffstat (limited to 'usr.sbin/sensorsd')
-rw-r--r-- | usr.sbin/sensorsd/sensorsd.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/sensorsd/sensorsd.c b/usr.sbin/sensorsd/sensorsd.c index fd6fb67728e..f122a7315a4 100644 --- a/usr.sbin/sensorsd/sensorsd.c +++ b/usr.sbin/sensorsd/sensorsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sensorsd.c,v 1.62 2018/10/22 16:20:09 deraadt Exp $ */ +/* $OpenBSD: sensorsd.c,v 1.63 2018/12/10 13:35:54 landry Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -692,7 +692,7 @@ print_sensor(enum sensor_type type, int64_t value) snprintf(fbuf, RFBUFSIZ, "%lld", value); break; case SENSOR_DISTANCE: - snprintf(fbuf, RFBUFSIZ, "%.2f mm", value / 1000.0); + snprintf(fbuf, RFBUFSIZ, "%.3f m", value / 1000000.0); break; case SENSOR_PRESSURE: snprintf(fbuf, RFBUFSIZ, "%.2f Pa", value / 1000.0); @@ -700,6 +700,9 @@ print_sensor(enum sensor_type type, int64_t value) case SENSOR_ACCEL: snprintf(fbuf, RFBUFSIZ, "%2.4f m/s^2", value / 1000000.0); break; + case SENSOR_VELOCITY: + snprintf(fbuf, RFBUFSIZ, "%4.3f m/s", value / 1000000.0); + break; default: snprintf(fbuf, RFBUFSIZ, "%lld ???", value); } @@ -813,13 +816,14 @@ get_val(char *buf, int upper, enum sensor_type type) case SENSOR_LUX: case SENSOR_FREQ: case SENSOR_ACCEL: + case SENSOR_DISTANCE: + case SENSOR_VELOCITY: rval = val * 1000 * 1000; break; case SENSOR_TIMEDELTA: rval = val * 1000 * 1000 * 1000; break; case SENSOR_HUMIDITY: - case SENSOR_DISTANCE: case SENSOR_PRESSURE: rval = val * 1000.0; break; |