Open Debenben opened 2 years ago
@nathankellenicki Thank you for merging some pull requests! For me this mechanism has been working well, I think it would be a benefit for the official library, too. I rebased the pull request, let me know if you have some questions, suggestions or would like me to do some changes.
Initially I only planned to do some small improvements to prevent my port input commands from clogging up such that they were already outdated when being transmitted. But the whole undertaking got more and more inconsistent and messy, so I ended up doing a large-scale rework for all port output commands.
A large majority of code using the library should be compatible with the changes, but some things would change. Rough overview of most important breaking change without paying attention to detail:
same behavior:
motorA.rotateByDegrees(30).then(motorA.rotateByDegrees(30));
Result: motorA rotates by 60 degrees in totalawait motorA.rotateByDegrees(30); await motorA.rotateByDegrees(30);
Result: motorA rotates by 60 degrees in totalmotorA.rotateByDegrees(30); motorB.rotateByDegrees(30);
Result: motorA and motorB start rotating at the same time by 30 degrees eachmotorA.setAccelerationTime(300); motorA.rotateByDegrees(30);
Result: the acceleration time is set to 300 ms and then motorA rotates by 30 degreesdifferent behavior:
motorA.rotateByDegrees(30); motorA.rotateByDegrees(30);
Result old: motorA rotates by 30 degrees Result new: motorA rotates by 60 degreesmotorA.rampPower(0,100,5000).then(res => console.log("feedback is " + res)); motorA.rotateByDegrees(30);
Result old: motorA rotates by 30 degrees Result new: motorA ramps power from 0 to 100, then prints "feedback is 34", then rotates by 30 degreesnew feature:
motorA.setAccelerationTime(300, true).then(res => console.log("feedback1 is " + res)); motorA.rotateByDegrees(30, 100, true).then(res => console.log("feedback2 is " + res));
Result new: prints "feedback1 is 68" and discards the acceleration time command, then rotates by 30 degrees with speed 100, then prints "feedback2 is 34"I tested with a technic hub and two motors so far it works great for me and I did not encounter any problems, therefore I decided to put this change up for discussion even though not every device has been tested.