Browse Source

Merge Servo pin (PR#2425)

pull/1/head
Richard Wackerbarth 10 years ago
parent
commit
ee71845d60
  1. 8
      Marlin/servo.cpp
  2. 4
      Marlin/servo.h

8
Marlin/servo.cpp

@ -244,11 +244,9 @@ uint8_t Servo::attach(int pin) {
uint8_t Servo::attach(int pin, int min, int max) { uint8_t Servo::attach(int pin, int min, int max) {
if (this->servoIndex < MAX_SERVOS ) { if (this->servoIndex < MAX_SERVOS ) {
#if defined(ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0) if(pin > 0)
if (pin > 0) this->pin = pin; else pin = this->pin; servos[this->servoIndex].Pin.nbr = pin;
#endif pinMode(servos[this->servoIndex].Pin.nbr, OUTPUT); // set servo pin to output
pinMode(pin, OUTPUT); // set servo pin to output
servos[this->servoIndex].Pin.nbr = pin;
// todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128 // todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128
this->min = (MIN_PULSE_WIDTH - min) / 4; //resolution of min/max is 4 uS this->min = (MIN_PULSE_WIDTH - min) / 4; //resolution of min/max is 4 uS
this->max = (MAX_PULSE_WIDTH - max) / 4; this->max = (MAX_PULSE_WIDTH - max) / 4;

4
Marlin/servo.h

@ -128,9 +128,7 @@ class Servo {
int read(); // returns current pulse width as an angle between 0 and 180 degrees int read(); // returns current pulse width as an angle between 0 and 180 degrees
int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release) int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release)
bool attached(); // return true if this servo is attached, otherwise false bool attached(); // return true if this servo is attached, otherwise false
#if defined(ENABLE_AUTO_BED_LEVELING) && PROBE_SERVO_DEACTIVATION_DELAY > 0
int pin; // store the hardware pin of the servo
#endif
private: private:
uint8_t servoIndex; // index into the channel data for this servo uint8_t servoIndex; // index into the channel data for this servo
int8_t min; // minimum is this value times 4 added to MIN_PULSE_WIDTH int8_t min; // minimum is this value times 4 added to MIN_PULSE_WIDTH

Loading…
Cancel
Save