Browse Source

Allow libServo::attach to work on Teensy 3.5/3.6

Scott Lahteine 7 years ago
parent
commit
cbcb284f4a

+ 1
- 0
Marlin/src/HAL/HAL_STM32F1/HAL_Servo_Stm32f1.h View File

24
 #ifndef HAL_SERVO_STM32F1_H
24
 #ifndef HAL_SERVO_STM32F1_H
25
 #define HAL_SERVO_STM32F1_H
25
 #define HAL_SERVO_STM32F1_H
26
 
26
 
27
+// Path needed, otherwise HAL version is used
27
 #include <../../libraries/Servo/src/Servo.h>
28
 #include <../../libraries/Servo/src/Servo.h>
28
 
29
 
29
 // Inherit and expand on the official library
30
 // Inherit and expand on the official library

+ 6
- 2
Marlin/src/HAL/HAL_TEENSY35_36/HAL_Servo_Teensy.cpp View File

6
 
6
 
7
 #include "HAL_Servo_Teensy.h"
7
 #include "HAL_Servo_Teensy.h"
8
 
8
 
9
+uint8_t servoPin[MAX_SERVOS] = { 0 };
10
+
9
 int8_t libServo::attach(const int pin) {
11
 int8_t libServo::attach(const int pin) {
10
   if (this->servoIndex >= MAX_SERVOS) return -1;
12
   if (this->servoIndex >= MAX_SERVOS) return -1;
11
-  return Servo::attach(pin);
13
+  if (pin > 0) servoPin[this->servoIndex] = pin;
14
+  return Servo::attach(servoPin[this->servoIndex]);
12
 }
15
 }
13
 
16
 
14
 int8_t libServo::attach(const int pin, const int min, const int max) {
17
 int8_t libServo::attach(const int pin, const int min, const int max) {
15
-  return Servo::attach(pin, min, max);
18
+  if (pin > 0) servoPin[this->servoIndex] = pin;
19
+  return Servo::attach(servoPin[this->servoIndex], min, max);
16
 }
20
 }
17
 
21
 
18
 void libServo::move(const int value) {
22
 void libServo::move(const int value) {

+ 0
- 1
Marlin/src/HAL/servo.cpp View File

51
  *
51
  *
52
  */
52
  */
53
 
53
 
54
-
55
 #include "../inc/MarlinConfig.h"
54
 #include "../inc/MarlinConfig.h"
56
 
55
 
57
 #if HAS_SERVOS && !(IS_32BIT_TEENSY || defined(TARGET_LPC1768) || defined(STM32F4))
56
 #if HAS_SERVOS && !(IS_32BIT_TEENSY || defined(TARGET_LPC1768) || defined(STM32F4))

Loading…
Cancel
Save