Skip to content

Commit

Permalink
v1.7.1 rewrite attach & detach function set_servo_status
Browse files Browse the repository at this point in the history
  • Loading branch information
altjz committed Jun 28, 2016
1 parent a9aeaf2 commit 36b98c4
Show file tree
Hide file tree
Showing 10 changed files with 313 additions and 293 deletions.
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# uArm Arduino Library Release Note

## [1.7.1] - 2016-06-28

### Fix
- Set Current angle after attach servo
- rewrite set_servo_status replace attach_servo detach_servo

## [1.7.0] - 2016-06-24

### Fix
Expand Down
5 changes: 4 additions & 1 deletion examples/Calibration/Calibration.ino
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ void manual_calibration_section()
{
int setLoop = 1;

uarm.detach_all_servos();
uarm.set_servo_status(false, SERVO_ROT_NUM);
uarm.set_servo_status(false, SERVO_LEFT_NUM);
uarm.set_servo_status(false, SERVO_RIGHT_NUM);
uarm.set_servo_status(false, SERVO_HAND_ROT_NUM);

Serial.println("Put uarm in calibration posture (servo 1 to 3: 45, 130, 20 degree respectively), then input 1");
while (setLoop) {
Expand Down
17 changes: 0 additions & 17 deletions examples/GetXYZ/GetXYZ.ino

This file was deleted.

16 changes: 14 additions & 2 deletions examples/GettingStarted/GettingStarted.ino
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,21 @@ void loop() {
// Detach Servo

if (readSerial == 'd') {
uarm.detach_all_servos();
uarm.set_servo_status(false, SERVO_ROT_NUM);
uarm.set_servo_status(false, SERVO_LEFT_NUM);
uarm.set_servo_status(false, SERVO_RIGHT_NUM);
uarm.set_servo_status(false, SERVO_HAND_ROT_NUM);
}
//---------------------------------- function a ------------------------------------
// Detach Servo

if (readSerial == 'a') {
uarm.set_servo_status(true, SERVO_ROT_NUM);
uarm.set_servo_status(true, SERVO_LEFT_NUM);
uarm.set_servo_status(true, SERVO_RIGHT_NUM);
uarm.set_servo_status(true, SERVO_HAND_ROT_NUM);
}

//---------------------------------- function o ------------------------------------
// Pump on
if (readSerial == 'o') {
Expand All @@ -97,7 +110,6 @@ void loop() {
// function below is for print current x,y,z absolute location

if (readSerial == 'g') {
uarm.detach_all_servos();
uarm.get_current_xyz();
Serial.print("The current location is ");
Serial.print(uarm.get_current_x());
Expand Down
14 changes: 9 additions & 5 deletions examples/UArmProtocol/UArmProtocol.ino
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#define UARM_FIRMATA_BUGFIX 2

#define UARM_FIRMWARE_MAJOR_VERSION 1
#define UARM_FIRMWARE_MINOR_VERSION 6
#define UARM_FIRMWARE_BUGFIX 2
#define UARM_FIRMWARE_MINOR_VERSION 7
#define UARM_FIRMWARE_BUGFIX 1

#define START_SYSEX 0xF0 // start a MIDI Sysex message
#define END_SYSEX 0xF7 // end a MIDI Sysex message
Expand All @@ -37,7 +37,7 @@
#define WRITE_ANALOG (0X17)
#define READ_EEPROM (0X1A)
#define WRITE_EEPROM (0X1B)
#define DETACH_SERVO (0X1C)
#define SERVO_STATUS (0X1C)
#define PUMP_STATUS (0X1D)
#define WRITE_STRETCH (0X1E)
#define WRITE_LEFT_RIGHT_ANGLE (0X1F)
Expand All @@ -61,6 +61,7 @@ int sysexBytesRead;
void setup()
{
Serial.begin(57600);
uarm.init();
}

void loop()
Expand Down Expand Up @@ -271,9 +272,12 @@ boolean handleSysex(byte command, byte argc, byte *argv)
}

// CMD 1C Servo Attach or Detach
if (uarmCommand == DETACH_SERVO)
if (uarmCommand == SERVO_STATUS)
{
uarm.detach_all_servos();
// uarm.detach_all_servos();
byte servo_num = argv[1];
boolean servo_status = argv[2] == 0 ? false : true;
uarm.set_servo_status(servo_status, servo_num);
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/UArmTextControl2.0/UArmTextControl2.0.ino
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ String runCommand(String cmnd){
if(errorResponse.length() > 0) {return errorResponse; }
float values[1];
getCommandValues(cmnd, attachDetachParameters, 1, values);
if(values[0] == 1) { uarm.g_servo_rot.attach(SERVO_ROT_PIN); }else if(values[0] == 2) { uarm.g_servo_left.attach(SERVO_LEFT_PIN); }else if(values[0] == 3) { uarm.g_servo_right.attach(SERVO_RIGHT_PIN); }else if(values[0] == 4) {uarm.g_servo_hand_rot.attach(SERVO_HAND_PIN); }else{ return F("[ERROR: Servo number does not exist]\n"); }
if(values[0] == 1) { uarm.set_servo_status(true, SERVO_ROT_NUM); }else if(values[0] == 2) { uarm.set_servo_status(true, SERVO_LEFT_NUM); }else if(values[0] == 3) { uarm.set_servo_status(true, SERVO_RIGHT_NUM); }else if(values[0] == 4) { uarm.set_servo_status(true, SERVO_HAND_ROT_NUM); }else{ return F("[ERROR: Servo number does not exist]\n"); }
return ok + cmnd + endB;
}

Expand All @@ -177,7 +177,7 @@ String runCommand(String cmnd){
if(errorResponse.length() > 0) {return errorResponse; }
float values[1];
getCommandValues(cmnd, attachDetachParameters, 1, values);
if(values[0] == 1) { uarm.g_servo_rot.detach(); }else if(values[0] == 2) {uarm.g_servo_left.detach(); }else if(values[0] == 3) {uarm.g_servo_right.detach(); }else if(values[0] == 4) {uarm.g_servo_hand_rot.detach(); }else{ return "[ERROR: Servo number " + String(values[0]) + " does not exist]\n"; }
if(values[0] == 1) { uarm.set_servo_status(false, SERVO_ROT_NUM); }else if(values[0] == 2) {uarm.set_servo_status(false, SERVO_LEFT_NUM); }else if(values[0] == 3) {uarm.set_servo_status(false, SERVO_RIGHT_NUM); }else if(values[0] == 4) {uarm.set_servo_status(false, SERVO_HAND_ROT_NUM); }else{ return "[ERROR: Servo number " + String(values[0]) + " does not exist]\n"; }
return ok + cmnd + endB;
}

Expand Down
Loading

0 comments on commit 36b98c4

Please sign in to comment.