Skip to content

Commit

Permalink
fix: direction
Browse files Browse the repository at this point in the history
  • Loading branch information
ferbar committed Jan 7, 2017
1 parent 53b0afd commit 236835f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class BTcommThread extends org.ferbar.btcontrol.BTcommThread {
int clientID=0;

int currspeed=0;
int currDir=0;
int currDir=1;

/**
* Creates a new instance of BTcommThread
Expand Down Expand Up @@ -76,7 +76,7 @@ public void run() {
this.currDir=dir;
sendStatusReply();

String ret=MainActivity.usbArduino.sendCommand("D"+this.currDir);
String ret=MainActivity.usbArduino.sendCommand("D"+(this.currDir==1 ? 1 : 0));
Log.d(TAG, "ACC ret:" + ret);
} else if(cmd.isType("POWER")) {
FBTCtlMessage reply = new FBTCtlMessage(); reply.setType(MessageLayouts.messageTypeID("POWER_REPLY"));
Expand Down
10 changes: 5 additions & 5 deletions arduino/monster_shield/monster_shield.ino
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@ bool processCmd() {
if(line.startsWith("M")) {
Serial.print("m");
if(line.length() != 3) {
Serial.print(F("-invalid length:")); Serial.println(line.length()); return false;
Serial.print(F("-invalid length:")); Serial.print(line.length()); return false;
}
char c1=hex2val(line[1]);
if(c1 < 0) {
Serial.print(F("-invalid hex1:")); Serial.println(line[1]); return false;
Serial.print(F("-invalid hex1:")); Serial.print(line[1]); return false;
}
char c2=hex2val(line[2]);
if(c2 < 0) {
Serial.print(F("-invalied hex2:")); Serial.println(line[2]); return false;
Serial.print(F("-invalied hex2:")); Serial.print(line[2]); return false;
}
target_pwm=(c1<<4) + c2;
Serial.println(target_pwm, HEX);
motorGo(0, CW, target_pwm);
motorGo(0, dir, target_pwm);
return true;
} else if(line.startsWith("D")) {
if(line[1] == '0') {
Expand Down Expand Up @@ -109,7 +109,7 @@ bool processCmd() {
return true;
}
// invalid command:
Serial.print(F("error:[")); Serial.print(line); Serial.print(F("]\n"));
Serial.print(F("error:[")); Serial.print(line); Serial.print(F("]"));
return false;
}

Expand Down

0 comments on commit 236835f

Please sign in to comment.