incyclist-devices 2.3.31 → 2.3.32

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.
@@ -61,7 +61,8 @@ class AntFEAdapter extends adapter_1.default {
61
61
  this.promiseSendUpdate = fe.sendTrackResistance(update.slope);
62
62
  }
63
63
  if (update.targetPower !== undefined) {
64
- this.promiseSendUpdate = fe.sendTargetPower(update.targetPower);
64
+ const tp = update.targetPower > 0 ? update.targetPower : 0;
65
+ this.promiseSendUpdate = fe.sendTargetPower(tp);
65
66
  }
66
67
  yield this.promiseSendUpdate;
67
68
  delete this.promiseSendUpdate;
@@ -112,6 +113,7 @@ class AntFEAdapter extends adapter_1.default {
112
113
  power: adapterData.power,
113
114
  speed: adapterData.speed,
114
115
  cadence: adapterData.pedalRpm,
116
+ gearStr: adapterData.gearStr,
115
117
  timestamp: Date.now()
116
118
  });
117
119
  if (adapterData.distanceInternal !== undefined) {
@@ -246,7 +246,8 @@ class BleFmAdapter extends adapter_1.default {
246
246
  yield device.setSlope(update.slope);
247
247
  }
248
248
  if (update.targetPower !== undefined) {
249
- yield device.setTargetPower(update.targetPower);
249
+ const tp = update.targetPower > 0 ? update.targetPower : 0;
250
+ yield device.setTargetPower(tp);
250
251
  }
251
252
  }
252
253
  }
@@ -44,6 +44,7 @@ export default class SmartTrainerCyclingMode extends PowerBasedCyclingModeBase i
44
44
  protected checkSlopeWithSimulatedShifting(request: UpdateRequest, newRequest?: UpdateRequest): void;
45
45
  checkSlope(request: UpdateRequest, newRequest?: UpdateRequest): void;
46
46
  checkGearChange(request: UpdateRequest, newRequest?: UpdateRequest): void;
47
+ protected verifySimPower(): void;
47
48
  protected checkEmptyRequest(newRequest: UpdateRequest): void;
48
49
  protected getVirtualShiftMode(): VirtshiftMode;
49
50
  updateData(bikeData: IncyclistBikeData, log?: boolean): IncyclistBikeData;
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  const types_1 = require("./types");
40
40
  const power_base_1 = __importDefault(require("./power-base"));
41
41
  const calculations_1 = __importStar(require("../utils/calculations"));
42
+ const MIN_POWER = 25;
42
43
  class SmartTrainerCyclingMode extends power_base_1.default {
43
44
  constructor(adapter, props) {
44
45
  super(adapter, props);
@@ -111,7 +112,8 @@ class SmartTrainerCyclingMode extends power_base_1.default {
111
112
  checkSlopeWithSimulatedShifting(request, newRequest = {}) {
112
113
  var _a, _b, _c, _d;
113
114
  if (this.gear === undefined) {
114
- return this.checkSlopeNoShiftig(request, newRequest);
115
+ this.checkSlopeNoShiftig(request, newRequest);
116
+ return;
115
117
  }
116
118
  if (request.slope !== undefined) {
117
119
  const prev = (_a = this.data.slope) !== null && _a !== void 0 ? _a : 0;
@@ -126,22 +128,14 @@ class SmartTrainerCyclingMode extends power_base_1.default {
126
128
  }
127
129
  catch (_e) {
128
130
  }
129
- if (this.data.slope === prev) {
130
- newRequest.targetPower = this.simPower;
131
- return;
132
- }
133
- else {
131
+ if (this.data.slope !== prev) {
134
132
  const virtualSpeed = (0, calculations_1.calculateVirtualSpeed)(this.data.pedalRpm, this.gearRatios[this.gear - 1]);
135
133
  const m = (_c = (_b = this.adapter) === null || _b === void 0 ? void 0 : _b.getWeight()) !== null && _c !== void 0 ? _c : 85;
136
134
  this.simPower = calculations_1.default.calculatePower(m, virtualSpeed, (_d = this.simSlope) !== null && _d !== void 0 ? _d : 0);
137
- newRequest.targetPower = this.simPower;
135
+ this.verifySimPower();
138
136
  }
139
- if (this.simPower < 0)
140
- this.simPower = 0;
141
- }
142
- else {
143
- newRequest.targetPower = this.simPower;
144
137
  }
138
+ newRequest.targetPower = this.simPower;
145
139
  }
146
140
  checkSlope(request, newRequest = {}) {
147
141
  const virtshiftMode = this.getVirtualShiftMode();
@@ -190,6 +184,7 @@ class SmartTrainerCyclingMode extends power_base_1.default {
190
184
  const virtualSpeed = (0, calculations_1.calculateVirtualSpeed)(this.data.pedalRpm, this.gearRatios[this.gear - 1]);
191
185
  const m = (_b = (_a = this.adapter) === null || _a === void 0 ? void 0 : _a.getWeight()) !== null && _b !== void 0 ? _b : 85;
192
186
  this.simPower = calculations_1.default.calculatePower(m, virtualSpeed, (_d = (_c = this.simSlope) !== null && _c !== void 0 ? _c : this.data.slope) !== null && _d !== void 0 ? _d : 0);
187
+ this.verifySimPower();
193
188
  }
194
189
  break;
195
190
  case 'Adapter':
@@ -198,6 +193,14 @@ class SmartTrainerCyclingMode extends power_base_1.default {
198
193
  break;
199
194
  }
200
195
  }
196
+ verifySimPower() {
197
+ if (this.simPower < 0) {
198
+ this.simPower = 0;
199
+ }
200
+ if (this.data.pedalRpm > 0 && this.simPower < MIN_POWER) {
201
+ this.simPower = MIN_POWER;
202
+ }
203
+ }
201
204
  checkEmptyRequest(newRequest) {
202
205
  if (Object.keys(newRequest).length === 0) {
203
206
  if (this.prevRequest) {
@@ -242,6 +245,7 @@ class SmartTrainerCyclingMode extends power_base_1.default {
242
245
  virtualSpeed = (0, calculations_1.calculateVirtualSpeed)(data.pedalRpm, this.gearRatios[this.gear - 1]);
243
246
  const m = (_b = (_a = this.adapter) === null || _a === void 0 ? void 0 : _a.getWeight()) !== null && _b !== void 0 ? _b : 85;
244
247
  this.simPower = calculations_1.default.calculatePower(m, virtualSpeed, (_d = (_c = this.simSlope) !== null && _c !== void 0 ? _c : data.slope) !== null && _d !== void 0 ? _d : 0);
248
+ this.verifySimPower();
245
249
  }
246
250
  }
247
251
  return data;
@@ -279,10 +283,10 @@ class SmartTrainerCyclingMode extends power_base_1.default {
279
283
  const mode = this.getVirtualShiftMode();
280
284
  if (mode === "Disabled")
281
285
  return undefined;
282
- if (this.gear === undefined || this.gear === null)
286
+ if (mode === 'Simulated' && (this.gear === undefined || this.gear === null))
283
287
  return '';
284
288
  if (mode === "SlopeDelta")
285
- return this.gear > 0 ? `+${this.gear}` : `${this.gear}`;
289
+ return this.gearDelta > 0 ? `+${this.gearDelta}` : `${this.gearDelta}`;
286
290
  return this.gear.toString();
287
291
  }
288
292
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "2.3.31",
3
+ "version": "2.3.32",
4
4
  "dependencies": {
5
5
  "@serialport/bindings-interface": "^1.2.2",
6
6
  "@serialport/parser-byte-length": "^9.0.1",