Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
id "com.github.johnrengelman.shadow" version "4.0.3"
}

version = '2.6.0-SNAPSHOT'
version = '2.6.1-SNAPSHOT'

repositories {
jcenter()
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/ev3dev/actuators/lego/motors/BaseRegulatedMotor.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ public float getPosition() {

@Override
public void forward() {
this.setStringAttribute(POLARITY, POLARITY_NORMAL);
this.setSpeed(this.speed);
this.setSpeedDirect(this.speed);
if (!this.regulationFlag) {
this.setStringAttribute(COMMAND, RUN_DIRECT);
} else {
Expand All @@ -147,8 +146,7 @@ public void forward() {

@Override
public void backward(){
this.setStringAttribute(POLARITY, POLARITY_INVERSED);
this.setSpeed(this.speed);
this.setSpeedDirect(-this.speed);
if (!this.regulationFlag) {
this.setStringAttribute(COMMAND, RUN_DIRECT);
} else {
Expand Down Expand Up @@ -241,9 +239,13 @@ public boolean isMoving() {
*/
public void setSpeed(int speed) {
this.speed = speed;
if (!this.regulationFlag) {
setSpeedDirect(speed);
}

private void setSpeedDirect(int speed) {
if (!this.regulationFlag) {
this.setIntegerAttribute(DUTY_CYCLE, speed);
} else {
} else {
this.setIntegerAttribute(SPEED, speed);
}
}
Expand All @@ -264,6 +266,7 @@ public void resetTachoCount() {
* Rotate by the requested number of degrees. Wait for the move to complete.
*/
public void rotate(int angle, boolean immediateReturn) {
this.setSpeedDirect(this.speed);
this.setIntegerAttribute(POSITION_SP, angle);
this.setStringAttribute(COMMAND, RUN_TO_REL_POS);

Expand All @@ -288,6 +291,7 @@ public void rotate(int angle) {
}

public void rotateTo(int limitAngle, boolean immediateReturn) {
this.setSpeedDirect(this.speed);
this.setIntegerAttribute(POSITION_SP, limitAngle);
this.setStringAttribute(COMMAND, RUN_TO_ABS_POS);

Expand Down