incyclist-devices 1.4.2 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,15 +55,19 @@ class DaumClassicCyclingMode extends PowerMeterCyclingMode_1.default {
55
55
  let power = data.power || 0;
56
56
  let speed = data.speed || 0;
57
57
  let slope = (prevData.slope !== undefined ? prevData.slope : prevRequest.slope || 0);
58
- let distanceInternal = prevData.distanceInternal || 0;
58
+ let distanceBike = data.distanceInternal || 0;
59
+ let distancePrev = prevData.distanceInternal || 0;
60
+ let distanceInternal = distanceBike;
61
+ let ts = Date.now();
59
62
  if (!bikeData.pedalRpm || bikeData.isPedalling === false) {
60
63
  speed = 0;
61
64
  power = 0;
62
65
  }
63
- let ts = Date.now();
64
- let v = speed / 3.6;
65
- let duration = this.prevUpdateTS === 0 ? 0 : ((ts - this.prevUpdateTS) / 1000);
66
- distanceInternal += Math.round(v * duration);
66
+ if (distanceBike < distancePrev) {
67
+ let v = speed / 3.6;
68
+ let duration = this.prevUpdateTS === 0 ? 0 : ((ts - this.prevUpdateTS) / 1000);
69
+ distanceInternal = distancePrev + Math.round(v * duration);
70
+ }
67
71
  data.speed = parseFloat(speed.toFixed(1));
68
72
  data.power = Math.round(power);
69
73
  data.distanceInternal = Math.round(distanceInternal);
@@ -592,7 +592,6 @@ class Daum8i {
592
592
  .then((res) => {
593
593
  const resData = Uint8Array.from(res, x => x.charCodeAt(0));
594
594
  const cmd = (0, utils_1.esc2bin)(resData);
595
- console.log('~~~ cmd', cmd);
596
595
  return cmd;
597
596
  });
598
597
  }
@@ -764,7 +763,6 @@ class Daum8i {
764
763
  .then((res) => {
765
764
  const buffer = Buffer.from(res);
766
765
  let success = buffer.readInt16LE(0) === utils_1.ReservedCommands.PROGRAM_LIST_CONTINUE_PROGRAM;
767
- console.log('~~ Buffer', buffer, buffer.readInt16LE(2), buffer.readInt8(4));
768
766
  success = success && (buffer.readInt16LE(2) === 1);
769
767
  success = success && (buffer.readInt8(4) === 1);
770
768
  if (!success)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "dependencies": {
5
5
  "@serialport/parser-byte-length": "^9.0.1",
6
6
  "@serialport/parser-delimiter": "^9.0.1",