From cbcb284f4a32568c0c0782e8e3b6ffe6e0e485fe Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 28 May 2018 20:55:50 -0500 Subject: [PATCH] Allow libServo::attach to work on Teensy 3.5/3.6 --- Marlin/src/HAL/HAL_STM32F1/HAL_Servo_Stm32f1.h | 1 + Marlin/src/HAL/HAL_TEENSY35_36/HAL_Servo_Teensy.cpp | 8 ++++++-- Marlin/src/HAL/servo.cpp | 1 - 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Marlin/src/HAL/HAL_STM32F1/HAL_Servo_Stm32f1.h b/Marlin/src/HAL/HAL_STM32F1/HAL_Servo_Stm32f1.h index c035ba755..c27f7bd07 100644 --- a/Marlin/src/HAL/HAL_STM32F1/HAL_Servo_Stm32f1.h +++ b/Marlin/src/HAL/HAL_STM32F1/HAL_Servo_Stm32f1.h @@ -24,6 +24,7 @@ #ifndef HAL_SERVO_STM32F1_H #define HAL_SERVO_STM32F1_H +// Path needed, otherwise HAL version is used #include <../../libraries/Servo/src/Servo.h> // Inherit and expand on the official library diff --git a/Marlin/src/HAL/HAL_TEENSY35_36/HAL_Servo_Teensy.cpp b/Marlin/src/HAL/HAL_TEENSY35_36/HAL_Servo_Teensy.cpp index 6a5e40127..ff56036cc 100644 --- a/Marlin/src/HAL/HAL_TEENSY35_36/HAL_Servo_Teensy.cpp +++ b/Marlin/src/HAL/HAL_TEENSY35_36/HAL_Servo_Teensy.cpp @@ -6,13 +6,17 @@ #include "HAL_Servo_Teensy.h" +uint8_t servoPin[MAX_SERVOS] = { 0 }; + int8_t libServo::attach(const int pin) { if (this->servoIndex >= MAX_SERVOS) return -1; - return Servo::attach(pin); + if (pin > 0) servoPin[this->servoIndex] = pin; + return Servo::attach(servoPin[this->servoIndex]); } int8_t libServo::attach(const int pin, const int min, const int max) { - return Servo::attach(pin, min, max); + if (pin > 0) servoPin[this->servoIndex] = pin; + return Servo::attach(servoPin[this->servoIndex], min, max); } void libServo::move(const int value) { diff --git a/Marlin/src/HAL/servo.cpp b/Marlin/src/HAL/servo.cpp index 1c3c003d8..6bafb26dc 100644 --- a/Marlin/src/HAL/servo.cpp +++ b/Marlin/src/HAL/servo.cpp @@ -51,7 +51,6 @@ * */ - #include "../inc/MarlinConfig.h" #if HAS_SERVOS && !(IS_32BIT_TEENSY || defined(TARGET_LPC1768) || defined(STM32F4))