Skip to content

Commit

Permalink
gnuplot deprecations fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bonswouar committed Dec 22, 2024
1 parent 402605a commit 056b2ac
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
# Autotools
/autom4te.cache
/stamp-h1
CMakeFiles
data
CMakeCache.txt
cmake_install.cmake
install_manifest.txt
make_install.log*
src/cmake_install.cmake
Makefile
/config.status
/config.log
Expand Down
23 changes: 8 additions & 15 deletions src/battery-graph.in
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,11 @@ case "${from}:${duration}:${to}" in
exit 2
esac

# So far, $from and $to are 'seconds since 1st Jan 1970 00:00:00 UTC'.
# But gnuplot uses 'seconds since '1st Jan 2000 00:00:00 UTC'...

adjustment=$(( $(TZ=UTC date +%s --date='1/1/2000') - $(TZ=UTC date +%s --date='1/1/1970') ))

# Adjustment between UTC and local time
utc_adjust=$(( $( date -u --date=12:00 +%s) - $(date --date=12:00 +%s) ))

adjustment=$(( $adjustment - $utc_adjust ))
adjustment=$(( $(date --date=12:00 +%s) - $( date -u --date=12:00 +%s) ))

from2000=$(( $from - $adjustment ))
to2000=$(( $to - $adjustment ))
fromAjusted=$(( $from - $adjustment ))
toAdjusted=$(( $to - $adjustment ))

TMPFILENAME=`mktemp`

Expand Down Expand Up @@ -185,9 +178,10 @@ ZERO_BIOS_ESTIMATE=`tail -n 1 $TMPFILENAME | awk '{ print $6 }'`

(
if $text ; then
echo set terminal dumb ${COLUMNS:-$(tput cols)} ${LINES:-$(tput lines)}
echo set terminal dumb ${COLUMNS:-$(tput cols)} ${LINES:-$(tput lines)}
else
echo set terminal qt title \"${title}\"
fi

echo call \"${libdir}/graph-setup\"

# Fitting last discharge segment if SWITCH_RATE is true
Expand All @@ -211,16 +205,15 @@ ZERO_BIOS_ESTIMATE=`tail -n 1 $TMPFILENAME | awk '{ print $6 }'`
echo "g(x) = x<zero_time?(x>full_time?f(x):1/0):1/0"
fi

echo "set xrange [ $from2000 : $to2000 ] noreverse"
echo "set xrange [ $fromAdjusted : $toAdjusted ] noreverse"
echo plot "\"$TMPFILENAME\" using (\$1 - $adjustment):(\$3==2?\$2:1/0) smooth unique axis x1y1 title \"Plugged in\" with lines linecolor rgb \"blue\" linewidth 3, \
\"\" using (\$1 - $adjustment):(\$3==1?\$2:1/0) smooth unique axis x1y1 title \"Discharging\" with lines linecolor rgb \"red\" linewidth 3, \
\"\" using (\$1 - $adjustment):(\$3==0?\$2:1/0) smooth unique axis x1y1 title \"Unknown\" with lines linecolor rgb \"gray\" linewidth 3 \\"
if $SWITCH_RATE ; then
echo ", g(x -($TIME_LAST_DISCHARGE_BEGIN-$adjustment) ) title (B<0?sprintf(\"slope= (%.2f +/- %.2f) %/h\", B*3600, B_err*3600):\"\") lc rgb \"black\" lt 2 "
fi

) | gnuplot -persist ${geometry:+-geometry} $geometry ${title:+-title} "${title}" ; rm -f $TMPFILENAME

) | gnuplot -persist ${geometry:+-geometry} $geometry ; rm -f $TMPFILENAME

# TODO Have to decide if we want to clean up or leave the file for us to zoom in/out in the graph
# For now we will just go the clean way and delete everything again.
Expand Down
2 changes: 1 addition & 1 deletion src/graph-setup
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ set samples 100, 100
set isosamples 10, 10
set surface
set nocontour
set clabel '%8.3g'
set cntrlabel format '%8.3g'
set mapping cartesian
set nohidden3d
set cntrparam order 4
Expand Down

0 comments on commit 056b2ac

Please sign in to comment.