summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-12-26 21:25:16 +0100
committerDaniel Friesel <derf@finalrewind.org>2016-12-26 21:25:16 +0100
commitf3ddfd65a21e56647264aba819c054fa2830995a (patch)
tree64dc1eba10a3ad16e8f127ec62106b13ba348bcb
parent05b06034a8ec920e6f01632e0688d249f330aaf5 (diff)
lm75 example: Add support for LM75BD (with 11-bit resolution)
-rwxr-xr-xcommandline/examples/lm759
1 files changed, 2 insertions, 7 deletions
diff --git a/commandline/examples/lm75 b/commandline/examples/lm75
index 2dfd956..81fd497 100755
--- a/commandline/examples/lm75
+++ b/commandline/examples/lm75
@@ -5,16 +5,11 @@ cmd=$1
arg=$2
function read_temp {
- typeset buf num
+ typeset buf
buf=($(vusb-i2cget $addr 2 $1))
- num=$buf[1]
- if (( buf[2] > 127 )); then
- num="${num}.5"
- fi
-
- echo $num
+ printf "%.2f\n" $(( buf[1] + (buf[2] / 256.) ))
}
function set_temp {