|
@@ -74,8 +74,8 @@ block_t* Stepper::current_block = NULL; // A pointer to the block currently bei
|
74
|
74
|
|
75
|
75
|
// private:
|
76
|
76
|
|
77
|
|
-unsigned char Stepper::last_direction_bits = 0; // The next stepping-bits to be output
|
78
|
|
-unsigned int Stepper::cleaning_buffer_counter = 0;
|
|
77
|
+uint8_t Stepper::last_direction_bits = 0; // The next stepping-bits to be output
|
|
78
|
+uint16_t Stepper::cleaning_buffer_counter = 0;
|
79
|
79
|
|
80
|
80
|
#if ENABLED(Z_DUAL_ENDSTOPS)
|
81
|
81
|
bool Stepper::locked_z_motor = false;
|
|
@@ -1447,11 +1447,11 @@ void Stepper::report_positions() {
|
1447
|
1447
|
#if HAS_DIGIPOTSS
|
1448
|
1448
|
|
1449
|
1449
|
// From Arduino DigitalPotControl example
|
1450
|
|
- void Stepper::digitalPotWrite(int address, int value) {
|
1451
|
|
- WRITE(DIGIPOTSS_PIN, LOW); // take the SS pin low to select the chip
|
1452
|
|
- SPI.transfer(address); // send in the address and value via SPI:
|
|
1450
|
+ void Stepper::digitalPotWrite(const int16_t address, const int16_t value) {
|
|
1451
|
+ WRITE(DIGIPOTSS_PIN, LOW); // Take the SS pin low to select the chip
|
|
1452
|
+ SPI.transfer(address); // Send the address and value via SPI
|
1453
|
1453
|
SPI.transfer(value);
|
1454
|
|
- WRITE(DIGIPOTSS_PIN, HIGH); // take the SS pin high to de-select the chip:
|
|
1454
|
+ WRITE(DIGIPOTSS_PIN, HIGH); // Take the SS pin high to de-select the chip
|
1455
|
1455
|
//delay(10);
|
1456
|
1456
|
}
|
1457
|
1457
|
|
|
@@ -1486,21 +1486,24 @@ void Stepper::report_positions() {
|
1486
|
1486
|
#endif
|
1487
|
1487
|
}
|
1488
|
1488
|
|
1489
|
|
- void Stepper::digipot_current(uint8_t driver, int current) {
|
|
1489
|
+ void Stepper::digipot_current(const uint8_t driver, const int current) {
|
|
1490
|
+
|
1490
|
1491
|
#if HAS_DIGIPOTSS
|
|
1492
|
+
|
1491
|
1493
|
const uint8_t digipot_ch[] = DIGIPOT_CHANNELS;
|
1492
|
1494
|
digitalPotWrite(digipot_ch[driver], current);
|
|
1495
|
+
|
1493
|
1496
|
#elif HAS_MOTOR_CURRENT_PWM
|
1494
|
|
- #define _WRITE_CURRENT_PWM(P) analogWrite(P, 255L * current / (MOTOR_CURRENT_PWM_RANGE))
|
|
1497
|
+ #define _WRITE_CURRENT_PWM(P) analogWrite(MOTOR_CURRENT_PWM_## P ##_PIN, 255L * current / (MOTOR_CURRENT_PWM_RANGE))
|
1495
|
1498
|
switch (driver) {
|
1496
|
1499
|
#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
|
1497
|
|
- case 0: _WRITE_CURRENT_PWM(MOTOR_CURRENT_PWM_XY_PIN); break;
|
|
1500
|
+ case 0: _WRITE_CURRENT_PWM(XY); break;
|
1498
|
1501
|
#endif
|
1499
|
1502
|
#if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
|
1500
|
|
- case 1: _WRITE_CURRENT_PWM(MOTOR_CURRENT_PWM_Z_PIN); break;
|
|
1503
|
+ case 1: _WRITE_CURRENT_PWM(Z); break;
|
1501
|
1504
|
#endif
|
1502
|
1505
|
#if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
|
1503
|
|
- case 2: _WRITE_CURRENT_PWM(MOTOR_CURRENT_PWM_E_PIN); break;
|
|
1506
|
+ case 2: _WRITE_CURRENT_PWM(E); break;
|
1504
|
1507
|
#endif
|
1505
|
1508
|
}
|
1506
|
1509
|
#endif
|
|
@@ -1550,7 +1553,7 @@ void Stepper::report_positions() {
|
1550
|
1553
|
microstep_mode(i, microstep_modes[i]);
|
1551
|
1554
|
}
|
1552
|
1555
|
|
1553
|
|
- void Stepper::microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2) {
|
|
1556
|
+ void Stepper::microstep_ms(const uint8_t driver, const int8_t ms1, const int8_t ms2) {
|
1554
|
1557
|
if (ms1 >= 0) switch (driver) {
|
1555
|
1558
|
case 0: WRITE(X_MS1_PIN, ms1); break;
|
1556
|
1559
|
#if HAS_Y_MICROSTEPS
|
|
@@ -1601,7 +1604,7 @@ void Stepper::report_positions() {
|
1601
|
1604
|
}
|
1602
|
1605
|
}
|
1603
|
1606
|
|
1604
|
|
- void Stepper::microstep_mode(uint8_t driver, uint8_t stepping_mode) {
|
|
1607
|
+ void Stepper::microstep_mode(const uint8_t driver, const uint8_t stepping_mode) {
|
1605
|
1608
|
switch (stepping_mode) {
|
1606
|
1609
|
case 1: microstep_ms(driver, MICROSTEP1); break;
|
1607
|
1610
|
case 2: microstep_ms(driver, MICROSTEP2); break;
|