Skip to content

Commit

Permalink
Removed 'reversed' from intToLittleEndianArray (#10)
Browse files Browse the repository at this point in the history
* Removed 'reversed' from intToLittleEndianArray in order to send correct values to indoor trainer, it was not vorking correctly with the reversed array

* Fixed 'reversed' and wrote test for target power case
  • Loading branch information
indoorcyclingdev authored Mar 17, 2024
1 parent 0117d46 commit b6963fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class MachineControlPoint {
List<int> writeData = [opCode.value];
if (parameter != null) {
writeData.addAll(
Utils.intToLittleEndianArray(parameter!.value, parameter!.size));
Utils.intToLittleEndianArray(parameter!.value, parameter!.size).reversed);
}
return writeData;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,12 @@ void main() {
expect(controlPoint.opCode.type, MachineControlPointOpcodeType.stopOrPause);
expect(controlPoint.getWriteData(), [0x8, 0x2]);
});

test("test machine control point with Target Power", () {
var controlPoint = MachineControlPoint.setTargetPower(power: 300);

expect(controlPoint.opCode.value, 0x5);
expect(controlPoint.opCode.type, MachineControlPointOpcodeType.setTargetPower);
expect(controlPoint.getWriteData(), [0x5, 0x2C,0x01]);
});
}

0 comments on commit b6963fb

Please sign in to comment.