Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added idle() method to power down a motor to save energy or allow manual rotation of motor #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Stepper KEYWORD1 Stepper

step KEYWORD2
setSpeed KEYWORD2
idle KEYWORD2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to use a true tab separator between the keyword and identifier, not spaces.

version KEYWORD2

######################################
Expand Down
28 changes: 26 additions & 2 deletions src/Stepper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Stepper.cpp - Stepper library for Wiring/Arduino - Version 1.1.0
* Stepper.cpp - Stepper library for Wiring/Arduino - Version 1.1.1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version is actually already at 1.1.3. A non-breaking API change should bump the minor version so the next release would be 1.2.0. But I think it's best to let Arduino handle the versioning since you don't necessarily want a version bump for every commit, only every release.

*
* Original library (0.1) by Tom Igoe.
* Two-wire modifications (0.2) by Sebastian Gassner
Expand All @@ -8,6 +8,7 @@
* High-speed stepping mod by Eugene Kozlenko
* Timer rollover fix by Eugene Kozlenko
* Five phase five wire (1.1.0) by Ryan Orendorff
* add idle method (1.1.1) by Darren Clark
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment regarding version.

*
* 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 @@ -356,10 +357,33 @@ void Stepper::stepMotor(int thisStep)
}
}

/*
idle() power down the pins (may lose count):
*/
void Stepper::idle(void) {
if (this->pin_count == 2) {
digitalWrite(motor_pin_1, LOW);
digitalWrite(motor_pin_2, LOW);
}
if (this->pin_count == 4) {
digitalWrite(motor_pin_1, LOW);
digitalWrite(motor_pin_2, LOW);
digitalWrite(motor_pin_3, LOW);
digitalWrite(motor_pin_4, LOW);
}
if (this->pin_count == 5) {
digitalWrite(motor_pin_1, LOW);
digitalWrite(motor_pin_2, LOW);
digitalWrite(motor_pin_3, LOW);
digitalWrite(motor_pin_4, LOW);
digitalWrite(motor_pin_5, LOW);
}
}

/*
version() returns the version of the library:
*/
int Stepper::version(void)
{
return 5;
return 6;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment regarding version.

}
4 changes: 4 additions & 0 deletions src/Stepper.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* High-speed stepping mod by Eugene Kozlenko
* Timer rollover fix by Eugene Kozlenko
* Five phase five wire (1.1.0) by Ryan Orendorff
* add idle method (1.1.1) by Darren Clark
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment regarding version.

*
* 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 @@ -95,6 +96,9 @@ class Stepper {

// mover method:
void step(int number_of_steps);

// idle method:
void idle(void);

int version(void);

Expand Down