Reduce pen down speed

This commit is contained in:
Blokkendoos
2018-05-15 01:18:38 +02:00
parent 38ef1ea963
commit b81623a4f8
2 changed files with 17 additions and 10 deletions

View File

@@ -494,21 +494,27 @@ void process_commands(char command[], int command_length) // deals with standard
void moveServo(double value) void moveServo(double value)
{ {
const int incrementDelay = SERVO_DELAY;
const int currentAngle = servo.read();
servoEnabled = true; servoEnabled = true;
if (value < 0.) if (value < 0.) value = 0.;
value = 0.; if (value > 180.) value = 180.;
else if (value > 180.)
if (value > currentAngle) // down
{ {
value = DEFAULT_PEN_UP_POSITION; for (int angle=currentAngle; angle<value; angle++) // single "degree" increments
servo.write((int)value);
for(int i=0; i<100; i++)
{ {
SoftwareServo::refresh(); servo.write(angle);
delay(2); delay (incrementDelay);
SoftwareServo::refresh();
} }
servoEnabled = false;
} }
servo.write((int)value); else if (value < currentAngle) // up, no delay
{
servo.write((int)value);
}
// nothing to be done if value == currentAngle
} }
/* This code was ported from the Makerbot/ReplicatorG java sources */ /* This code was ported from the Makerbot/ReplicatorG java sources */

View File

@@ -44,6 +44,7 @@
#define XAXIS_MICROSTEPPING 16 #define XAXIS_MICROSTEPPING 16
#define SERVO_PIN_1 10 #define SERVO_PIN_1 10
#define SERVO_DELAY 75 // (ms) delay between position changes
// Optional output // Optional output
#define ALT_PIN 2 #define ALT_PIN 2