Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
5c61677ab9 | |||
21025b5f83 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pxt-ev3",
|
"name": "pxt-ev3",
|
||||||
"version": "0.3.3",
|
"version": "0.3.4",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pxt-ev3",
|
"name": "pxt-ev3",
|
||||||
"version": "0.3.3",
|
"version": "0.3.4",
|
||||||
"description": "LEGO MINDSTORMS EV3 for Microsoft MakeCode",
|
"description": "LEGO MINDSTORMS EV3 for Microsoft MakeCode",
|
||||||
"private": true,
|
"private": true,
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
@ -150,7 +150,8 @@ namespace pxsim {
|
|||||||
const step2 = this.speedCmdValues[2];
|
const step2 = this.speedCmdValues[2];
|
||||||
const step3 = this.speedCmdValues[3];
|
const step3 = this.speedCmdValues[3];
|
||||||
const brake = this.speedCmdValues[4];
|
const brake = this.speedCmdValues[4];
|
||||||
const dstep = (this.speedCmd == DAL.opOutputTimePower || this.speedCmd == DAL.opOutputTimeSpeed)
|
const isTimeCommand = this.speedCmd == DAL.opOutputTimePower || this.speedCmd == DAL.opOutputTimeSpeed;
|
||||||
|
const dstep = isTimeCommand
|
||||||
? pxsim.U.now() - this.speedCmdTime
|
? pxsim.U.now() - this.speedCmdTime
|
||||||
: this.tacho - this.speedCmdTacho;
|
: this.tacho - this.speedCmdTacho;
|
||||||
if (dstep < step1) // rampup
|
if (dstep < step1) // rampup
|
||||||
@ -161,6 +162,16 @@ namespace pxsim {
|
|||||||
this.speed = speed * (step1 + step2 + step3 - dstep) / (step1 + step2 + step3);
|
this.speed = speed * (step1 + step2 + step3 - dstep) / (step1 + step2 + step3);
|
||||||
else {
|
else {
|
||||||
if (brake) this.speed = 0;
|
if (brake) this.speed = 0;
|
||||||
|
if (!isTimeCommand) {
|
||||||
|
// we need to patch the actual position of the motor when
|
||||||
|
// finishing the move as our integration step introduce errors
|
||||||
|
const deltaAngle = -Math.sign(speed) * (dstep - (step1 + step2 + step3));
|
||||||
|
if (deltaAngle) {
|
||||||
|
this.angle += deltaAngle;
|
||||||
|
this.tacho -= Math.abs(deltaAngle);
|
||||||
|
this.setChangedState();
|
||||||
|
}
|
||||||
|
}
|
||||||
this.clearSpeedCmd();
|
this.clearSpeedCmd();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user