|
@@ -81,6 +81,10 @@
|
81
|
81
|
|
82
|
82
|
Stepper stepper; // Singleton
|
83
|
83
|
|
|
84
|
+#if HAS_MOTOR_CURRENT_PWM
|
|
85
|
+ bool Stepper::initialized; // = false
|
|
86
|
+#endif
|
|
87
|
+
|
84
|
88
|
#ifdef __AVR__
|
85
|
89
|
#include "speed_lookuptable.h"
|
86
|
90
|
#endif
|
|
@@ -2161,6 +2165,9 @@ void Stepper::init() {
|
2161
|
2165
|
| (INVERT_Z_DIR ? _BV(Z_AXIS) : 0);
|
2162
|
2166
|
|
2163
|
2167
|
set_directions();
|
|
2168
|
+ #if HAS_MOTOR_CURRENT_PWM
|
|
2169
|
+ initialized = true;
|
|
2170
|
+ #endif
|
2164
|
2171
|
}
|
2165
|
2172
|
|
2166
|
2173
|
/**
|
|
@@ -2466,6 +2473,7 @@ void Stepper::report_positions() {
|
2466
|
2473
|
#if HAS_MOTOR_CURRENT_PWM
|
2467
|
2474
|
|
2468
|
2475
|
void Stepper::refresh_motor_power() {
|
|
2476
|
+ if (!initialized) return;
|
2469
|
2477
|
LOOP_L_N(i, COUNT(motor_current_setting)) {
|
2470
|
2478
|
switch (i) {
|
2471
|
2479
|
#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) || PIN_EXISTS(MOTOR_CURRENT_PWM_X) || PIN_EXISTS(MOTOR_CURRENT_PWM_Y)
|
|
@@ -2498,6 +2506,8 @@ void Stepper::report_positions() {
|
2498
|
2506
|
|
2499
|
2507
|
#elif HAS_MOTOR_CURRENT_PWM
|
2500
|
2508
|
|
|
2509
|
+ if (!initialized) return;
|
|
2510
|
+
|
2501
|
2511
|
if (WITHIN(driver, 0, COUNT(motor_current_setting) - 1))
|
2502
|
2512
|
motor_current_setting[driver] = current; // update motor_current_setting
|
2503
|
2513
|
|