diff --git a/Marlin/G26_Mesh_Validation_Tool.cpp b/Marlin/G26_Mesh_Validation_Tool.cpp index ffcad389f2..9b1d4b5ad1 100644 --- a/Marlin/G26_Mesh_Validation_Tool.cpp +++ b/Marlin/G26_Mesh_Validation_Tool.cpp @@ -134,14 +134,14 @@ extern char lcd_status_message[]; #endif extern float destination[XYZE]; - void set_destination_to_current(); + extern void set_destination_to_current() { COPY(destination, current_position); } void prepare_move_to_destination(); #if AVR_AT90USB1286_FAMILY // Teensyduino & Printrboard IDE extensions have compile errors without this inline void sync_plan_position_e() { planner.set_e_position_mm(current_position[E_AXIS]); } inline void set_current_to_destination() { COPY(current_position, destination); } #else - void sync_plan_position_e(); - void set_current_to_destination(); + extern void sync_plan_position_e() { planner.set_e_position_mm(current_position[E_AXIS]); } + extern void set_current_to_destination() { COPY(current_position, destination); } #endif #if ENABLED(NEWPANEL) void lcd_setstatusPGM(const char* const message, const int8_t level); diff --git a/Marlin/src/HAL/HAL_LPC1768/arduino.cpp b/Marlin/src/HAL/HAL_LPC1768/arduino.cpp index d24482b751..6a13448343 100644 --- a/Marlin/src/HAL/HAL_LPC1768/arduino.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/arduino.cpp @@ -140,17 +140,27 @@ bool digitalRead(int pin) { return LPC_GPIO(pin_map[pin].port)->FIOPIN & LPC_PIN(pin_map[pin].pin) ? 1 : 0; } -void analogWrite(int pin, int pin_status) { //todo: Hardware PWM - /* - if (pin == P2_4) { - LPC_PWM1->MR5 = pin_status; // set value - LPC_PWM1->LER = _BV(5); // set latch +void analogWrite(int pin, int pwm_value) { +/* + if (!WITHIN(pin, 0, NUM_DIGITAL_PINS - 1) || pin_map[pin].port == 0xFF) + return; + + int old_pin = pin; + int old_value = pwm_value; + + if(old_value != 0) { + for(uint16_t x = 0; x <= 5000; x++) { + LPC_GPIO(pin_map[pin].port)->FIOSET = LPC_PIN(pin_map[pin].pin); + //digitalWrite(old_pin, HIGH); + delayMicroseconds(old_value); + LPC_GPIO(pin_map[pin].port)->FIOCLR = LPC_PIN(pin_map[pin].pin); + //pinMode(pin, OUTPUT); + //digitalWrite(old_pin, LOW); + delayMicroseconds(255 - old_value); + } } - else if (pin == P2_5) { - LPC_PWM1->MR6 = pin_status; - LPC_PWM1->LER = _BV(6); - } - */ +*/ + } extern bool HAL_adc_finished(); @@ -175,7 +185,6 @@ void eeprom_read_block (void *__dst, const void *__src, size_t __n) { } void eeprom_update_block (const void *__src, void *__dst, size_t __n) { } -/***/ char *dtostrf (double __val, signed char __width, unsigned char __prec, char *__s) { char format_string[20]; snprintf(format_string, 20, "%%%d.%df", __width, __prec); @@ -195,4 +204,8 @@ void randomSeed(uint32_t value) { srand(value); } +int map(uint16_t x, uint16_t in_min, uint16_t in_max, uint16_t out_min, uint16_t out_max) { + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; +} + #endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/HAL_LPC1768/arduino.h b/Marlin/src/HAL/HAL_LPC1768/arduino.h index e5a749d99c..a8a67d5c77 100644 --- a/Marlin/src/HAL/HAL_LPC1768/arduino.h +++ b/Marlin/src/HAL/HAL_LPC1768/arduino.h @@ -112,4 +112,6 @@ void randomSeed(uint32_t); char *dtostrf (double __val, signed char __width, unsigned char __prec, char *__s); +int map(uint16_t x, uint16_t in_min, uint16_t in_max, uint16_t out_min, uint16_t out_max); + #endif // __ARDUINO_DEF_H__