Regen Brake Monitor

../../../_images/regenmon.png

This plugin defines a page including an acceleration level gauge chart, number metrics for the acceleration, speed and battery power and two large indicators for the regen brake light and the brake pedal state.

It’s useful to fine tune the regen brake settings, as you can monitor the actual deceleration levels while driving and check the smoothing level.

Install: add the source as a page plugin, e.g. /dev/regenmon.

regenmon.htm (hint: right click, save as)

  1<!--
  2  Test/Development/Documentation page; install as plugin to test
  3-->
  4
  5<style>
  6.indicator > .label {
  7  font-size: 150%;
  8  line-height: 200%;
  9  margin: 10px;
 10  padding: 10px;
 11  display: block;
 12  border-radius: 50px;
 13}
 14.metric.number .label {
 15  min-width: 8em;
 16}
 17.metric.number {
 18  display: block;
 19  float: none;
 20  text-align: center;
 21}
 22</style>
 23
 24<div class="panel panel-primary">
 25  <div class="panel-heading">Regen Brake Monitor</div>
 26  <div class="panel-body">
 27
 28    <div class="receiver" id="regenmon-receiver">
 29
 30      <div class="row">
 31        <div class="col-sm-6">
 32          <div class="metric chart" data-metric="v.p.acceleration" style="height:300px">
 33            <div class="chart-box gaugechart" id="accel-gauge"/>
 34          </div>
 35          <div class="metric number" data-metric="v.p.acceleration" data-prec="2">
 36            <span class="label">Acceleration:</span>
 37            <span class="value">?</span>
 38            <span class="unit">m/s²</span>
 39          </div>
 40          <div class="metric number" data-metric="v.p.speed" data-prec="1">
 41            <span class="label">Speed:</span>
 42            <span class="value">?</span>
 43            <span class="unit">kph</span>
 44          </div>
 45          <div class="metric number" data-metric="v.b.power" data-prec="1">
 46            <span class="label">Battery power:</span>
 47            <span class="value">?</span>
 48            <span class="unit">kW</span>
 49          </div>
 50          <br class="clearfix"/>
 51        </div>
 52        <div class="col-sm-6">
 53          <div class="indicator" data-metric="v.e.regenbrake">
 54            <span class="label label-default">REGEN</span>
 55          </div>
 56          <div class="indicator" data-metric="v.e.footbrake">
 57            <span class="label label-default">FOOT</span>
 58          </div>
 59        </div>
 60      </div>
 61
 62    </div>
 63
 64  </div>
 65</div>
 66
 67<script>
 68(function(){
 69
 70  /* Init acceleration gauge: */
 71  $("#accel-gauge").chart({
 72    chart: {
 73      type: 'gauge',
 74      spacing: [0, 0, 0, 0],
 75      margin: [0, 0, 0, 0],
 76      animation: { duration: 250, easing: 'easeOutExpo' },
 77    },
 78    title: { text: "Acceleration", verticalAlign: "middle", y: 75 },
 79    credits: { enabled: false },
 80    tooltip: { enabled: false },
 81    plotOptions: {
 82      gauge: { dataLabels: { enabled: false }, overshoot: 5 }
 83    },
 84    pane: [{
 85      startAngle: -120, endAngle: 120, size: '100%', center: ['50%', '60%']
 86    }],
 87    yAxis: [{
 88      title: { text: 'm/s²' },
 89      className: 'accel',
 90      reversed: false,
 91      min: -2, max: 2,
 92      minorTickInterval: 0.1, minorTickLength: 5, minorTickPosition: 'inside',
 93      tickInterval: 0.5, tickPosition: 'inside', tickLength: 13,
 94      labels: { step: 1, distance: -28, x: 0, y: 5, zIndex: 2 },
 95    }],
 96    series: [{
 97      name: 'Acceleration', data: [0],
 98      className: 'accel',
 99      animation: { duration: 0 },
100      pivot: { radius: '10' },
101      dial: { radius: '88%', topWidth: 1, baseLength: '20%', baseWidth: 10, rearLength: '20%' },
102    }],
103    /* Update method: */
104    onUpdate: function(update) {
105      // Create gauge data set from metric:
106      var data = [ metrics["v.p.acceleration"] ];
107      // Update chart:
108      this.series[0].setData(data);
109    },
110  });
111
112  /* Init indicators: */
113  $('#regenmon-receiver').on('msg:metrics', function(e, update) {
114    $(this).find('.indicator').each(function() {
115      var $el = $(this), metric = $el.data("metric"), val = update[metric];
116      if (val == null)
117        return;
118      else if (val != 0)
119        $el.children().removeClass('label-default').addClass('label-danger');
120      else if (val == 0)
121        $el.children().removeClass('label-danger').addClass('label-default');
122    });
123  });
124
125})();
126</script>