From a80c0d6dfd1a398d5908fc8e5ec309b380e8b1c6 Mon Sep 17 00:00:00 2001 From: bonswouar Date: Sat, 21 Dec 2024 00:51:10 +0100 Subject: [PATCH] gnuplot deprecations fixes re #40 --- .gitignore | 7 +++++++ src/battery-graph.in | 23 ++++++++--------------- src/graph-setup | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 9ae8de2..37bf85b 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/src/battery-graph.in b/src/battery-graph.in index 4cf84ba..96aa134 100644 --- a/src/battery-graph.in +++ b/src/battery-graph.in @@ -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 -u --date=12:00 +%s) - $(date --date=12:00 +%s) )) -from2000=$(( $from - $adjustment )) -to2000=$(( $to - $adjustment )) +fromAjusted=$(( $from - $adjustment )) +toAdjusted=$(( $to - $adjustment )) TMPFILENAME=`mktemp` @@ -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 @@ -211,7 +205,7 @@ ZERO_BIOS_ESTIMATE=`tail -n 1 $TMPFILENAME | awk '{ print $6 }'` echo "g(x) = xfull_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 \\" @@ -219,8 +213,7 @@ ZERO_BIOS_ESTIMATE=`tail -n 1 $TMPFILENAME | awk '{ print $6 }'` 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. diff --git a/src/graph-setup b/src/graph-setup index a33673a..37450d7 100644 --- a/src/graph-setup +++ b/src/graph-setup @@ -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