servo update

2.0.x
Christopher Pepper 6 years ago
parent 870bfd08f5
commit 254b68fe2c

@ -315,4 +315,4 @@ __attribute__((naked)) void RSTC_Handler(void) {
);
}
}
#endif // ARDUINO_ARCH_SAM
#endif // TARGET_LPC1768

@ -151,6 +151,8 @@ using FilteredADC = LPC176x::ADC<ADC_LOWPASS_K_VALUE, ADC_MEDIAN_FILTER_SIZE>;
// Parse a G-code word into a pin index
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval);
// P0.6 thru P0.9 are for the onboard SD card
#define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09
#define HAL_IDLETASK 1
void HAL_idletask(void);

@ -50,25 +50,24 @@
#ifndef SERVO_PRIVATE_H
#define SERVO_PRIVATE_H
#include <LPC1768_Servo.h>
#include <Servo.h>
class MarlinServo: public Servo {
public:
void move(const int value) {
constexpr uint16_t servo_delay[] = SERVO_DELAY;
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
if (this->attach(0) >= 0) { // notice the pin number is zero here
this->write(value);
safe_delay(servo_delay[this->servoIndex]);
if (this->attach(servo_info[this->servoIndex].Pin.nbr) >= 0) { // try to reattach
this->write(value);
safe_delay(servo_delay[this->servoIndex]); // delay to allow servo to reach position
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach();
LPC1768_PWM_detach_pin(servo_info[this->servoIndex].Pin.nbr); // shut down the PWM signal
LPC1768_PWM_attach_pin(servo_info[this->servoIndex].Pin.nbr, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH, this->servoIndex); // make sure no one else steals the slot
#endif
}
}
}
};
#define HAL_SERVO_LIB MarlinServo

@ -1,6 +1,5 @@
#ifdef TARGET_LPC1768
#include <LPC1768_PWM.h>
#include <usb/usb.h>
#include <usb/usbcfg.h>
#include <usb/usbhw.h>
@ -84,7 +83,6 @@ void HAL_init() {
#endif
HAL_timer_init();
LPC1768_PWM_init();
}
// HAL idle task

@ -50,7 +50,7 @@
#ifndef SS_PIN
#define SS_PIN P1_23
#endif
#if !defined(SDSS) || SDSS == P_NC // get defaulted in pins.h
#if !defined(SDSS) || SDSS == P_NC // gets defaulted in pins.h
#undef SDSS
#define SDSS SS_PIN
#endif

@ -73,7 +73,7 @@
#elif IS_TEENSY35 || IS_TEENSY36
#include "../HAL_TEENSY35_36/HAL_Servo_Teensy.h"
#elif defined(TARGET_LPC1768)
#include "../HAL_LPC1768/servo_private.h"
#include "../HAL_LPC1768/MarlinServo.h"
#elif defined(__STM32F1__) || defined(TARGET_STM32F1)
#include "../HAL_STM32F1/HAL_Servo_STM32F1.h"
#elif defined(STM32GENERIC) && defined(STM32F4)

@ -27,6 +27,7 @@
#ifndef _SERVO_H_
#define _SERVO_H_
#include "../inc/MarlinConfig.h"
#include "../HAL/shared/servo.h"
extern HAL_SERVO_LIB servo[NUM_SERVOS];
@ -35,8 +36,6 @@ extern void servo_init();
#define MOVE_SERVO(I, P) servo[I].move(P)
#include "../inc/MarlinConfig.h"
#if HAS_Z_SERVO_PROBE
#define DEPLOY_Z_SERVO() MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][0])
#define STOW_Z_SERVO() MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][1])

Loading…
Cancel
Save