should be working now

This commit is contained in:
2024-10-20 09:01:31 +02:00
parent 1ae30d5d91
commit 0eefa1772a
4 changed files with 32 additions and 31 deletions

View File

@@ -1,5 +1,5 @@
#!/bin/sh
# -*- sh -*-
#!/bin/bash
# -*- bash -*-
: << =cut
@@ -32,7 +32,6 @@ if [ "$1" = "autoconf" ]; then
fi
if [ "$1" = "config" ]; then
echo 'graph_title Power'
echo 'graph_args --base 1 -l 0 '
echo 'graph_scale no'
@@ -45,22 +44,26 @@ if [ "$1" = "config" ]; then
exit 0
fi
ROUNDS=5
ROUNDS=3
VOLTAGE=0
CURRENT=0
POWER=0
for i in $(seq ${ROUNDS}); do
RESULT=$(/usr/bin/ina219)
#ROW="12204mV 184.3mA"
ROW=$(/usr/bin/ina219)
ENTRY=( $ROW )
VOLTAGE_RAW=${ENTRY[0]%mV}
CURRENT_RAW=${ENTRY[1]%mA}
#echo "Voltage: ${VOLTAGE_RAW}"
#echo "Current: ${CURRENT_RAW}"
VOLTAGE_RAW=$(echo $RESULT | /bin/sed 's/\([0-9]\+\)mV \+\([0-9\.]\+\)mA/\1/')
VOLTAGE=$(echo "scale=3; $VOLTAGE+$VOLTAGE_RAW" | /usr/bin/bc)
CURRENT_RAW=$(echo $RESULT | /bin/sed 's/\([0-9]\+\)mV \+\([0-9\.]\+\)mA/\2/')
CURRENT=$(echo "scale=3; $CURRENT+$CURRENT_RAW" | /usr/bin/bc)
done
#exit 1
VOLTAGE=$(echo "scale=3; $VOLTAGE/$ROUNDS" | /usr/bin/bc)
CURRENT=$(echo "scale=3; $CURRENT/$ROUNDS" | /usr/bin/bc)