Skip to content

Commit

Permalink
Dynamically add/remove current_now negative sign
Browse files Browse the repository at this point in the history
  • Loading branch information
VR-25 committed Aug 3, 2021
1 parent 71f54ae commit 6a535fe
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions acc/batt-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ batt_info() {
dtr_conv_factor ${currNow#-} ${ampFactor-}
currNow=$(calc ${currNow:-0} / $factor)

# strip negative sign if charging
case $currNow in
-*) grep -Eiq 'dis|not' $batt/status || currNow=${currNow#-}
;;
esac
# add/remove negative sign
if grep -Eiq 'dis|not' $batt/status; then
currNow=-${currNow#-}
else
currNow=${currNow#-}
fi

# parse VOLTAGE_NOW & convert to Volts
voltNow=$(echo "$info" | sed -n "s/^VOLTAGE_NOW=//p")
Expand Down

0 comments on commit 6a535fe

Please sign in to comment.