Skip to content

Commit

Permalink
cleanup files and bump minor version to v2.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
soundanalogous committed Sep 16, 2017
1 parent 3074683 commit 75073b9
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 71 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "git",
"url": "https://github.com/firmata/ConfigurableFirmata.git"
},
"version": "2.9.2",
"version": "2.10.0",
"exclude": [
"extras",
"test"
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ConfigurableFirmata
version=2.9.2
version=2.10.0
author=Firmata Developers
maintainer=https://github.com/firmata/ConfigurableFirmata
sentence=This library implements the Firmata protocol as a set of plugins that can be used to create applications to remotely interface with an Arduino board.
Expand Down
65 changes: 28 additions & 37 deletions src/AccelStepperFirmata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2010-2011 Paul Stoffregen. All rights reserved.
Copyright (C) 2009 Shigeru Kobayashi. All rights reserved.
Copyright (C) 2013 Norbert Truchsess. All rights reserved.
Copyright (C) 2009-2016 Jeff Hoefs. All rights reserved.
Copyright (C) 2009-2017 Jeff Hoefs. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand All @@ -12,7 +12,7 @@
See file LICENSE.txt for further informations on licensing terms.
Last updated by Jeff Hoefs: January 23rd, 2016
Last updated: September 16th, 2017
*/

#include <ConfigurableFirmata.h>
Expand Down Expand Up @@ -43,11 +43,10 @@ void AccelStepperFirmata::handleCapability(byte pin)
void AccelStepperFirmata::reportPosition(byte deviceNum, bool complete)
{
if (stepper[deviceNum]) {

byte data[5];
long position = stepper[deviceNum]->currentPosition();
encode32BitSignedInteger(position, data);

Firmata.write(START_SYSEX);
Firmata.write(ACCELSTEPPER_DATA);
if (complete) {
Expand All @@ -68,7 +67,6 @@ void AccelStepperFirmata::reportPosition(byte deviceNum, bool complete)
void AccelStepperFirmata::reportGroupComplete(byte deviceNum)
{
if (group[deviceNum]) {

Firmata.write(START_SYSEX);
Firmata.write(ACCELSTEPPER_DATA);
Firmata.write(MULTISTEPPER_MOVE_COMPLETE);
Expand All @@ -83,30 +81,30 @@ void AccelStepperFirmata::reportGroupComplete(byte deviceNum)

boolean AccelStepperFirmata::handleSysex(byte command, byte argc, byte *argv)
{

if (command == ACCELSTEPPER_DATA) {

byte stepCommand, deviceNum, interface, wireCount, stepType;
byte stepOrMotorPin1, directionOrMotorPin2, motorPin3 = 0, motorPin4 = 0, enablePin = 0, invertPins = 0;
byte stepOrMotorPin1, directionOrMotorPin2;
byte motorPin3 = 0, motorPin4 = 0, enablePin = 0, invertPins = 0;
long numSteps;

unsigned int index = 0;

stepCommand = argv[index++];
deviceNum = argv[index++];

if (deviceNum < MAX_ACCELSTEPPERS) {

if (stepCommand == ACCELSTEPPER_CONFIG) {

interface = argv[index++];
wireCount = (interface & 0x70) >> 4; // upper 3 bits are the wire count
stepType = (interface & 0x07) >> 1; // bits 4-6 are the step type
stepOrMotorPin1 = argv[index++]; // Step pin for driver or MotorPin1
directionOrMotorPin2 = argv[index++]; // Direction pin for driver or motorPin2

if (Firmata.getPinMode(directionOrMotorPin2) == PIN_MODE_IGNORE || Firmata.getPinMode(stepOrMotorPin1) == PIN_MODE_IGNORE)
if (Firmata.getPinMode(directionOrMotorPin2) == PIN_MODE_IGNORE
|| Firmata.getPinMode(stepOrMotorPin1) == PIN_MODE_IGNORE) {
return false;
}

Firmata.setPinMode(stepOrMotorPin1, PIN_MODE_STEPPER);
Firmata.setPinMode(directionOrMotorPin2, PIN_MODE_STEPPER);
Expand Down Expand Up @@ -150,12 +148,12 @@ boolean AccelStepperFirmata::handleSysex(byte command, byte argc, byte *argv)
} else if (wireCount == 4 && stepType == STEP_TYPE_HALF) {
stepper[deviceNum] = new AccelStepper(AccelStepper::HALF4WIRE, stepOrMotorPin1, directionOrMotorPin2, motorPin3, motorPin4, false);
}

// If there is still another byte to read we must be inverting some pins
if (argc >= index) {
invertPins = argv[index];
if (wireCount == 1) {
stepper[deviceNum]->setPinsInverted(invertPins & 0x01, invertPins >> 1 & 0x01, invertPins >> 4 & 0x01);
stepper[deviceNum]->setPinsInverted(invertPins & 0x01, invertPins >> 1 & 0x01, invertPins >> 4 & 0x01);
} else {
stepper[deviceNum]->setPinsInverted(invertPins & 0x01, invertPins >> 1 & 0x01, invertPins >> 2 & 0x01, invertPins >> 3 & 0x01, invertPins >> 4 & 0x01);
}
Expand All @@ -166,11 +164,11 @@ boolean AccelStepperFirmata::handleSysex(byte command, byte argc, byte *argv)
}

/*
Default to no acceleration. We set the acceleration value high enough that our speed is
reached on the first step of a movement.
Default to no acceleration. We set the acceleration value high enough that our speed is
reached on the first step of a movement.
More info about this hack in ACCELSTEPPER_SET_ACCELERATION.
The lines where we are setting the speed twice are necessary because if the max speed doesn't change
The lines where we are setting the speed twice are necessary because if the max speed doesn't change
from the default value then our time to next step does not get computed after raising the acceleration.
*/
stepper[deviceNum]->setMaxSpeed(2.0);
Expand All @@ -182,7 +180,6 @@ boolean AccelStepperFirmata::handleSysex(byte command, byte argc, byte *argv)
}

else if (stepCommand == ACCELSTEPPER_STEP) {

numSteps = decode32BitSignedInteger(argv[2], argv[3], argv[4], argv[5], argv[6]);

if (stepper[deviceNum]) {
Expand Down Expand Up @@ -231,11 +228,10 @@ boolean AccelStepperFirmata::handleSysex(byte command, byte argc, byte *argv)
}

else if (stepCommand == ACCELSTEPPER_SET_ACCELERATION) {

float decodedAcceleration = decodeCustomFloat(argv[2], argv[3], argv[4], argv[5]);

if (stepper[deviceNum]) {
/*
/*
<HACK>
All firmata instances of accelStepper have an acceleration value. If a user does not
want acceleration we just set the acceleration value high enough so
Expand All @@ -256,27 +252,25 @@ boolean AccelStepperFirmata::handleSysex(byte command, byte argc, byte *argv)
}

else if (stepCommand == ACCELSTEPPER_SET_SPEED) {
// Sets the maxSpeed for accelStepper. We do not use setSpeed here because
// Sets the maxSpeed for accelStepper. We do not use setSpeed here because
// all instances of accelStepper that have been created by firmata are
// using acceleration. More info about this hack in ACCELSTEPPER_SET_ACCELERATION.
float speed = decodeCustomFloat(argv[2], argv[3], argv[4], argv[5]);

if (stepper[deviceNum]) {
stepper[deviceNum]->setMaxSpeed(speed);
}

}

else if (stepCommand == MULTISTEPPER_CONFIG) {

if (!group[deviceNum]) {
numGroups++;
group[deviceNum] = new MultiStepper();
}

for (byte i = index; i < argc; i++) {
byte stepperNumber = argv[i];

if (stepper[stepperNumber]) {
groupStepperCount[deviceNum]++;
group[deviceNum]->addStepper(*stepper[stepperNumber]);
Expand All @@ -287,27 +281,24 @@ boolean AccelStepperFirmata::handleSysex(byte command, byte argc, byte *argv)
}

else if (stepCommand == MULTISTEPPER_TO) {

groupIsRunning[deviceNum] = true;
long positions[groupStepperCount[deviceNum]];

for (byte i = 0, offset = 0; i < groupStepperCount[deviceNum]; i++) {
offset = index + (i * 5);
positions[i] = decode32BitSignedInteger(argv[offset], argv[offset+1], argv[offset+2], argv[offset+3], argv[offset+4]);
positions[i] = decode32BitSignedInteger(argv[offset], argv[offset + 1], argv[offset + 2], argv[offset + 3], argv[offset + 4]);
}

group[deviceNum]->moveTo(positions);

}

else if (stepCommand == MULTISTEPPER_STOP) {

groupIsRunning[deviceNum] = false;
reportGroupComplete(deviceNum);
}
}
return true;

}
return false;
}
Expand All @@ -325,7 +316,7 @@ void AccelStepperFirmata::reset()
}
}
numSteppers = 0;

for (byte i = 0; i < MAX_GROUPS; i++) {
if (group[i]) {
free(group[i]);
Expand Down Expand Up @@ -375,13 +366,13 @@ void AccelStepperFirmata::encode32BitSignedInteger(long value, byte pdata[])
inv = true;
value = value * -1;
}

pdata[0] = value & 0x7f;
pdata[1] = (value >> 7) & 0x7f;
pdata[2] = (value >> 14) & 0x7f;
pdata[3] = (value >> 21) & 0x7f;
pdata[4] = (value >> 28) & 0x7f;

if (inv == true) {
pdata[4] = pdata[4] | 0x08;
}
Expand All @@ -399,29 +390,29 @@ void AccelStepperFirmata::update()
for (byte i = 0; i < MAX_GROUPS; i++) {
if (group[i] && groupIsRunning[i] == true) {
stepsLeft = group[i]->run();

// send command to client application when stepping is complete
if (stepsLeft != true) {
groupIsRunning[i] = false;
reportGroupComplete(i);
}

}
}
}

if (numSteppers > 0) {
// if one or more stepper motors are used, update their position
for (byte i = 0; i < MAX_ACCELSTEPPERS; i++) {
if (stepper[i] && isRunning[i] == true) {
stepsLeft = stepper[i]->run();

// send command to client application when stepping is complete
if (!stepsLeft) {
isRunning[i] = false;
reportPosition(i, true);
}

}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/AccelStepperFirmata.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2010-2011 Paul Stoffregen. All rights reserved.
Copyright (C) 2009 Shigeru Kobayashi. All rights reserved.
Copyright (C) 2013 Norbert Truchsess. All rights reserved.
Copyright (C) 2009-2016 Jeff Hoefs. All rights reserved.
Copyright (C) 2009-2017 Jeff Hoefs. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -66,4 +66,4 @@ class AccelStepperFirmata: public FirmataFeature
byte groupStepperCount[MAX_GROUPS];
};

#endif
#endif /* AccelStepperFirmata_h */
4 changes: 2 additions & 2 deletions src/ConfigurableFirmata.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
ConfigurableFirmata.pp - ConfigurableFirmata library v2.9.1 - 2016-8-14
ConfigurableFirmata.pp - ConfigurableFirmata library v2.10.0 - 2017-6-16
Copyright (c) 2006-2008 Hans-Christoph Steiner. All rights reserved.
Copyright (c) 2013 Norbert Truchsess. All rights reserved.
Copyright (c) 2013-2016 Jeff Hoefs. All rights reserved.
Copyright (c) 2013-2017 Jeff Hoefs. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down
22 changes: 11 additions & 11 deletions src/ConfigurableFirmata.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
ConfigurableFirmata.h - ConfigurableFirmata library v2.9.1 - 2016-8-14
ConfigurableFirmata.h - ConfigurableFirmata library v2.10.0 - 2017-6-16
Copyright (c) 2006-2008 Hans-Christoph Steiner. All rights reserved.
Copyright (c) 2013 Norbert Truchsess. All rights reserved.
Copyright (c) 2013-2016 Jeff Hoefs. All rights reserved.
Copyright (c) 2013-2017 Jeff Hoefs. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand All @@ -22,29 +22,29 @@
* Query using the REPORT_VERSION message.
*/
#define FIRMATA_PROTOCOL_MAJOR_VERSION 2 // for non-compatible changes
#define FIRMATA_PROTOCOL_MINOR_VERSION 5 // for backwards compatible changes
#define FIRMATA_PROTOCOL_BUGFIX_VERSION 1 // for bugfix releases
#define FIRMATA_PROTOCOL_MINOR_VERSION 6 // for backwards compatible changes
#define FIRMATA_PROTOCOL_BUGFIX_VERSION 0 // for bugfix releases

/*
* Version numbers for the Firmata library.
* ConfigurableFirmata 2.9.1 implements version 2.5.1 of the Firmata protocol.
* ConfigurableFirmata 2.10.0 implements version 2.6.0 of the Firmata protocol.
* The firmware version will not always equal the protocol version going forward.
* Query using the REPORT_FIRMWARE message.
*/
#define FIRMATA_FIRMWARE_MAJOR_VERSION 2 // for non-compatible changes
#define FIRMATA_FIRMWARE_MINOR_VERSION 9 // for backwards compatible changes
#define FIRMATA_FIRMWARE_BUGFIX_VERSION 1 // for bugfix releases
#define FIRMATA_FIRMWARE_MINOR_VERSION 10 // for backwards compatible changes
#define FIRMATA_FIRMWARE_BUGFIX_VERSION 0 // for bugfix releases

// DEPRECATED as of ConfigurableFirmata v2.8.1.
// Use FIRMATA_PROTOCOL_[MAJOR|MINOR|BUGFIX]_VERSION instead.
#define FIRMATA_MAJOR_VERSION 2
#define FIRMATA_MINOR_VERSION 5
#define FIRMATA_BUGFIX_VERSION 1
#define FIRMATA_MINOR_VERSION 6
#define FIRMATA_BUGFIX_VERSION 0
// DEPRECATED as of ConfigurableFirmata v2.8.1.
//Use FIRMATA_FIRMWARE_[MAJOR|MINOR|BUGFIX]_VERSION instead.
#define FIRMWARE_MAJOR_VERSION 2
#define FIRMWARE_MINOR_VERSION 9
#define FIRMWARE_BUGFIX_VERSION 1
#define FIRMWARE_MINOR_VERSION 10
#define FIRMWARE_BUGFIX_VERSION 0

#define MAX_DATA_BYTES 64 // max number of data bytes in incoming messages

Expand Down
Loading

0 comments on commit 75073b9

Please sign in to comment.