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
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!--
  Test/Development/Documentation page; install as plugin to test
-->

<style>
.indicator > .label {
  font-size: 150%;
  line-height: 200%;
  margin: 10px;
  padding: 10px;
  display: block;
  border-radius: 50px;
}
.metric.number .label {
  min-width: 8em;
}
.metric.number {
  display: block;
  float: none;
  text-align: center;
}
</style>

<div class="panel panel-primary">
  <div class="panel-heading">Regen Brake Monitor</div>
  <div class="panel-body">

    <div class="receiver" id="regenmon-receiver">

      <div class="row">
        <div class="col-sm-6">
          <div class="metric chart" data-metric="v.p.acceleration" style="height:300px">
            <div class="chart-box gaugechart" id="accel-gauge"/>
          </div>
          <div class="metric number" data-metric="v.p.acceleration" data-prec="2">
            <span class="label">Acceleration:</span>
            <span class="value">?</span>
            <span class="unit">m/s²</span>
          </div>
          <div class="metric number" data-metric="v.p.speed" data-prec="1">
            <span class="label">Speed:</span>
            <span class="value">?</span>
            <span class="unit">kph</span>
          </div>
          <div class="metric number" data-metric="v.b.power" data-prec="1">
            <span class="label">Battery power:</span>
            <span class="value">?</span>
            <span class="unit">kW</span>
          </div>
          <br class="clearfix"/>
        </div>
        <div class="col-sm-6">
          <div class="indicator" data-metric="v.e.regenbrake">
            <span class="label label-default">REGEN</span>
          </div>
          <div class="indicator" data-metric="v.e.footbrake">
            <span class="label label-default">FOOT</span>
          </div>
        </div>
      </div>

    </div>

  </div>
</div>

<script>
(function(){

  /* Init acceleration gauge: */
  $("#accel-gauge").chart({
    chart: {
      type: 'gauge',
      spacing: [0, 0, 0, 0],
      margin: [0, 0, 0, 0],
      animation: { duration: 250, easing: 'easeOutExpo' },
    },
    title: { text: "Acceleration", verticalAlign: "middle", y: 75 },
    credits: { enabled: false },
    tooltip: { enabled: false },
    plotOptions: {
      gauge: { dataLabels: { enabled: false }, overshoot: 5 }
    },
    pane: [{
      startAngle: -120, endAngle: 120, size: '100%', center: ['50%', '60%']
    }],
    yAxis: [{
      title: { text: 'm/s²' },
      className: 'accel',
      reversed: false,
      min: -2, max: 2,
      minorTickInterval: 0.1, minorTickLength: 5, minorTickPosition: 'inside',
      tickInterval: 0.5, tickPosition: 'inside', tickLength: 13,
      labels: { step: 1, distance: -28, x: 0, y: 5, zIndex: 2 },
    }],
    series: [{
      name: 'Acceleration', data: [0],
      className: 'accel',
      animation: { duration: 0 },
      pivot: { radius: '10' },
      dial: { radius: '88%', topWidth: 1, baseLength: '20%', baseWidth: 10, rearLength: '20%' },
    }],
    /* Update method: */
    onUpdate: function(update) {
      // Create gauge data set from metric:
      var data = [ metrics["v.p.acceleration"] ];
      // Update chart:
      this.series[0].setData(data);
    },
  });

  /* Init indicators: */
  $('#regenmon-receiver').on('msg:metrics', function(e, update) {
    $(this).find('.indicator').each(function() {
      var $el = $(this), metric = $el.data("metric"), val = update[metric];
      if (val == null)
        return;
      else if (val != 0)
        $el.children().removeClass('label-default').addClass('label-danger');
      else if (val == 0)
        $el.children().removeClass('label-danger').addClass('label-default');
    });
  });

})();
</script>