|
@@ -1,85 +1,79 @@
|
1
|
1
|
/**
|
2
|
|
- * Marlin 3D Printer Firmware
|
3
|
|
- * Copyright (C) 2016, 2017 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
4
|
|
- *
|
5
|
|
- * Based on Sprinter and grbl.
|
6
|
|
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
7
|
|
- *
|
8
|
|
- * This program is free software: you can redistribute it and/or modify
|
9
|
|
- * it under the terms of the GNU General Public License as published by
|
10
|
|
- * the Free Software Foundation, either version 3 of the License, or
|
11
|
|
- * (at your option) any later version.
|
12
|
|
- *
|
13
|
|
- * This program is distributed in the hope that it will be useful,
|
14
|
|
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
|
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
|
- * GNU General Public License for more details.
|
17
|
|
- *
|
18
|
|
- * You should have received a copy of the GNU General Public License
|
19
|
|
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20
|
|
- *
|
21
|
|
-*/
|
22
|
|
-
|
23
|
|
-/**
|
24
|
|
- * Based on servo.cpp - Interrupt driven Servo library for Arduino using 16 bit
|
25
|
|
- * timers- Version 2 Copyright (c) 2009 Michael Margolis. All right reserved.
|
26
|
|
-*/
|
|
2
|
+ * Marlin 3D Printer Firmware
|
|
3
|
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
4
|
+ *
|
|
5
|
+ * Based on Sprinter and grbl.
|
|
6
|
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
|
7
|
+ *
|
|
8
|
+ * This program is free software: you can redistribute it and/or modify
|
|
9
|
+ * it under the terms of the GNU General Public License as published by
|
|
10
|
+ * the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+ * (at your option) any later version.
|
|
12
|
+ *
|
|
13
|
+ * This program is distributed in the hope that it will be useful,
|
|
14
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+ * GNU General Public License for more details.
|
|
17
|
+ *
|
|
18
|
+ * You should have received a copy of the GNU General Public License
|
|
19
|
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+ *
|
|
21
|
+ */
|
27
|
22
|
|
28
|
23
|
/**
|
29
|
|
- * A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method.
|
30
|
|
- * The servos are pulsed in the background using the value most recently written using the write() method
|
31
|
|
- *
|
32
|
|
- * Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached.
|
33
|
|
- * Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four.
|
34
|
|
- *
|
35
|
|
- * The methods are:
|
36
|
|
- *
|
37
|
|
- * Servo - Class for manipulating servo motors connected to Arduino pins.
|
38
|
|
- *
|
39
|
|
- * attach(pin) - Attach a servo motor to an i/o pin.
|
40
|
|
- * attach(pin, min, max) - Attach to a pin, setting min and max values in microseconds
|
41
|
|
- * Default min is 544, max is 2400
|
42
|
|
- *
|
43
|
|
- * write() - Set the servo angle in degrees. (Invalid angles —over MIN_PULSE_WIDTH— are treated as µs.)
|
44
|
|
- * writeMicroseconds() - Set the servo pulse width in microseconds.
|
45
|
|
- * move(pin, angle) - Sequence of attach(pin), write(angle), delay(SERVO_DELAY).
|
46
|
|
- * With DEACTIVATE_SERVOS_AFTER_MOVE it detaches after SERVO_DELAY.
|
47
|
|
- * read() - Get the last-written servo pulse width as an angle between 0 and 180.
|
48
|
|
- * readMicroseconds() - Get the last-written servo pulse width in microseconds.
|
49
|
|
- * attached() - Return true if a servo is attached.
|
50
|
|
- * detach() - Stop an attached servo from pulsing its i/o pin.
|
51
|
|
- *
|
52
|
|
-*/
|
|
24
|
+ * Based on servo.cpp - Interrupt driven Servo library for Arduino using 16 bit
|
|
25
|
+ * timers- Version 2 Copyright (c) 2009 Michael Margolis. All right reserved.
|
|
26
|
+ */
|
53
|
27
|
|
54
|
28
|
/**
|
55
|
|
- * The only time that this library wants physical movement is when a WRITE
|
56
|
|
- * command is issued. Before that all the attach & detach activity is solely
|
57
|
|
- * within the data base.
|
|
29
|
+ * A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method.
|
|
30
|
+ * The servos are pulsed in the background using the value most recently written using the write() method
|
|
31
|
+ *
|
|
32
|
+ * Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached.
|
|
33
|
+ * Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four.
|
|
34
|
+ *
|
|
35
|
+ * The methods are:
|
|
36
|
+ *
|
|
37
|
+ * Servo - Class for manipulating servo motors connected to Arduino pins.
|
58
|
38
|
*
|
59
|
|
- * The PWM output is inactive until the first WRITE. After that it stays active
|
60
|
|
- * unless DEACTIVATE_SERVOS_AFTER_MOVE is enabled and a MOVE command was issued.
|
|
39
|
+ * attach(pin) - Attach a servo motor to an i/o pin.
|
|
40
|
+ * attach(pin, min, max) - Attach to a pin, setting min and max values in microseconds
|
|
41
|
+ * Default min is 544, max is 2400
|
|
42
|
+ *
|
|
43
|
+ * write() - Set the servo angle in degrees. (Invalid angles —over MIN_PULSE_WIDTH— are treated as µs.)
|
|
44
|
+ * writeMicroseconds() - Set the servo pulse width in microseconds.
|
|
45
|
+ * move(pin, angle) - Sequence of attach(pin), write(angle), delay(SERVO_DELAY).
|
|
46
|
+ * With DEACTIVATE_SERVOS_AFTER_MOVE it detaches after SERVO_DELAY.
|
|
47
|
+ * read() - Get the last-written servo pulse width as an angle between 0 and 180.
|
|
48
|
+ * readMicroseconds() - Get the last-written servo pulse width in microseconds.
|
|
49
|
+ * attached() - Return true if a servo is attached.
|
|
50
|
+ * detach() - Stop an attached servo from pulsing its i/o pin.
|
61
|
51
|
*
|
62
|
52
|
*/
|
63
|
53
|
|
64
|
|
-#ifdef TARGET_LPC1768
|
65
|
|
-
|
66
|
|
-#if HAS_SERVOS
|
|
54
|
+/**
|
|
55
|
+ * The only time that this library wants physical movement is when a WRITE
|
|
56
|
+ * command is issued. Before that all the attach & detach activity is solely
|
|
57
|
+ * within the data base.
|
|
58
|
+ *
|
|
59
|
+ * The PWM output is inactive until the first WRITE. After that it stays active
|
|
60
|
+ * unless DEACTIVATE_SERVOS_AFTER_MOVE is enabled and a MOVE command was issued.
|
|
61
|
+ */
|
67
|
62
|
|
|
63
|
+#include "../../../MarlinConfig.h"
|
68
|
64
|
|
69
|
|
-#include "LPC1768_Servo.h"
|
70
|
|
-#include "servo_private.h"
|
|
65
|
+#if HAS_SERVOS && defined(TARGET_LPC1768)
|
71
|
66
|
|
|
67
|
+ #include "LPC1768_Servo.h"
|
|
68
|
+ #include "servo_private.h"
|
72
|
69
|
|
73
|
70
|
extern bool LPC1768_PWM_attach_pin(uint8_t, uint32_t, uint32_t, uint8_t);
|
74
|
71
|
extern bool LPC1768_PWM_write(uint8_t, uint32_t);
|
75
|
72
|
extern bool LPC1768_PWM_detach_pin(uint8_t);
|
76
|
73
|
|
77
|
|
-
|
78
|
|
-
|
79
|
74
|
ServoInfo_t servo_info[MAX_SERVOS]; // static array of servo info structures
|
80
|
75
|
uint8_t ServoCount = 0; // the total number of attached servos
|
81
|
76
|
|
82
|
|
-
|
83
|
77
|
#define US_TO_PULSE_WIDTH(p) p
|
84
|
78
|
#define PULSE_WIDTH_TO_US(p) p
|
85
|
79
|
#define TRIM_DURATION 0
|
|
@@ -107,7 +101,6 @@
|
107
|
101
|
// greater than zero. This way the init routine can
|
108
|
102
|
// assign the pin and the MOVE command only needs the value.
|
109
|
103
|
|
110
|
|
-
|
111
|
104
|
this->min = MIN_PULSE_WIDTH; //resolution of min/max is 1 uS
|
112
|
105
|
this->max = MAX_PULSE_WIDTH;
|
113
|
106
|
|
|
@@ -165,7 +158,4 @@
|
165
|
158
|
}
|
166
|
159
|
}
|
167
|
160
|
|
168
|
|
-#endif // HAS_SERVOS
|
169
|
|
-
|
170
|
|
-#endif // TARGET_LPC1768
|
171
|
|
-
|
|
161
|
+#endif // HAS_SERVOS && TARGET_LPC1768
|