瀏覽代碼

Feature file updates

Scott Lahteine 6 年之前
父節點
當前提交
4a82e95c3e

+ 897
- 898
Marlin/src/feature/I2CPositionEncoder.cpp
文件差異過大導致無法顯示
查看文件


+ 76
- 80
Marlin/src/feature/I2CPositionEncoder.h 查看文件

@@ -23,88 +23,85 @@
23 23
 #ifndef I2CPOSENC_H
24 24
 #define I2CPOSENC_H
25 25
 
26
-#include "MarlinConfig.h"
26
+#include "../inc/MarlinConfig.h"
27 27
 
28
-#if ENABLED(I2C_POSITION_ENCODERS)
28
+#include "../module/planner.h"
29 29
 
30
-  #include "enum.h"
31
-  #include "macros.h"
32
-  #include "types.h"
33
-  #include <Wire.h>
30
+#include <Wire.h>
34 31
 
35
-  //=========== Advanced / Less-Common Encoder Configuration Settings ==========
32
+//=========== Advanced / Less-Common Encoder Configuration Settings ==========
36 33
 
37
-  #define I2CPE_EC_THRESH_PROPORTIONAL                    // if enabled adjusts the error correction threshold
38
-                                                          // proportional to the current speed of the axis allows
39
-                                                          // for very small error margin at low speeds without
40
-                                                          // stuttering due to reading latency at high speeds
34
+#define I2CPE_EC_THRESH_PROPORTIONAL                    // if enabled adjusts the error correction threshold
35
+                                                        // proportional to the current speed of the axis allows
36
+                                                        // for very small error margin at low speeds without
37
+                                                        // stuttering due to reading latency at high speeds
41 38
 
42
-  #define I2CPE_DEBUG                                     // enable encoder-related debug serial echos
39
+#define I2CPE_DEBUG                                     // enable encoder-related debug serial echos
43 40
 
44
-  #define I2CPE_REBOOT_TIME             5000              // time we wait for an encoder module to reboot
45
-                                                          // after changing address.
41
+#define I2CPE_REBOOT_TIME             5000              // time we wait for an encoder module to reboot
42
+                                                        // after changing address.
46 43
 
47
-  #define I2CPE_MAG_SIG_GOOD            0
48
-  #define I2CPE_MAG_SIG_MID             1
49
-  #define I2CPE_MAG_SIG_BAD             2
50
-  #define I2CPE_MAG_SIG_NF              255
44
+#define I2CPE_MAG_SIG_GOOD            0
45
+#define I2CPE_MAG_SIG_MID             1
46
+#define I2CPE_MAG_SIG_BAD             2
47
+#define I2CPE_MAG_SIG_NF              255
51 48
 
52
-  #define I2CPE_REQ_REPORT              0
53
-  #define I2CPE_RESET_COUNT             1
54
-  #define I2CPE_SET_ADDR                2
55
-  #define I2CPE_SET_REPORT_MODE         3
56
-  #define I2CPE_CLEAR_EEPROM            4
49
+#define I2CPE_REQ_REPORT              0
50
+#define I2CPE_RESET_COUNT             1
51
+#define I2CPE_SET_ADDR                2
52
+#define I2CPE_SET_REPORT_MODE         3
53
+#define I2CPE_CLEAR_EEPROM            4
57 54
 
58
-  #define I2CPE_LED_PAR_MODE            10
59
-  #define I2CPE_LED_PAR_BRT             11
60
-  #define I2CPE_LED_PAR_RATE            14
55
+#define I2CPE_LED_PAR_MODE            10
56
+#define I2CPE_LED_PAR_BRT             11
57
+#define I2CPE_LED_PAR_RATE            14
61 58
 
62
-  #define I2CPE_REPORT_DISTANCE         0
63
-  #define I2CPE_REPORT_STRENGTH         1
64
-  #define I2CPE_REPORT_VERSION          2
59
+#define I2CPE_REPORT_DISTANCE         0
60
+#define I2CPE_REPORT_STRENGTH         1
61
+#define I2CPE_REPORT_VERSION          2
65 62
 
66
-  // Default I2C addresses
67
-  #define I2CPE_PRESET_ADDR_X           30
68
-  #define I2CPE_PRESET_ADDR_Y           31
69
-  #define I2CPE_PRESET_ADDR_Z           32
70
-  #define I2CPE_PRESET_ADDR_E           33
63
+// Default I2C addresses
64
+#define I2CPE_PRESET_ADDR_X           30
65
+#define I2CPE_PRESET_ADDR_Y           31
66
+#define I2CPE_PRESET_ADDR_Z           32
67
+#define I2CPE_PRESET_ADDR_E           33
71 68
 
72
-  #define I2CPE_DEF_AXIS                X_AXIS
73
-  #define I2CPE_DEF_ADDR                I2CPE_PRESET_ADDR_X
69
+#define I2CPE_DEF_AXIS                X_AXIS
70
+#define I2CPE_DEF_ADDR                I2CPE_PRESET_ADDR_X
74 71
 
75
-  // Error event counter; tracks how many times there is an error exceeding a certain threshold
76
-  #define I2CPE_ERR_CNT_THRESH          3.00
77
-  #define I2CPE_ERR_CNT_DEBOUNCE_MS     2000
72
+// Error event counter; tracks how many times there is an error exceeding a certain threshold
73
+#define I2CPE_ERR_CNT_THRESH          3.00
74
+#define I2CPE_ERR_CNT_DEBOUNCE_MS     2000
78 75
 
79
-  #if ENABLED(I2CPE_ERR_ROLLING_AVERAGE)
80
-    #define I2CPE_ERR_ARRAY_SIZE        32
81
-  #endif
76
+#if ENABLED(I2CPE_ERR_ROLLING_AVERAGE)
77
+  #define I2CPE_ERR_ARRAY_SIZE        32
78
+#endif
82 79
 
83
-  // Error Correction Methods
84
-  #define I2CPE_ECM_NONE                0
85
-  #define I2CPE_ECM_MICROSTEP           1
86
-  #define I2CPE_ECM_PLANNER             2
87
-  #define I2CPE_ECM_STALLDETECT         3
80
+// Error Correction Methods
81
+#define I2CPE_ECM_NONE                0
82
+#define I2CPE_ECM_MICROSTEP           1
83
+#define I2CPE_ECM_PLANNER             2
84
+#define I2CPE_ECM_STALLDETECT         3
88 85
 
89
-  // Encoder types
90
-  #define I2CPE_ENC_TYPE_ROTARY         0
91
-  #define I2CPE_ENC_TYPE_LINEAR         1
86
+// Encoder types
87
+#define I2CPE_ENC_TYPE_ROTARY         0
88
+#define I2CPE_ENC_TYPE_LINEAR         1
92 89
 
93
-  // Parser
94
-  #define I2CPE_PARSE_ERR               1
95
-  #define I2CPE_PARSE_OK                0
90
+// Parser
91
+#define I2CPE_PARSE_ERR               1
92
+#define I2CPE_PARSE_OK                0
96 93
 
97
-  #define LOOP_PE(VAR) LOOP_L_N(VAR, I2CPE_ENCODER_CNT)
98
-  #define CHECK_IDX() do{ if (!WITHIN(idx, 0, I2CPE_ENCODER_CNT - 1)) return; }while(0)
94
+#define LOOP_PE(VAR) LOOP_L_N(VAR, I2CPE_ENCODER_CNT)
95
+#define CHECK_IDX() do{ if (!WITHIN(idx, 0, I2CPE_ENCODER_CNT - 1)) return; }while(0)
99 96
 
100
-  extern const char axis_codes[XYZE];
97
+extern const char axis_codes[XYZE];
101 98
 
102
-  typedef union {
103
-    volatile int32_t val = 0;
104
-    uint8_t          bval[4];
105
-  } i2cLong;
99
+typedef union {
100
+  volatile int32_t val = 0;
101
+  uint8_t          bval[4];
102
+} i2cLong;
106 103
 
107
-  class I2CPositionEncoder {
104
+class I2CPositionEncoder {
108 105
   private:
109 106
     AxisEnum  encoderAxis         = I2CPE_DEF_AXIS;
110 107
 
@@ -229,9 +226,9 @@
229 226
     FORCE_INLINE void set_current_position(const float newPositionMm) {
230 227
       set_axis_offset(get_position_mm() - newPositionMm + axisOffset);
231 228
     }
232
-  };
229
+};
233 230
 
234
-  class I2CPositionEncodersMgr {
231
+class I2CPositionEncodersMgr {
235 232
   private:
236 233
     static bool I2CPE_anyaxis;
237 234
     static uint8_t I2CPE_addr, I2CPE_idx;
@@ -252,7 +249,7 @@
252 249
 
253 250
     static void report_status(const int8_t idx) {
254 251
       CHECK_IDX();
255
-      SERIAL_ECHOPAIR("Encoder ",idx);
252
+      SERIAL_ECHOPAIR("Encoder ", idx);
256 253
       SERIAL_ECHOPGM(": ");
257 254
       encoders[idx].get_raw_count();
258 255
       encoders[idx].passes_test(true);
@@ -340,20 +337,19 @@
340 337
     static void M869();
341 338
 
342 339
     static I2CPositionEncoder encoders[I2CPE_ENCODER_CNT];
343
-  };
344
-
345
-  extern I2CPositionEncodersMgr I2CPEM;
346
-
347
-  FORCE_INLINE static void gcode_M860() { I2CPEM.M860(); }
348
-  FORCE_INLINE static void gcode_M861() { I2CPEM.M861(); }
349
-  FORCE_INLINE static void gcode_M862() { I2CPEM.M862(); }
350
-  FORCE_INLINE static void gcode_M863() { I2CPEM.M863(); }
351
-  FORCE_INLINE static void gcode_M864() { I2CPEM.M864(); }
352
-  FORCE_INLINE static void gcode_M865() { I2CPEM.M865(); }
353
-  FORCE_INLINE static void gcode_M866() { I2CPEM.M866(); }
354
-  FORCE_INLINE static void gcode_M867() { I2CPEM.M867(); }
355
-  FORCE_INLINE static void gcode_M868() { I2CPEM.M868(); }
356
-  FORCE_INLINE static void gcode_M869() { I2CPEM.M869(); }
357
-
358
-#endif //I2C_POSITION_ENCODERS
340
+};
341
+
342
+extern I2CPositionEncodersMgr I2CPEM;
343
+
344
+FORCE_INLINE static void gcode_M860() { I2CPEM.M860(); }
345
+FORCE_INLINE static void gcode_M861() { I2CPEM.M861(); }
346
+FORCE_INLINE static void gcode_M862() { I2CPEM.M862(); }
347
+FORCE_INLINE static void gcode_M863() { I2CPEM.M863(); }
348
+FORCE_INLINE static void gcode_M864() { I2CPEM.M864(); }
349
+FORCE_INLINE static void gcode_M865() { I2CPEM.M865(); }
350
+FORCE_INLINE static void gcode_M866() { I2CPEM.M866(); }
351
+FORCE_INLINE static void gcode_M867() { I2CPEM.M867(); }
352
+FORCE_INLINE static void gcode_M868() { I2CPEM.M868(); }
353
+FORCE_INLINE static void gcode_M869() { I2CPEM.M869(); }
354
+
359 355
 #endif //I2CPOSENC_H

+ 90
- 86
Marlin/src/feature/dac/dac_dac084s085.cpp 查看文件

@@ -3,106 +3,110 @@
3 3
  * External DAC for Alligator Board
4 4
  *
5 5
  ****************************************************************/
6
-#include "Marlin.h"
7 6
 
8
-#if MB(ALLIGATOR)
9
-  #include "stepper.h"
10
-  #include "dac_dac084s085.h"
7
+#include "../../inc/MarlinConfig.h"
11 8
 
12
-  dac084s085::dac084s085() {
13
-    return ;
14
-  }
9
+#if MB(ALLIGATOR)
15 10
 
16
-  void dac084s085::begin() {
17
-    uint8_t externalDac_buf[2] = {0x20,0x00};//all off
18
-
19
-    // All SPI chip-select HIGH
20
-    pinMode(DAC0_SYNC, OUTPUT);
21
-    digitalWrite( DAC0_SYNC , HIGH );
22
-    #if EXTRUDERS > 1
23
-      pinMode(DAC1_SYNC, OUTPUT);
24
-      digitalWrite( DAC1_SYNC , HIGH );
25
-    #endif
26
-    digitalWrite( SPI_EEPROM1_CS , HIGH );
27
-    digitalWrite( SPI_EEPROM2_CS , HIGH );
28
-    digitalWrite( SPI_FLASH_CS , HIGH );
29
-    digitalWrite( SS_PIN , HIGH );
30
-    spiBegin();
31
-
32
-    //init onboard DAC
11
+#include "dac_dac084s085.h"
12
+
13
+#include "../../Marlin.h"
14
+#include "../../module/stepper.h"
15
+
16
+dac084s085::dac084s085() {
17
+  return ;
18
+}
19
+
20
+void dac084s085::begin() {
21
+  uint8_t externalDac_buf[2] = {0x20,0x00};//all off
22
+
23
+  // All SPI chip-select HIGH
24
+  pinMode(DAC0_SYNC, OUTPUT);
25
+  digitalWrite( DAC0_SYNC , HIGH );
26
+  #if EXTRUDERS > 1
27
+    pinMode(DAC1_SYNC, OUTPUT);
28
+    digitalWrite( DAC1_SYNC , HIGH );
29
+  #endif
30
+  digitalWrite( SPI_EEPROM1_CS , HIGH );
31
+  digitalWrite( SPI_EEPROM2_CS , HIGH );
32
+  digitalWrite( SPI_FLASH_CS , HIGH );
33
+  digitalWrite( SS_PIN , HIGH );
34
+  spiBegin();
35
+
36
+  //init onboard DAC
37
+  delayMicroseconds(2U);
38
+  digitalWrite( DAC0_SYNC , LOW );
39
+  delayMicroseconds(2U);
40
+  digitalWrite( DAC0_SYNC , HIGH );
41
+  delayMicroseconds(2U);
42
+  digitalWrite( DAC0_SYNC , LOW );
43
+
44
+  spiSend(SPI_CHAN_DAC,externalDac_buf , 2);
45
+  digitalWrite( DAC0_SYNC , HIGH );
46
+
47
+  #if EXTRUDERS > 1
48
+    //init Piggy DAC
33 49
     delayMicroseconds(2U);
34
-    digitalWrite( DAC0_SYNC , LOW );
50
+    digitalWrite( DAC1_SYNC , LOW );
35 51
     delayMicroseconds(2U);
36
-    digitalWrite( DAC0_SYNC , HIGH );
52
+    digitalWrite( DAC1_SYNC , HIGH );
37 53
     delayMicroseconds(2U);
38
-    digitalWrite( DAC0_SYNC , LOW );
54
+    digitalWrite( DAC1_SYNC , LOW );
39 55
 
40 56
     spiSend(SPI_CHAN_DAC,externalDac_buf , 2);
41
-    digitalWrite( DAC0_SYNC , HIGH );
57
+    digitalWrite( DAC1_SYNC , HIGH );
58
+  #endif
42 59
 
43
-    #if EXTRUDERS > 1
44
-      //init Piggy DAC
45
-      delayMicroseconds(2U);
46
-      digitalWrite( DAC1_SYNC , LOW );
47
-      delayMicroseconds(2U);
48
-      digitalWrite( DAC1_SYNC , HIGH );
49
-      delayMicroseconds(2U);
50
-      digitalWrite( DAC1_SYNC , LOW );
51
-
52
-      spiSend(SPI_CHAN_DAC,externalDac_buf , 2);
53
-      digitalWrite( DAC1_SYNC , HIGH );
54
-    #endif
60
+  return;
61
+}
55 62
 
63
+void dac084s085::setValue(uint8_t channel, uint8_t value) {
64
+  if(channel >= 7) // max channel (X,Y,Z,E0,E1,E2,E3)
56 65
     return;
66
+  if(value > 255) value = 255;
67
+
68
+  uint8_t externalDac_buf[2] = {0x10,0x00};
69
+
70
+  if(channel > 3)
71
+    externalDac_buf[0] |= (7 - channel << 6);
72
+  else
73
+    externalDac_buf[0] |= (3 - channel << 6);
74
+
75
+  externalDac_buf[0] |= (value >> 4);
76
+  externalDac_buf[1] |= (value << 4);
77
+  
78
+  // All SPI chip-select HIGH
79
+  digitalWrite( DAC0_SYNC , HIGH );
80
+  #if EXTRUDERS > 1
81
+    digitalWrite( DAC1_SYNC , HIGH );
82
+  #endif
83
+  digitalWrite( SPI_EEPROM1_CS , HIGH );
84
+  digitalWrite( SPI_EEPROM2_CS , HIGH );
85
+  digitalWrite( SPI_FLASH_CS , HIGH );
86
+  digitalWrite( SS_PIN , HIGH );
87
+
88
+  if(channel > 3) { // DAC Piggy E1,E2,E3
89
+
90
+    digitalWrite(DAC1_SYNC , LOW);
91
+    delayMicroseconds(2U);
92
+    digitalWrite(DAC1_SYNC , HIGH);
93
+    delayMicroseconds(2U);
94
+    digitalWrite(DAC1_SYNC , LOW);
57 95
   }
58 96
 
59
-  void dac084s085::setValue(uint8_t channel, uint8_t value) {
60
-    if(channel >= 7) // max channel (X,Y,Z,E0,E1,E2,E3)
61
-      return;
62
-    if(value > 255) value = 255;
63
-
64
-    uint8_t externalDac_buf[2] = {0x10,0x00};
65
-
66
-    if(channel > 3)
67
-      externalDac_buf[0] |= (7 - channel << 6);
68
-    else
69
-      externalDac_buf[0] |= (3 - channel << 6);
70
-
71
-    externalDac_buf[0] |= (value >> 4);
72
-    externalDac_buf[1] |= (value << 4);
73
-    
74
-    // All SPI chip-select HIGH
75
-    digitalWrite( DAC0_SYNC , HIGH );
76
-    #if EXTRUDERS > 1
77
-      digitalWrite( DAC1_SYNC , HIGH );
78
-    #endif
79
-    digitalWrite( SPI_EEPROM1_CS , HIGH );
80
-    digitalWrite( SPI_EEPROM2_CS , HIGH );
81
-    digitalWrite( SPI_FLASH_CS , HIGH );
82
-    digitalWrite( SS_PIN , HIGH );
83
-
84
-    if(channel > 3) { // DAC Piggy E1,E2,E3
85
-
86
-      digitalWrite(DAC1_SYNC , LOW);
87
-      delayMicroseconds(2U);
88
-      digitalWrite(DAC1_SYNC , HIGH);
89
-      delayMicroseconds(2U);
90
-      digitalWrite(DAC1_SYNC , LOW);
91
-    }
92
-
93
-    else { // DAC onboard X,Y,Z,E0
94
-
95
-      digitalWrite(DAC0_SYNC , LOW);
96
-      delayMicroseconds(2U);
97
-      digitalWrite(DAC0_SYNC , HIGH);
98
-      delayMicroseconds(2U);
99
-      digitalWrite(DAC0_SYNC , LOW);
100
-    }
97
+  else { // DAC onboard X,Y,Z,E0
101 98
 
99
+    digitalWrite(DAC0_SYNC , LOW);
102 100
     delayMicroseconds(2U);
103
-    spiSend(SPI_CHAN_DAC,externalDac_buf , 2);
104
-
105
-    return;
101
+    digitalWrite(DAC0_SYNC , HIGH);
102
+    delayMicroseconds(2U);
103
+    digitalWrite(DAC0_SYNC , LOW);
106 104
   }
107 105
 
108
-#endif
106
+  delayMicroseconds(2U);
107
+  spiSend(SPI_CHAN_DAC,externalDac_buf , 2);
108
+
109
+  return;
110
+}
111
+
112
+#endif // MB(ALLIGATOR)

+ 3
- 3
Marlin/src/feature/dac/dac_dac084s085.h 查看文件

@@ -1,5 +1,5 @@
1
-#ifndef dac084s085_h
2
-#define dac084s085_h
1
+#ifndef DAC084S085_H
2
+#define DAC084S085_H
3 3
 
4 4
 class dac084s085 {
5 5
   public:
@@ -8,4 +8,4 @@ class dac084s085 {
8 8
     static void setValue(uint8_t channel, uint8_t value);
9 9
 };
10 10
 
11
-#endif //dac084s085_h
11
+#endif // DAC084S085_H

+ 3
- 2
Marlin/src/feature/dac/dac_mcp4728.cpp 查看文件

@@ -30,11 +30,12 @@
30 30
  * http://arduino.cc/forum/index.php/topic,51842.0.html
31 31
  */
32 32
 
33
-#include "dac_mcp4728.h"
34
-#include "enum.h"
33
+#include "../../inc/MarlinConfig.h"
35 34
 
36 35
 #if ENABLED(DAC_STEPPER_CURRENT)
37 36
 
37
+#include "dac_mcp4728.h"
38
+
38 39
 uint16_t mcp4728_values[XYZE];
39 40
 
40 41
 /**

+ 1
- 6
Marlin/src/feature/dac/dac_mcp4728.h 查看文件

@@ -27,10 +27,7 @@
27 27
 #ifndef DAC_MCP4728_H
28 28
 #define DAC_MCP4728_H
29 29
 
30
-#include "MarlinConfig.h"
31
-
32
-#if ENABLED(DAC_STEPPER_CURRENT)
33
-#include "Wire.h"
30
+#include <Wire.h>
34 31
 
35 32
 #define defaultVDD     DAC_STEPPER_MAX //was 5000 but differs with internal Vref
36 33
 #define BASE_ADDR      0x60
@@ -50,7 +47,6 @@
50 47
 // DAC_OR_ADDRESS defined in pins_BOARD.h  file
51 48
 #define DAC_DEV_ADDRESS (BASE_ADDR | DAC_OR_ADDRESS)
52 49
 
53
-
54 50
 void mcp4728_init();
55 51
 uint8_t mcp4728_analogWrite(uint8_t channel, uint16_t value);
56 52
 uint8_t mcp4728_eepromWrite();
@@ -62,5 +58,4 @@ uint8_t mcp4728_simpleCommand(byte simpleCommand);
62 58
 uint8_t mcp4728_getDrvPct(uint8_t channel);
63 59
 void mcp4728_setDrvPct(uint8_t pct[XYZE]);
64 60
 
65
-#endif
66 61
 #endif // DAC_MCP4728_H

+ 67
- 67
Marlin/src/feature/dac/stepper_dac.cpp 查看文件

@@ -41,85 +41,85 @@
41 41
   along with Marlin.  If not, see <http://www.gnu.org/licenses/>.
42 42
 */
43 43
 
44
-#include "Marlin.h"
44
+#include "../../inc/MarlinConfig.h"
45 45
 
46 46
 #if ENABLED(DAC_STEPPER_CURRENT)
47 47
 
48
-  #include "stepper_dac.h"
48
+#include "stepper_dac.h"
49 49
 
50
-  bool dac_present = false;
51
-  const uint8_t dac_order[NUM_AXIS] = DAC_STEPPER_ORDER;
52
-  uint8_t dac_channel_pct[XYZE] = DAC_MOTOR_CURRENT_DEFAULT;
50
+bool dac_present = false;
51
+const uint8_t dac_order[NUM_AXIS] = DAC_STEPPER_ORDER;
52
+uint8_t dac_channel_pct[XYZE] = DAC_MOTOR_CURRENT_DEFAULT;
53 53
 
54
-  int dac_init() {
55
-    #if PIN_EXISTS(DAC_DISABLE)
56
-      OUT_WRITE(DAC_DISABLE_PIN, LOW);  // set pin low to enable DAC
57
-    #endif
54
+int dac_init() {
55
+  #if PIN_EXISTS(DAC_DISABLE)
56
+    OUT_WRITE(DAC_DISABLE_PIN, LOW);  // set pin low to enable DAC
57
+  #endif
58 58
 
59
-    mcp4728_init();
59
+  mcp4728_init();
60 60
 
61
-    if (mcp4728_simpleCommand(RESET)) return -1;
61
+  if (mcp4728_simpleCommand(RESET)) return -1;
62 62
 
63
-    dac_present = true;
63
+  dac_present = true;
64 64
 
65
-    mcp4728_setVref_all(DAC_STEPPER_VREF);
66
-    mcp4728_setGain_all(DAC_STEPPER_GAIN);
65
+  mcp4728_setVref_all(DAC_STEPPER_VREF);
66
+  mcp4728_setGain_all(DAC_STEPPER_GAIN);
67 67
 
68
-    if (mcp4728_getDrvPct(0) < 1 || mcp4728_getDrvPct(1) < 1 || mcp4728_getDrvPct(2) < 1 || mcp4728_getDrvPct(3) < 1 ) {
69
-      mcp4728_setDrvPct(dac_channel_pct);
70
-      mcp4728_eepromWrite();
71
-    }
72
-
73
-    return 0;
74
-  }
75
-
76
-  void dac_current_percent(uint8_t channel, float val) {
77
-    if (!dac_present) return;
78
-
79
-    NOMORE(val, 100);
80
-
81
-    mcp4728_analogWrite(dac_order[channel], val * 0.01 * (DAC_STEPPER_MAX));
82
-    mcp4728_simpleCommand(UPDATE);
83
-  }
84
-
85
-  void dac_current_raw(uint8_t channel, uint16_t val) {
86
-    if (!dac_present) return;
87
-
88
-    NOMORE(val, DAC_STEPPER_MAX);
89
-
90
-    mcp4728_analogWrite(dac_order[channel], val);
91
-    mcp4728_simpleCommand(UPDATE);
92
-  }
93
-
94
-  static float dac_perc(int8_t n) { return 100.0 * mcp4728_getValue(dac_order[n]) * (1.0 / (DAC_STEPPER_MAX)); }
95
-  static float dac_amps(int8_t n) { return mcp4728_getDrvPct(dac_order[n]) * (DAC_STEPPER_MAX) * 0.125 * (1.0 / (DAC_STEPPER_SENSE)); }
96
-
97
-  uint8_t dac_current_get_percent(AxisEnum axis) { return mcp4728_getDrvPct(dac_order[axis]); }
98
-  void dac_current_set_percents(const uint8_t pct[XYZE]) {
99
-    LOOP_XYZE(i) dac_channel_pct[i] = pct[dac_order[i]];
68
+  if (mcp4728_getDrvPct(0) < 1 || mcp4728_getDrvPct(1) < 1 || mcp4728_getDrvPct(2) < 1 || mcp4728_getDrvPct(3) < 1 ) {
100 69
     mcp4728_setDrvPct(dac_channel_pct);
101
-  }
102
-
103
-  void dac_print_values() {
104
-    if (!dac_present) return;
105
-
106
-    SERIAL_ECHO_START();
107
-    SERIAL_ECHOLNPGM("Stepper current values in % (Amps):");
108
-    SERIAL_ECHO_START();
109
-    SERIAL_ECHOPAIR(" X:",  dac_perc(X_AXIS));
110
-    SERIAL_ECHOPAIR(" (",   dac_amps(X_AXIS));
111
-    SERIAL_ECHOPAIR(") Y:", dac_perc(Y_AXIS));
112
-    SERIAL_ECHOPAIR(" (",   dac_amps(Y_AXIS));
113
-    SERIAL_ECHOPAIR(") Z:", dac_perc(Z_AXIS));
114
-    SERIAL_ECHOPAIR(" (",   dac_amps(Z_AXIS));
115
-    SERIAL_ECHOPAIR(") E:", dac_perc(E_AXIS));
116
-    SERIAL_ECHOPAIR(" (",   dac_amps(E_AXIS));
117
-    SERIAL_ECHOLN(")");
118
-  }
119
-
120
-  void dac_commit_eeprom() {
121
-    if (!dac_present) return;
122 70
     mcp4728_eepromWrite();
123 71
   }
124 72
 
73
+  return 0;
74
+}
75
+
76
+void dac_current_percent(uint8_t channel, float val) {
77
+  if (!dac_present) return;
78
+
79
+  NOMORE(val, 100);
80
+
81
+  mcp4728_analogWrite(dac_order[channel], val * 0.01 * (DAC_STEPPER_MAX));
82
+  mcp4728_simpleCommand(UPDATE);
83
+}
84
+
85
+void dac_current_raw(uint8_t channel, uint16_t val) {
86
+  if (!dac_present) return;
87
+
88
+  NOMORE(val, DAC_STEPPER_MAX);
89
+
90
+  mcp4728_analogWrite(dac_order[channel], val);
91
+  mcp4728_simpleCommand(UPDATE);
92
+}
93
+
94
+static float dac_perc(int8_t n) { return 100.0 * mcp4728_getValue(dac_order[n]) * (1.0 / (DAC_STEPPER_MAX)); }
95
+static float dac_amps(int8_t n) { return mcp4728_getDrvPct(dac_order[n]) * (DAC_STEPPER_MAX) * 0.125 * (1.0 / (DAC_STEPPER_SENSE)); }
96
+
97
+uint8_t dac_current_get_percent(AxisEnum axis) { return mcp4728_getDrvPct(dac_order[axis]); }
98
+void dac_current_set_percents(const uint8_t pct[XYZE]) {
99
+  LOOP_XYZE(i) dac_channel_pct[i] = pct[dac_order[i]];
100
+  mcp4728_setDrvPct(dac_channel_pct);
101
+}
102
+
103
+void dac_print_values() {
104
+  if (!dac_present) return;
105
+
106
+  SERIAL_ECHO_START();
107
+  SERIAL_ECHOLNPGM("Stepper current values in % (Amps):");
108
+  SERIAL_ECHO_START();
109
+  SERIAL_ECHOPAIR(" X:",  dac_perc(X_AXIS));
110
+  SERIAL_ECHOPAIR(" (",   dac_amps(X_AXIS));
111
+  SERIAL_ECHOPAIR(") Y:", dac_perc(Y_AXIS));
112
+  SERIAL_ECHOPAIR(" (",   dac_amps(Y_AXIS));
113
+  SERIAL_ECHOPAIR(") Z:", dac_perc(Z_AXIS));
114
+  SERIAL_ECHOPAIR(" (",   dac_amps(Z_AXIS));
115
+  SERIAL_ECHOPAIR(") E:", dac_perc(E_AXIS));
116
+  SERIAL_ECHOPAIR(" (",   dac_amps(E_AXIS));
117
+  SERIAL_ECHOLN(")");
118
+}
119
+
120
+void dac_commit_eeprom() {
121
+  if (!dac_present) return;
122
+  mcp4728_eepromWrite();
123
+}
124
+
125 125
 #endif // DAC_STEPPER_CURRENT

+ 2
- 2
Marlin/src/feature/digipot_mcp4018.cpp 查看文件

@@ -20,11 +20,11 @@
20 20
  *
21 21
  */
22 22
 
23
-#include "MarlinConfig.h"
23
+#include "../inc/MarlinConfig.h"
24 24
 
25 25
 #if ENABLED(DIGIPOT_I2C) && ENABLED(DIGIPOT_MCP4018)
26 26
 
27
-#include "enum.h"
27
+#include "../core/enum.h"
28 28
 #include "Stream.h"
29 29
 #include "utility/twi.h"
30 30
 #include <SlowSoftI2CMaster.h>  //https://github.com/stawel/SlowSoftI2CMaster

+ 1
- 1
Marlin/src/feature/digipot_mcp4451.cpp 查看文件

@@ -20,7 +20,7 @@
20 20
  *
21 21
  */
22 22
 
23
-#include "MarlinConfig.h"
23
+#include "../inc/MarlinConfig.h"
24 24
 
25 25
 #if ENABLED(DIGIPOT_I2C) && DISABLED(DIGIPOT_MCP4018)
26 26
 

+ 5
- 4
Marlin/src/feature/leds/Max7219_Debug_LEDs.cpp 查看文件

@@ -49,15 +49,16 @@
49 49
  * void Max7219_idle_tasks();
50 50
  */
51 51
 
52
-#include "MarlinConfig.h"
52
+#include "../../inc/MarlinConfig.h"
53 53
 
54 54
 #if ENABLED(MAX7219_DEBUG)
55 55
 
56
-  #include "Marlin.h"
57
-  #include "planner.h"
58
-  #include "stepper.h"
59 56
   #include "Max7219_Debug_LEDs.h"
60 57
 
58
+  #include "../../module/planner.h"
59
+  #include "../../module/stepper.h"
60
+  #include "../../Marlin.h"
61
+
61 62
   static uint8_t LEDs[8] = { 0 };
62 63
 
63 64
   void Max7219_PutByte(uint8_t data) {

+ 1
- 1
Marlin/src/feature/leds/blinkm.cpp 查看文件

@@ -25,7 +25,7 @@
25 25
  * Created by Tim Koster, August 21 2013.
26 26
  */
27 27
 
28
-#include "Marlin.h"
28
+#include "../../Marlin.h"
29 29
 
30 30
 #if ENABLED(BLINKM)
31 31
 

+ 2
- 2
Marlin/src/feature/leds/pca9632.cpp 查看文件

@@ -20,12 +20,12 @@
20 20
  *
21 21
  */
22 22
 
23
-/*
23
+/**
24 24
  * Driver for the Philips PCA9632 LED driver.
25 25
  * Written by Robert Mendon Feb 2017.
26 26
  */
27 27
 
28
-#include "MarlinConfig.h"
28
+#include "../../inc/MarlinConfig.h"
29 29
 
30 30
 #if ENABLED(PCA9632)
31 31
 

+ 3
- 1
Marlin/src/feature/mbl/mesh_bed_leveling.cpp 查看文件

@@ -20,10 +20,12 @@
20 20
  *
21 21
  */
22 22
 
23
-#include "mesh_bed_leveling.h"
23
+#include "../../inc/MarlinConfig.h"
24 24
 
25 25
 #if ENABLED(MESH_BED_LEVELING)
26 26
 
27
+  #include "mesh_bed_leveling.h"
28
+
27 29
   mesh_bed_leveling mbl;
28 30
 
29 31
   uint8_t mesh_bed_leveling::status;

+ 99
- 98
Marlin/src/feature/mbl/mesh_bed_leveling.h 查看文件

@@ -20,103 +20,104 @@
20 20
  *
21 21
  */
22 22
 
23
-#include "Marlin.h"
24
-
25
-#if ENABLED(MESH_BED_LEVELING)
26
-
27
-  enum MeshLevelingState {
28
-    MeshReport,
29
-    MeshStart,
30
-    MeshNext,
31
-    MeshSet,
32
-    MeshSetZOffset,
33
-    MeshReset
34
-  };
35
-
36
-  enum MBLStatus {
37
-    MBL_STATUS_NONE = 0,
38
-    MBL_STATUS_HAS_MESH_BIT = 0,
39
-    MBL_STATUS_ACTIVE_BIT = 1
40
-  };
41
-
42
-  #define MESH_X_DIST ((MESH_MAX_X - (MESH_MIN_X)) / (GRID_MAX_POINTS_X - 1))
43
-  #define MESH_Y_DIST ((MESH_MAX_Y - (MESH_MIN_Y)) / (GRID_MAX_POINTS_Y - 1))
44
-
45
-  class mesh_bed_leveling {
46
-  public:
47
-    static uint8_t status; // Has Mesh and Is Active bits
48
-    static float z_offset,
49
-                 z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
50
-                 index_to_xpos[GRID_MAX_POINTS_X],
51
-                 index_to_ypos[GRID_MAX_POINTS_Y];
52
-
53
-    mesh_bed_leveling();
54
-
55
-    static void reset();
56
-
57
-    static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
58
-
59
-    static bool active()                       { return TEST(status, MBL_STATUS_ACTIVE_BIT); }
60
-    static void set_active(const bool onOff)   { onOff ? SBI(status, MBL_STATUS_ACTIVE_BIT) : CBI(status, MBL_STATUS_ACTIVE_BIT); }
61
-    static bool has_mesh()                     { return TEST(status, MBL_STATUS_HAS_MESH_BIT); }
62
-    static void set_has_mesh(const bool onOff) { onOff ? SBI(status, MBL_STATUS_HAS_MESH_BIT) : CBI(status, MBL_STATUS_HAS_MESH_BIT); }
63
-
64
-    static inline void zigzag(const int8_t index, int8_t &px, int8_t &py) {
65
-      px = index % (GRID_MAX_POINTS_X);
66
-      py = index / (GRID_MAX_POINTS_X);
67
-      if (py & 1) px = (GRID_MAX_POINTS_X - 1) - px; // Zig zag
68
-    }
69
-
70
-    static void set_zigzag_z(const int8_t index, const float &z) {
71
-      int8_t px, py;
72
-      zigzag(index, px, py);
73
-      set_z(px, py, z);
74
-    }
75
-
76
-    static int8_t cell_index_x(const float &x) {
77
-      int8_t cx = (x - (MESH_MIN_X)) * (1.0 / (MESH_X_DIST));
78
-      return constrain(cx, 0, (GRID_MAX_POINTS_X) - 2);
79
-    }
80
-
81
-    static int8_t cell_index_y(const float &y) {
82
-      int8_t cy = (y - (MESH_MIN_Y)) * (1.0 / (MESH_Y_DIST));
83
-      return constrain(cy, 0, (GRID_MAX_POINTS_Y) - 2);
84
-    }
85
-
86
-    static int8_t probe_index_x(const float &x) {
87
-      int8_t px = (x - (MESH_MIN_X) + 0.5 * (MESH_X_DIST)) * (1.0 / (MESH_X_DIST));
88
-      return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1;
89
-    }
90
-
91
-    static int8_t probe_index_y(const float &y) {
92
-      int8_t py = (y - (MESH_MIN_Y) + 0.5 * (MESH_Y_DIST)) * (1.0 / (MESH_Y_DIST));
93
-      return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1;
94
-    }
95
-
96
-    static float calc_z0(const float &a0, const float &a1, const float &z1, const float &a2, const float &z2) {
97
-      const float delta_z = (z2 - z1) / (a2 - a1),
98
-                  delta_a = a0 - a1;
99
-      return z1 + delta_a * delta_z;
100
-    }
101
-
102
-    static float get_z(const float &x0, const float &y0
23
+#ifndef _MESH_BED_LEVELING_H_
24
+#define _MESH_BED_LEVELING_H_
25
+
26
+#include "../../Marlin.h"
27
+
28
+enum MeshLevelingState {
29
+  MeshReport,
30
+  MeshStart,
31
+  MeshNext,
32
+  MeshSet,
33
+  MeshSetZOffset,
34
+  MeshReset
35
+};
36
+
37
+enum MBLStatus {
38
+  MBL_STATUS_NONE = 0,
39
+  MBL_STATUS_HAS_MESH_BIT = 0,
40
+  MBL_STATUS_ACTIVE_BIT = 1
41
+};
42
+
43
+#define MESH_X_DIST ((MESH_MAX_X - (MESH_MIN_X)) / (GRID_MAX_POINTS_X - 1))
44
+#define MESH_Y_DIST ((MESH_MAX_Y - (MESH_MIN_Y)) / (GRID_MAX_POINTS_Y - 1))
45
+
46
+class mesh_bed_leveling {
47
+public:
48
+  static uint8_t status; // Has Mesh and Is Active bits
49
+  static float z_offset,
50
+               z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
51
+               index_to_xpos[GRID_MAX_POINTS_X],
52
+               index_to_ypos[GRID_MAX_POINTS_Y];
53
+
54
+  mesh_bed_leveling();
55
+
56
+  static void reset();
57
+
58
+  static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
59
+
60
+  static bool active()                       { return TEST(status, MBL_STATUS_ACTIVE_BIT); }
61
+  static void set_active(const bool onOff)   { onOff ? SBI(status, MBL_STATUS_ACTIVE_BIT) : CBI(status, MBL_STATUS_ACTIVE_BIT); }
62
+  static bool has_mesh()                     { return TEST(status, MBL_STATUS_HAS_MESH_BIT); }
63
+  static void set_has_mesh(const bool onOff) { onOff ? SBI(status, MBL_STATUS_HAS_MESH_BIT) : CBI(status, MBL_STATUS_HAS_MESH_BIT); }
64
+
65
+  static inline void zigzag(const int8_t index, int8_t &px, int8_t &py) {
66
+    px = index % (GRID_MAX_POINTS_X);
67
+    py = index / (GRID_MAX_POINTS_X);
68
+    if (py & 1) px = (GRID_MAX_POINTS_X - 1) - px; // Zig zag
69
+  }
70
+
71
+  static void set_zigzag_z(const int8_t index, const float &z) {
72
+    int8_t px, py;
73
+    zigzag(index, px, py);
74
+    set_z(px, py, z);
75
+  }
76
+
77
+  static int8_t cell_index_x(const float &x) {
78
+    int8_t cx = (x - (MESH_MIN_X)) * (1.0 / (MESH_X_DIST));
79
+    return constrain(cx, 0, (GRID_MAX_POINTS_X) - 2);
80
+  }
81
+
82
+  static int8_t cell_index_y(const float &y) {
83
+    int8_t cy = (y - (MESH_MIN_Y)) * (1.0 / (MESH_Y_DIST));
84
+    return constrain(cy, 0, (GRID_MAX_POINTS_Y) - 2);
85
+  }
86
+
87
+  static int8_t probe_index_x(const float &x) {
88
+    int8_t px = (x - (MESH_MIN_X) + 0.5 * (MESH_X_DIST)) * (1.0 / (MESH_X_DIST));
89
+    return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1;
90
+  }
91
+
92
+  static int8_t probe_index_y(const float &y) {
93
+    int8_t py = (y - (MESH_MIN_Y) + 0.5 * (MESH_Y_DIST)) * (1.0 / (MESH_Y_DIST));
94
+    return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1;
95
+  }
96
+
97
+  static float calc_z0(const float &a0, const float &a1, const float &z1, const float &a2, const float &z2) {
98
+    const float delta_z = (z2 - z1) / (a2 - a1),
99
+                delta_a = a0 - a1;
100
+    return z1 + delta_a * delta_z;
101
+  }
102
+
103
+  static float get_z(const float &x0, const float &y0
104
+    #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
105
+      , const float &factor
106
+    #endif
107
+  ) {
108
+    const int8_t cx = cell_index_x(x0), cy = cell_index_y(y0);
109
+    const float z1 = calc_z0(x0, index_to_xpos[cx], z_values[cx][cy], index_to_xpos[cx + 1], z_values[cx + 1][cy]),
110
+                z2 = calc_z0(x0, index_to_xpos[cx], z_values[cx][cy + 1], index_to_xpos[cx + 1], z_values[cx + 1][cy + 1]),
111
+                z0 = calc_z0(y0, index_to_ypos[cy], z1, index_to_ypos[cy + 1], z2);
112
+
113
+    return z_offset + z0
103 114
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
104
-        , const float &factor
115
+        * factor
105 116
       #endif
106
-    ) {
107
-      const int8_t cx = cell_index_x(x0), cy = cell_index_y(y0);
108
-      const float z1 = calc_z0(x0, index_to_xpos[cx], z_values[cx][cy], index_to_xpos[cx + 1], z_values[cx + 1][cy]),
109
-                  z2 = calc_z0(x0, index_to_xpos[cx], z_values[cx][cy + 1], index_to_xpos[cx + 1], z_values[cx + 1][cy + 1]),
110
-                  z0 = calc_z0(y0, index_to_ypos[cy], z1, index_to_ypos[cy + 1], z2);
111
-
112
-      return z_offset + z0
113
-        #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
114
-          * factor
115
-        #endif
116
-      ;
117
-    }
118
-  };
119
-
120
-  extern mesh_bed_leveling mbl;
121
-
122
-#endif // MESH_BED_LEVELING
117
+    ;
118
+  }
119
+};
120
+
121
+extern mesh_bed_leveling mbl;
122
+
123
+#endif // _MESH_BED_LEVELING_H_

+ 157
- 0
Marlin/src/feature/tmc2130.cpp 查看文件

@@ -0,0 +1,157 @@
1
+/**
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
+ */
22
+
23
+#include "../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(HAVE_TMC2130)
26
+
27
+#include "tmc2130.h"
28
+#include "../Marlin.h"
29
+
30
+#include "../libs/duration_t.h"
31
+#include "../module/stepper_indirection.h"
32
+
33
+#include <TMC2130Stepper.h>
34
+
35
+#ifdef AUTOMATIC_CURRENT_CONTROL
36
+  bool auto_current_control = 0;
37
+#endif
38
+
39
+void automatic_current_control(TMC2130Stepper &st, String axisID) {
40
+  // Check otpw even if we don't use automatic control. Allows for flag inspection.
41
+  const bool is_otpw = st.checkOT();
42
+
43
+  // Report if a warning was triggered
44
+  static bool previous_otpw = false;
45
+  if (is_otpw && !previous_otpw) {
46
+    char timestamp[10];
47
+    duration_t elapsed = print_job_timer.duration();
48
+    const bool has_days = (elapsed.value > 60*60*24L);
49
+    (void)elapsed.toDigital(timestamp, has_days);
50
+    SERIAL_ECHO(timestamp);
51
+    SERIAL_ECHOPGM(": ");
52
+    SERIAL_ECHO(axisID);
53
+    SERIAL_ECHOLNPGM(" driver overtemperature warning!");
54
+  }
55
+  previous_otpw = is_otpw;
56
+
57
+  #if ENABLED(AUTOMATIC_CURRENT_CONTROL) && CURRENT_STEP > 0
58
+    // Return if user has not enabled current control start with M906 S1.
59
+    if (!auto_current_control) return;
60
+
61
+    /**
62
+     * Decrease current if is_otpw is true.
63
+     * Bail out if driver is disabled.
64
+     * Increase current if OTPW has not been triggered yet.
65
+     */
66
+    uint16_t current = st.getCurrent();
67
+    if (is_otpw) {
68
+      st.setCurrent(current - CURRENT_STEP, R_SENSE, HOLD_MULTIPLIER);
69
+      #if ENABLED(REPORT_CURRENT_CHANGE)
70
+        SERIAL_ECHO(axisID);
71
+        SERIAL_ECHOPAIR(" current decreased to ", st.getCurrent());
72
+      #endif
73
+    }
74
+
75
+    else if (!st.isEnabled())
76
+      return;
77
+
78
+    else if (!is_otpw && !st.getOTPW()) {
79
+      current += CURRENT_STEP;
80
+      if (current <= AUTO_ADJUST_MAX) {
81
+        st.setCurrent(current, R_SENSE, HOLD_MULTIPLIER);
82
+        #if ENABLED(REPORT_CURRENT_CHANGE)
83
+          SERIAL_ECHO(axisID);
84
+          SERIAL_ECHOPAIR(" current increased to ", st.getCurrent());
85
+        #endif
86
+      }
87
+    }
88
+    SERIAL_EOL();
89
+  #endif
90
+}
91
+
92
+void tmc2130_checkOverTemp(void) {
93
+  static millis_t next_cOT = 0;
94
+  if (ELAPSED(millis(), next_cOT)) {
95
+    next_cOT = millis() + 5000;
96
+    #if ENABLED(X_IS_TMC2130)
97
+      automatic_current_control(stepperX, "X");
98
+    #endif
99
+    #if ENABLED(Y_IS_TMC2130)
100
+      automatic_current_control(stepperY, "Y");
101
+    #endif
102
+    #if ENABLED(Z_IS_TMC2130)
103
+      automatic_current_control(stepperZ, "Z");
104
+    #endif
105
+    #if ENABLED(X2_IS_TMC2130)
106
+      automatic_current_control(stepperX2, "X2");
107
+    #endif
108
+    #if ENABLED(Y2_IS_TMC2130)
109
+      automatic_current_control(stepperY2, "Y2");
110
+    #endif
111
+    #if ENABLED(Z2_IS_TMC2130)
112
+      automatic_current_control(stepperZ2, "Z2");
113
+    #endif
114
+    #if ENABLED(E0_IS_TMC2130)
115
+      automatic_current_control(stepperE0, "E0");
116
+    #endif
117
+    #if ENABLED(E1_IS_TMC2130)
118
+      automatic_current_control(stepperE1, "E1");
119
+    #endif
120
+    #if ENABLED(E2_IS_TMC2130)
121
+      automatic_current_control(stepperE2, "E2");
122
+    #endif
123
+    #if ENABLED(E3_IS_TMC2130)
124
+      automatic_current_control(stepperE3, "E3");
125
+    #endif
126
+    #if ENABLED(E4_IS_TMC2130)
127
+      automatic_current_control(stepperE4, "E4");
128
+    #endif
129
+    #if ENABLED(E4_IS_TMC2130)
130
+      automatic_current_control(stepperE4);
131
+    #endif
132
+  }
133
+}
134
+
135
+/**
136
+ * TMC2130 specific sensorless homing using stallGuard2.
137
+ * stallGuard2 only works when in spreadCycle mode.
138
+ * spreadCycle and stealthChop are mutually exclusive.
139
+ */
140
+#if ENABLED(SENSORLESS_HOMING)
141
+  void tmc2130_sensorless_homing(TMC2130Stepper &st, bool enable/*=true*/) {
142
+    #if ENABLED(STEALTHCHOP)
143
+      if (enable) {
144
+        st.coolstep_min_speed(1024UL * 1024UL - 1UL);
145
+        st.stealthChop(0);
146
+      }
147
+      else {
148
+        st.coolstep_min_speed(0);
149
+        st.stealthChop(1);
150
+      }
151
+    #endif
152
+
153
+    st.diag1_stall(enable ? 1 : 0);
154
+  }
155
+#endif // SENSORLESS_HOMING
156
+
157
+#endif // HAVE_TMC2130

+ 30
- 0
Marlin/src/feature/tmc2130.h 查看文件

@@ -0,0 +1,30 @@
1
+/**
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
+ */
22
+
23
+#ifndef _TMC2130_H_
24
+#define _TMC2130_H_
25
+
26
+extern bool auto_current_control;
27
+
28
+void tmc2130_checkOverTemp(void);
29
+
30
+#endif // _TMC2130_H_

+ 2
- 1
Marlin/src/feature/twibus.cpp 查看文件

@@ -20,11 +20,12 @@
20 20
  *
21 21
  */
22 22
 
23
-#include "Marlin.h"
23
+#include "../inc/MarlinConfig.h"
24 24
 
25 25
 #if ENABLED(EXPERIMENTAL_I2CBUS)
26 26
 
27 27
 #include "twibus.h"
28
+
28 29
 #include <Wire.h>
29 30
 
30 31
 TWIBus::TWIBus() {

+ 1
- 1
Marlin/src/feature/twibus.h 查看文件

@@ -23,7 +23,7 @@
23 23
 #ifndef TWIBUS_H
24 24
 #define TWIBUS_H
25 25
 
26
-#include "macros.h"
26
+#include "../core/macros.h"
27 27
 
28 28
 #include <Wire.h>
29 29
 

+ 10
- 9
Marlin/src/feature/ubl/G26_Mesh_Validation_Tool.cpp 查看文件

@@ -24,17 +24,18 @@
24 24
  * Marlin Firmware -- G26 - Mesh Validation Tool
25 25
  */
26 26
 
27
-#include "MarlinConfig.h"
27
+#include "../../inc/MarlinConfig.h"
28 28
 
29 29
 #if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(UBL_G26_MESH_VALIDATION)
30 30
 
31 31
   #include "ubl.h"
32
-  #include "Marlin.h"
33
-  #include "planner.h"
34
-  #include "stepper.h"
35
-  #include "temperature.h"
36
-  #include "ultralcd.h"
37
-  #include "gcode.h"
32
+
33
+  #include "../../Marlin.h"
34
+  #include "../../module/planner.h"
35
+  #include "../../module/stepper.h"
36
+  #include "../../module/temperature.h"
37
+  #include "../../lcd/ultralcd.h"
38
+  #include "../../gcode/parser.h"
38 39
 
39 40
   #define EXTRUSION_MULTIPLIER 1.0
40 41
   #define RETRACTION_MULTIPLIER 1.0
@@ -140,8 +141,8 @@
140 141
     inline void sync_plan_position_e() { planner.set_e_position_mm(current_position[E_AXIS]); }
141 142
     inline void set_current_to_destination() { COPY(current_position, destination); }
142 143
   #else
143
-    extern void sync_plan_position_e() { planner.set_e_position_mm(current_position[E_AXIS]); }
144
-    extern void set_current_to_destination() { COPY(current_position, destination); }
144
+    extern void sync_plan_position_e();
145
+    extern void set_current_to_destination();
145 146
   #endif
146 147
   #if ENABLED(NEWPANEL)
147 148
     void lcd_setstatusPGM(const char* const message, const int8_t level);

+ 10
- 8
Marlin/src/feature/ubl/ubl.cpp 查看文件

@@ -20,16 +20,18 @@
20 20
  *
21 21
  */
22 22
 
23
-#include "Marlin.h"
24
-#include "math.h"
23
+#include "../../inc/MarlinConfig.h"
25 24
 
26 25
 #if ENABLED(AUTO_BED_LEVELING_UBL)
27 26
 
28 27
   #include "ubl.h"
29
-  #include "hex_print_routines.h"
30
-  #include "temperature.h"
28
+  unified_bed_leveling ubl;
31 29
 
32
-  extern Planner planner;
30
+  #include "../../module/configuration_store.h"
31
+  #include "../../core/serial.h"
32
+  #include "../../module/planner.h"
33
+
34
+  #include "math.h"
33 35
 
34 36
   /**
35 37
    * These support functions allow the use of large bit arrays of flags that take very
@@ -37,9 +39,9 @@
37 39
    * to unsigned long will allow us to go to 32x32 if higher resolution Mesh's are needed
38 40
    * in the future.
39 41
    */
40
-  void bit_clear(uint16_t bits[16], uint8_t x, uint8_t y) { CBI(bits[y], x); }
41
-  void bit_set(uint16_t bits[16], uint8_t x, uint8_t y) { SBI(bits[y], x); }
42
-  bool is_bit_set(uint16_t bits[16], uint8_t x, uint8_t y) { return TEST(bits[y], x); }
42
+  void bit_clear(uint16_t bits[16], const uint8_t x, const uint8_t y) { CBI(bits[y], x); }
43
+  void bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y) { SBI(bits[y], x); }
44
+  bool is_bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y) { return TEST(bits[y], x); }
43 45
 
44 46
   uint8_t ubl_cnt = 0;
45 47
 

+ 340
- 352
Marlin/src/feature/ubl/ubl.h 查看文件

@@ -23,387 +23,375 @@
23 23
 #ifndef UNIFIED_BED_LEVELING_H
24 24
 #define UNIFIED_BED_LEVELING_H
25 25
 
26
-#include "MarlinConfig.h"
27
-
28
-#if ENABLED(AUTO_BED_LEVELING_UBL)
29
-  #include "Marlin.h"
30
-  #include "planner.h"
31
-  #include "math.h"
32
-  #include "vector_3.h"
33
-  #include "configuration_store.h"
34
-
35
-  #define UBL_VERSION "1.01"
36
-  #define UBL_OK false
37
-  #define UBL_ERR true
38
-
39
-  #define USE_NOZZLE_AS_REFERENCE 0
40
-  #define USE_PROBE_AS_REFERENCE 1
41
-
42
-  typedef struct {
43
-    int8_t x_index, y_index;
44
-    float distance; // When populated, the distance from the search location
45
-  } mesh_index_pair;
46
-
47
-  // ubl.cpp
48
-
49
-  void bit_clear(uint16_t bits[16], uint8_t x, uint8_t y);
50
-  void bit_set(uint16_t bits[16], uint8_t x, uint8_t y);
51
-  bool is_bit_set(uint16_t bits[16], uint8_t x, uint8_t y);
52
-
53
-  // ubl_motion.cpp
54
-
55
-  void debug_current_and_destination(const char * const title);
56
-
57
-  // ubl_G29.cpp
58
-
59
-  enum MeshPointType { INVALID, REAL, SET_IN_BITMAP };
60
-
61
-  // External references
62
-
63
-  char *ftostr43sign(const float&, char);
64
-  bool ubl_lcd_clicked();
65
-  void home_all_axes();
66
-
67
-  extern uint8_t ubl_cnt;
68
-
69
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////
70
-
71
-  #if ENABLED(ULTRA_LCD)
72
-    extern char lcd_status_message[];
73
-    void lcd_quick_feedback();
74
-  #endif
75
-
76
-  #define MESH_X_DIST (float(UBL_MESH_MAX_X - (UBL_MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1))
77
-  #define MESH_Y_DIST (float(UBL_MESH_MAX_Y - (UBL_MESH_MIN_Y)) / float(GRID_MAX_POINTS_Y - 1))
78
-
79
-  typedef struct {
80
-    bool active = false;
81
-    float z_offset = 0.0;
82
-    int8_t storage_slot = -1;
83
-  } ubl_state;
84
-
85
-  class unified_bed_leveling {
86
-    private:
87
-
88
-      static float last_specified_z;
89
-
90
-      static int    g29_verbose_level,
91
-                    g29_phase_value,
92
-                    g29_repetition_cnt,
93
-                    g29_storage_slot,
94
-                    g29_map_type,
95
-                    g29_grid_size;
96
-      static bool   g29_c_flag, g29_x_flag, g29_y_flag;
97
-      static float  g29_x_pos, g29_y_pos,
98
-                    g29_card_thickness,
99
-                    g29_constant;
100
-
101
-      #if ENABLED(UBL_G26_MESH_VALIDATION)
102
-        static float   g26_extrusion_multiplier,
103
-                       g26_retraction_multiplier,
104
-                       g26_nozzle,
105
-                       g26_filament_diameter,
106
-                       g26_prime_length,
107
-                       g26_x_pos, g26_y_pos,
108
-                       g26_ooze_amount,
109
-                       g26_layer_height;
110
-        static int16_t g26_bed_temp,
111
-                       g26_hotend_temp,
112
-                       g26_repeats;
113
-        static int8_t  g26_prime_flag;
114
-        static bool    g26_continue_with_closest, g26_keep_heaters_on;
115
-      #endif
116
-
117
-      static float measure_point_with_encoder();
118
-      static float measure_business_card_thickness(float);
119
-      static bool g29_parameter_parsing();
120
-      static void find_mean_mesh_height();
121
-      static void shift_mesh_height();
122
-      static void probe_entire_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest);
123
-      static void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool);
124
-      static void tilt_mesh_based_on_3pts(const float &z1, const float &z2, const float &z3);
125
-      static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map);
126
-      static void g29_what_command();
127
-      static void g29_eeprom_dump();
128
-      static void g29_compare_current_mesh_to_stored_mesh();
129
-      static void fine_tune_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map);
130
-      static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir);
131
-      static void smart_fill_mesh();
132
-
133
-      #if ENABLED(UBL_G26_MESH_VALIDATION)
134
-        static bool exit_from_g26();
135
-        static bool parse_G26_parameters();
136
-        static void G26_line_to_destination(const float &feed_rate);
137
-        static mesh_index_pair find_closest_circle_to_print(const float&, const float&);
138
-        static bool look_for_lines_to_connect();
139
-        static bool turn_on_heaters();
140
-        static bool prime_nozzle();
141
-        static void retract_filament(const float where[XYZE]);
142
-        static void recover_filament(const float where[XYZE]);
143
-        static void print_line_from_here_to_there(const float&, const float&, const float&, const float&, const float&, const float&);
144
-        static void move_to(const float&, const float&, const float&, const float&);
145
-        inline static void move_to(const float where[XYZE], const float &de) { move_to(where[X_AXIS], where[Y_AXIS], where[Z_AXIS], de); }
146
-      #endif
147
-
148
-    public:
149
-
150
-      static void echo_name();
151
-      static void report_state();
152
-      static void save_ubl_active_state_and_disable();
153
-      static void restore_ubl_active_state_and_leave();
154
-      static void display_map(const int);
155
-      static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const float&, const float&, const bool, uint16_t[16], bool);
156
-      static void reset();
157
-      static void invalidate();
158
-      static void set_all_mesh_points_to_value(float);
159
-      static bool sanity_check();
160
-
161
-      static void G29() _O0;                          // O0 for no optimization
162
-      static void smart_fill_wlsf(const float &) _O2; // O2 gives smaller code than Os on A2560
163
-
164
-      #if ENABLED(UBL_G26_MESH_VALIDATION)
165
-        static void G26();
166
-      #endif
167
-
168
-      static ubl_state state;
169
-
170
-      static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
171
-
172
-      // 15 is the maximum nubmer of grid points supported + 1 safety margin for now,
173
-      // until determinism prevails
174
-      constexpr static float _mesh_index_to_xpos[16] PROGMEM = {
175
-                                UBL_MESH_MIN_X +  0 * (MESH_X_DIST), UBL_MESH_MIN_X +  1 * (MESH_X_DIST),
176
-                                UBL_MESH_MIN_X +  2 * (MESH_X_DIST), UBL_MESH_MIN_X +  3 * (MESH_X_DIST),
177
-                                UBL_MESH_MIN_X +  4 * (MESH_X_DIST), UBL_MESH_MIN_X +  5 * (MESH_X_DIST),
178
-                                UBL_MESH_MIN_X +  6 * (MESH_X_DIST), UBL_MESH_MIN_X +  7 * (MESH_X_DIST),
179
-                                UBL_MESH_MIN_X +  8 * (MESH_X_DIST), UBL_MESH_MIN_X +  9 * (MESH_X_DIST),
180
-                                UBL_MESH_MIN_X + 10 * (MESH_X_DIST), UBL_MESH_MIN_X + 11 * (MESH_X_DIST),
181
-                                UBL_MESH_MIN_X + 12 * (MESH_X_DIST), UBL_MESH_MIN_X + 13 * (MESH_X_DIST),
182
-                                UBL_MESH_MIN_X + 14 * (MESH_X_DIST), UBL_MESH_MIN_X + 15 * (MESH_X_DIST)
183
-                              };
184
-
185
-      constexpr static float _mesh_index_to_ypos[16] PROGMEM = {
186
-                                UBL_MESH_MIN_Y +  0 * (MESH_Y_DIST), UBL_MESH_MIN_Y +  1 * (MESH_Y_DIST),
187
-                                UBL_MESH_MIN_Y +  2 * (MESH_Y_DIST), UBL_MESH_MIN_Y +  3 * (MESH_Y_DIST),
188
-                                UBL_MESH_MIN_Y +  4 * (MESH_Y_DIST), UBL_MESH_MIN_Y +  5 * (MESH_Y_DIST),
189
-                                UBL_MESH_MIN_Y +  6 * (MESH_Y_DIST), UBL_MESH_MIN_Y +  7 * (MESH_Y_DIST),
190
-                                UBL_MESH_MIN_Y +  8 * (MESH_Y_DIST), UBL_MESH_MIN_Y +  9 * (MESH_Y_DIST),
191
-                                UBL_MESH_MIN_Y + 10 * (MESH_Y_DIST), UBL_MESH_MIN_Y + 11 * (MESH_Y_DIST),
192
-                                UBL_MESH_MIN_Y + 12 * (MESH_Y_DIST), UBL_MESH_MIN_Y + 13 * (MESH_Y_DIST),
193
-                                UBL_MESH_MIN_Y + 14 * (MESH_Y_DIST), UBL_MESH_MIN_Y + 15 * (MESH_Y_DIST)
194
-                              };
195
-
196
-      static bool g26_debug_flag, has_control_of_lcd_panel;
197
-
198
-      static volatile int encoder_diff; // Volatile because it's changed at interrupt time.
199
-
200
-      unified_bed_leveling();
201
-
202
-      FORCE_INLINE static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
203
-
204
-      static int8_t get_cell_index_x(const float &x) {
205
-        const int8_t cx = (x - (UBL_MESH_MIN_X)) * (1.0 / (MESH_X_DIST));
206
-        return constrain(cx, 0, (GRID_MAX_POINTS_X) - 1);   // -1 is appropriate if we want all movement to the X_MAX
207
-      }                                                     // position. But with this defined this way, it is possible
208
-                                                            // to extrapolate off of this point even further out. Probably
209
-                                                            // that is OK because something else should be keeping that from
210
-                                                            // happening and should not be worried about at this level.
211
-      static int8_t get_cell_index_y(const float &y) {
212
-        const int8_t cy = (y - (UBL_MESH_MIN_Y)) * (1.0 / (MESH_Y_DIST));
213
-        return constrain(cy, 0, (GRID_MAX_POINTS_Y) - 1);   // -1 is appropriate if we want all movement to the Y_MAX
214
-      }                                                     // position. But with this defined this way, it is possible
215
-                                                            // to extrapolate off of this point even further out. Probably
216
-                                                            // that is OK because something else should be keeping that from
217
-                                                            // happening and should not be worried about at this level.
218
-
219
-      static int8_t find_closest_x_index(const float &x) {
220
-        const int8_t px = (x - (UBL_MESH_MIN_X) + (MESH_X_DIST) * 0.5) * (1.0 / (MESH_X_DIST));
221
-        return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1;
26
+#include "../../Marlin.h"
27
+#include "../../core/serial.h"
28
+#include "../../module/planner.h"
29
+
30
+#define UBL_VERSION "1.01"
31
+#define UBL_OK false
32
+#define UBL_ERR true
33
+
34
+#define USE_NOZZLE_AS_REFERENCE 0
35
+#define USE_PROBE_AS_REFERENCE 1
36
+
37
+typedef struct {
38
+  int8_t x_index, y_index;
39
+  float distance; // When populated, the distance from the search location
40
+} mesh_index_pair;
41
+
42
+// ubl.cpp
43
+
44
+void bit_clear(uint16_t bits[16], const uint8_t x, const uint8_t y);
45
+void bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y);
46
+bool is_bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y);
47
+
48
+// ubl_motion.cpp
49
+
50
+void debug_current_and_destination(const char * const title);
51
+
52
+// ubl_G29.cpp
53
+
54
+enum MeshPointType { INVALID, REAL, SET_IN_BITMAP };
55
+
56
+// External references
57
+
58
+char *ftostr43sign(const float&, char);
59
+bool ubl_lcd_clicked();
60
+void home_all_axes();
61
+
62
+extern uint8_t ubl_cnt;
63
+
64
+///////////////////////////////////////////////////////////////////////////////////////////////////////
65
+
66
+#if ENABLED(ULTRA_LCD)
67
+  extern char lcd_status_message[];
68
+  void lcd_quick_feedback();
69
+#endif
70
+
71
+#define MESH_X_DIST (float(UBL_MESH_MAX_X - (UBL_MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1))
72
+#define MESH_Y_DIST (float(UBL_MESH_MAX_Y - (UBL_MESH_MIN_Y)) / float(GRID_MAX_POINTS_Y - 1))
73
+
74
+typedef struct {
75
+  bool active = false;
76
+  float z_offset = 0.0;
77
+  int8_t storage_slot = -1;
78
+} ubl_state;
79
+
80
+class unified_bed_leveling {
81
+  private:
82
+
83
+    static float last_specified_z;
84
+
85
+    static int    g29_verbose_level,
86
+                  g29_phase_value,
87
+                  g29_repetition_cnt,
88
+                  g29_storage_slot,
89
+                  g29_map_type,
90
+                  g29_grid_size;
91
+    static bool   g29_c_flag, g29_x_flag, g29_y_flag;
92
+    static float  g29_x_pos, g29_y_pos,
93
+                  g29_card_thickness,
94
+                  g29_constant;
95
+
96
+    #if ENABLED(UBL_G26_MESH_VALIDATION)
97
+      static float   g26_extrusion_multiplier,
98
+                     g26_retraction_multiplier,
99
+                     g26_nozzle,
100
+                     g26_filament_diameter,
101
+                     g26_prime_length,
102
+                     g26_x_pos, g26_y_pos,
103
+                     g26_ooze_amount,
104
+                     g26_layer_height;
105
+      static int16_t g26_bed_temp,
106
+                     g26_hotend_temp,
107
+                     g26_repeats;
108
+      static int8_t  g26_prime_flag;
109
+      static bool    g26_continue_with_closest, g26_keep_heaters_on;
110
+    #endif
111
+
112
+    static float measure_point_with_encoder();
113
+    static float measure_business_card_thickness(float);
114
+    static bool g29_parameter_parsing();
115
+    static void find_mean_mesh_height();
116
+    static void shift_mesh_height();
117
+    static void probe_entire_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest);
118
+    static void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool);
119
+    static void tilt_mesh_based_on_3pts(const float &z1, const float &z2, const float &z3);
120
+    static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map);
121
+    static void g29_what_command();
122
+    static void g29_eeprom_dump();
123
+    static void g29_compare_current_mesh_to_stored_mesh();
124
+    static void fine_tune_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map);
125
+    static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir);
126
+    static void smart_fill_mesh();
127
+
128
+    #if ENABLED(UBL_G26_MESH_VALIDATION)
129
+      static bool exit_from_g26();
130
+      static bool parse_G26_parameters();
131
+      static void G26_line_to_destination(const float &feed_rate);
132
+      static mesh_index_pair find_closest_circle_to_print(const float&, const float&);
133
+      static bool look_for_lines_to_connect();
134
+      static bool turn_on_heaters();
135
+      static bool prime_nozzle();
136
+      static void retract_filament(const float where[XYZE]);
137
+      static void recover_filament(const float where[XYZE]);
138
+      static void print_line_from_here_to_there(const float&, const float&, const float&, const float&, const float&, const float&);
139
+      static void move_to(const float&, const float&, const float&, const float&);
140
+      inline static void move_to(const float where[XYZE], const float &de) { move_to(where[X_AXIS], where[Y_AXIS], where[Z_AXIS], de); }
141
+    #endif
142
+
143
+  public:
144
+
145
+    static void echo_name();
146
+    static void report_state();
147
+    static void save_ubl_active_state_and_disable();
148
+    static void restore_ubl_active_state_and_leave();
149
+    static void display_map(const int);
150
+    static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const float&, const float&, const bool, uint16_t[16], bool);
151
+    static void reset();
152
+    static void invalidate();
153
+    static void set_all_mesh_points_to_value(float);
154
+    static bool sanity_check();
155
+
156
+    static void G29() _O0;                          // O0 for no optimization
157
+    static void smart_fill_wlsf(const float &) _O2; // O2 gives smaller code than Os on A2560
158
+
159
+    #if ENABLED(UBL_G26_MESH_VALIDATION)
160
+      static void G26();
161
+    #endif
162
+
163
+    static ubl_state state;
164
+
165
+    static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
166
+
167
+    // 15 is the maximum nubmer of grid points supported + 1 safety margin for now,
168
+    // until determinism prevails
169
+    constexpr static float _mesh_index_to_xpos[16] PROGMEM = {
170
+                              UBL_MESH_MIN_X +  0 * (MESH_X_DIST), UBL_MESH_MIN_X +  1 * (MESH_X_DIST),
171
+                              UBL_MESH_MIN_X +  2 * (MESH_X_DIST), UBL_MESH_MIN_X +  3 * (MESH_X_DIST),
172
+                              UBL_MESH_MIN_X +  4 * (MESH_X_DIST), UBL_MESH_MIN_X +  5 * (MESH_X_DIST),
173
+                              UBL_MESH_MIN_X +  6 * (MESH_X_DIST), UBL_MESH_MIN_X +  7 * (MESH_X_DIST),
174
+                              UBL_MESH_MIN_X +  8 * (MESH_X_DIST), UBL_MESH_MIN_X +  9 * (MESH_X_DIST),
175
+                              UBL_MESH_MIN_X + 10 * (MESH_X_DIST), UBL_MESH_MIN_X + 11 * (MESH_X_DIST),
176
+                              UBL_MESH_MIN_X + 12 * (MESH_X_DIST), UBL_MESH_MIN_X + 13 * (MESH_X_DIST),
177
+                              UBL_MESH_MIN_X + 14 * (MESH_X_DIST), UBL_MESH_MIN_X + 15 * (MESH_X_DIST)
178
+                            };
179
+
180
+    constexpr static float _mesh_index_to_ypos[16] PROGMEM = {
181
+                              UBL_MESH_MIN_Y +  0 * (MESH_Y_DIST), UBL_MESH_MIN_Y +  1 * (MESH_Y_DIST),
182
+                              UBL_MESH_MIN_Y +  2 * (MESH_Y_DIST), UBL_MESH_MIN_Y +  3 * (MESH_Y_DIST),
183
+                              UBL_MESH_MIN_Y +  4 * (MESH_Y_DIST), UBL_MESH_MIN_Y +  5 * (MESH_Y_DIST),
184
+                              UBL_MESH_MIN_Y +  6 * (MESH_Y_DIST), UBL_MESH_MIN_Y +  7 * (MESH_Y_DIST),
185
+                              UBL_MESH_MIN_Y +  8 * (MESH_Y_DIST), UBL_MESH_MIN_Y +  9 * (MESH_Y_DIST),
186
+                              UBL_MESH_MIN_Y + 10 * (MESH_Y_DIST), UBL_MESH_MIN_Y + 11 * (MESH_Y_DIST),
187
+                              UBL_MESH_MIN_Y + 12 * (MESH_Y_DIST), UBL_MESH_MIN_Y + 13 * (MESH_Y_DIST),
188
+                              UBL_MESH_MIN_Y + 14 * (MESH_Y_DIST), UBL_MESH_MIN_Y + 15 * (MESH_Y_DIST)
189
+                            };
190
+
191
+    static bool g26_debug_flag, has_control_of_lcd_panel;
192
+
193
+    static volatile int encoder_diff; // Volatile because it's changed at interrupt time.
194
+
195
+    unified_bed_leveling();
196
+
197
+    FORCE_INLINE static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
198
+
199
+    static int8_t get_cell_index_x(const float &x) {
200
+      const int8_t cx = (x - (UBL_MESH_MIN_X)) * (1.0 / (MESH_X_DIST));
201
+      return constrain(cx, 0, (GRID_MAX_POINTS_X) - 1);   // -1 is appropriate if we want all movement to the X_MAX
202
+    }                                                     // position. But with this defined this way, it is possible
203
+                                                          // to extrapolate off of this point even further out. Probably
204
+                                                          // that is OK because something else should be keeping that from
205
+                                                          // happening and should not be worried about at this level.
206
+    static int8_t get_cell_index_y(const float &y) {
207
+      const int8_t cy = (y - (UBL_MESH_MIN_Y)) * (1.0 / (MESH_Y_DIST));
208
+      return constrain(cy, 0, (GRID_MAX_POINTS_Y) - 1);   // -1 is appropriate if we want all movement to the Y_MAX
209
+    }                                                     // position. But with this defined this way, it is possible
210
+                                                          // to extrapolate off of this point even further out. Probably
211
+                                                          // that is OK because something else should be keeping that from
212
+                                                          // happening and should not be worried about at this level.
213
+
214
+    static int8_t find_closest_x_index(const float &x) {
215
+      const int8_t px = (x - (UBL_MESH_MIN_X) + (MESH_X_DIST) * 0.5) * (1.0 / (MESH_X_DIST));
216
+      return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1;
217
+    }
218
+
219
+    static int8_t find_closest_y_index(const float &y) {
220
+      const int8_t py = (y - (UBL_MESH_MIN_Y) + (MESH_Y_DIST) * 0.5) * (1.0 / (MESH_Y_DIST));
221
+      return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1;
222
+    }
223
+
224
+    /**
225
+     *                           z2   --|
226
+     *                 z0        |      |
227
+     *                  |        |      + (z2-z1)
228
+     *   z1             |        |      |
229
+     * ---+-------------+--------+--  --|
230
+     *   a1            a0        a2
231
+     *    |<---delta_a---------->|
232
+     *
233
+     *  calc_z0 is the basis for all the Mesh Based correction. It is used to
234
+     *  find the expected Z Height at a position between two known Z-Height locations.
235
+     *
236
+     *  It is fairly expensive with its 4 floating point additions and 2 floating point
237
+     *  multiplications.
238
+     */
239
+    FORCE_INLINE static float calc_z0(const float &a0, const float &a1, const float &z1, const float &a2, const float &z2) {
240
+      return z1 + (z2 - z1) * (a0 - a1) / (a2 - a1);
241
+    }
242
+
243
+    /**
244
+     * z_correction_for_x_on_horizontal_mesh_line is an optimization for
245
+     * the case where the printer is making a vertical line that only crosses horizontal mesh lines.
246
+     */
247
+    inline static float z_correction_for_x_on_horizontal_mesh_line(const float &lx0, const int x1_i, const int yi) {
248
+      if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 2) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
249
+        serialprintPGM( !WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) ? PSTR("x1l_i") : PSTR("yi") );
250
+        SERIAL_ECHOPAIR(" out of bounds in z_correction_for_x_on_horizontal_mesh_line(lx0=", lx0);
251
+        SERIAL_ECHOPAIR(",x1_i=", x1_i);
252
+        SERIAL_ECHOPAIR(",yi=", yi);
253
+        SERIAL_CHAR(')');
254
+        SERIAL_EOL();
255
+        return NAN;
222 256
       }
223 257
 
224
-      static int8_t find_closest_y_index(const float &y) {
225
-        const int8_t py = (y - (UBL_MESH_MIN_Y) + (MESH_Y_DIST) * 0.5) * (1.0 / (MESH_Y_DIST));
226
-        return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1;
258
+      const float xratio = (RAW_X_POSITION(lx0) - mesh_index_to_xpos(x1_i)) * (1.0 / (MESH_X_DIST)),
259
+                  z1 = z_values[x1_i][yi];
260
+
261
+      return z1 + xratio * (z_values[x1_i + 1][yi] - z1);
262
+    }
263
+
264
+    //
265
+    // See comments above for z_correction_for_x_on_horizontal_mesh_line
266
+    //
267
+    inline static float z_correction_for_y_on_vertical_mesh_line(const float &ly0, const int xi, const int y1_i) {
268
+      if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 2)) {
269
+        serialprintPGM( !WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) ? PSTR("xi") : PSTR("yl_i") );
270
+        SERIAL_ECHOPAIR(" out of bounds in z_correction_for_y_on_vertical_mesh_line(ly0=", ly0);
271
+        SERIAL_ECHOPAIR(", xi=", xi);
272
+        SERIAL_ECHOPAIR(", y1_i=", y1_i);
273
+        SERIAL_CHAR(')');
274
+        SERIAL_EOL();
275
+        return NAN;
227 276
       }
228 277
 
229
-      /**
230
-       *                           z2   --|
231
-       *                 z0        |      |
232
-       *                  |        |      + (z2-z1)
233
-       *   z1             |        |      |
234
-       * ---+-------------+--------+--  --|
235
-       *   a1            a0        a2
236
-       *    |<---delta_a---------->|
237
-       *
238
-       *  calc_z0 is the basis for all the Mesh Based correction. It is used to
239
-       *  find the expected Z Height at a position between two known Z-Height locations.
240
-       *
241
-       *  It is fairly expensive with its 4 floating point additions and 2 floating point
242
-       *  multiplications.
243
-       */
244
-      FORCE_INLINE static float calc_z0(const float &a0, const float &a1, const float &z1, const float &a2, const float &z2) {
245
-        return z1 + (z2 - z1) * (a0 - a1) / (a2 - a1);
246
-      }
278
+      const float yratio = (RAW_Y_POSITION(ly0) - mesh_index_to_ypos(y1_i)) * (1.0 / (MESH_Y_DIST)),
279
+                  z1 = z_values[xi][y1_i];
247 280
 
248
-      /**
249
-       * z_correction_for_x_on_horizontal_mesh_line is an optimization for
250
-       * the case where the printer is making a vertical line that only crosses horizontal mesh lines.
251
-       */
252
-      inline static float z_correction_for_x_on_horizontal_mesh_line(const float &lx0, const int x1_i, const int yi) {
253
-        if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 2) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
254
-          serialprintPGM( !WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) ? PSTR("x1l_i") : PSTR("yi") );
255
-          SERIAL_ECHOPAIR(" out of bounds in z_correction_for_x_on_horizontal_mesh_line(lx0=", lx0);
256
-          SERIAL_ECHOPAIR(",x1_i=", x1_i);
257
-          SERIAL_ECHOPAIR(",yi=", yi);
258
-          SERIAL_CHAR(')');
259
-          SERIAL_EOL();
260
-          return NAN;
261
-        }
281
+      return z1 + yratio * (z_values[xi][y1_i + 1] - z1);
282
+    }
262 283
 
263
-        const float xratio = (RAW_X_POSITION(lx0) - mesh_index_to_xpos(x1_i)) * (1.0 / (MESH_X_DIST)),
264
-                    z1 = z_values[x1_i][yi];
284
+    /**
285
+     * This is the generic Z-Correction. It works anywhere within a Mesh Cell. It first
286
+     * does a linear interpolation along both of the bounding X-Mesh-Lines to find the
287
+     * Z-Height at both ends. Then it does a linear interpolation of these heights based
288
+     * on the Y position within the cell.
289
+     */
290
+    static float get_z_correction(const float &lx0, const float &ly0) {
291
+      const int8_t cx = get_cell_index_x(RAW_X_POSITION(lx0)),
292
+                   cy = get_cell_index_y(RAW_Y_POSITION(ly0));
265 293
 
266
-        return z1 + xratio * (z_values[x1_i + 1][yi] - z1);
267
-      }
294
+      if (!WITHIN(cx, 0, GRID_MAX_POINTS_X - 2) || !WITHIN(cy, 0, GRID_MAX_POINTS_Y - 2)) {
268 295
 
269
-      //
270
-      // See comments above for z_correction_for_x_on_horizontal_mesh_line
271
-      //
272
-      inline static float z_correction_for_y_on_vertical_mesh_line(const float &ly0, const int xi, const int y1_i) {
273
-        if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 2)) {
274
-          serialprintPGM( !WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) ? PSTR("xi") : PSTR("yl_i") );
275
-          SERIAL_ECHOPAIR(" out of bounds in z_correction_for_y_on_vertical_mesh_line(ly0=", ly0);
276
-          SERIAL_ECHOPAIR(", xi=", xi);
277
-          SERIAL_ECHOPAIR(", y1_i=", y1_i);
278
-          SERIAL_CHAR(')');
279
-          SERIAL_EOL();
280
-          return NAN;
281
-        }
296
+        SERIAL_ECHOPAIR("? in get_z_correction(lx0=", lx0);
297
+        SERIAL_ECHOPAIR(", ly0=", ly0);
298
+        SERIAL_CHAR(')');
299
+        SERIAL_EOL();
282 300
 
283
-        const float yratio = (RAW_Y_POSITION(ly0) - mesh_index_to_ypos(y1_i)) * (1.0 / (MESH_Y_DIST)),
284
-                    z1 = z_values[xi][y1_i];
285
-
286
-        return z1 + yratio * (z_values[xi][y1_i + 1] - z1);
301
+        #if ENABLED(ULTRA_LCD)
302
+          strcpy(lcd_status_message, "get_z_correction() indexes out of range.");
303
+          lcd_quick_feedback();
304
+        #endif
305
+        return NAN; // this used to return state.z_offset
287 306
       }
288 307
 
289
-      /**
290
-       * This is the generic Z-Correction. It works anywhere within a Mesh Cell. It first
291
-       * does a linear interpolation along both of the bounding X-Mesh-Lines to find the
292
-       * Z-Height at both ends. Then it does a linear interpolation of these heights based
293
-       * on the Y position within the cell.
294
-       */
295
-      static float get_z_correction(const float &lx0, const float &ly0) {
296
-        const int8_t cx = get_cell_index_x(RAW_X_POSITION(lx0)),
297
-                     cy = get_cell_index_y(RAW_Y_POSITION(ly0));
298
-
299
-        if (!WITHIN(cx, 0, GRID_MAX_POINTS_X - 2) || !WITHIN(cy, 0, GRID_MAX_POINTS_Y - 2)) {
300
-
301
-          SERIAL_ECHOPAIR("? in get_z_correction(lx0=", lx0);
302
-          SERIAL_ECHOPAIR(", ly0=", ly0);
303
-          SERIAL_CHAR(')');
304
-          SERIAL_EOL();
305
-
306
-          #if ENABLED(ULTRA_LCD)
307
-            strcpy(lcd_status_message, "get_z_correction() indexes out of range.");
308
-            lcd_quick_feedback();
309
-          #endif
310
-          return NAN; // this used to return state.z_offset
308
+      const float z1 = calc_z0(RAW_X_POSITION(lx0),
309
+                               mesh_index_to_xpos(cx), z_values[cx][cy],
310
+                               mesh_index_to_xpos(cx + 1), z_values[cx + 1][cy]);
311
+
312
+      const float z2 = calc_z0(RAW_X_POSITION(lx0),
313
+                               mesh_index_to_xpos(cx), z_values[cx][cy + 1],
314
+                               mesh_index_to_xpos(cx + 1), z_values[cx + 1][cy + 1]);
315
+
316
+      float z0 = calc_z0(RAW_Y_POSITION(ly0),
317
+                         mesh_index_to_ypos(cy), z1,
318
+                         mesh_index_to_ypos(cy + 1), z2);
319
+
320
+      #if ENABLED(DEBUG_LEVELING_FEATURE)
321
+        if (DEBUGGING(MESH_ADJUST)) {
322
+          SERIAL_ECHOPAIR(" raw get_z_correction(", lx0);
323
+          SERIAL_CHAR(',');
324
+          SERIAL_ECHO(ly0);
325
+          SERIAL_ECHOPGM(") = ");
326
+          SERIAL_ECHO_F(z0, 6);
311 327
         }
328
+      #endif
312 329
 
313
-        const float z1 = calc_z0(RAW_X_POSITION(lx0),
314
-                                 mesh_index_to_xpos(cx), z_values[cx][cy],
315
-                                 mesh_index_to_xpos(cx + 1), z_values[cx + 1][cy]);
316
-
317
-        const float z2 = calc_z0(RAW_X_POSITION(lx0),
318
-                                 mesh_index_to_xpos(cx), z_values[cx][cy + 1],
319
-                                 mesh_index_to_xpos(cx + 1), z_values[cx + 1][cy + 1]);
330
+      #if ENABLED(DEBUG_LEVELING_FEATURE)
331
+        if (DEBUGGING(MESH_ADJUST)) {
332
+          SERIAL_ECHOPGM(" >>>---> ");
333
+          SERIAL_ECHO_F(z0, 6);
334
+          SERIAL_EOL();
335
+        }
336
+      #endif
320 337
 
321
-        float z0 = calc_z0(RAW_Y_POSITION(ly0),
322
-                           mesh_index_to_ypos(cy), z1,
323
-                           mesh_index_to_ypos(cy + 1), z2);
338
+      if (isnan(z0)) { // if part of the Mesh is undefined, it will show up as NAN
339
+        z0 = 0.0;      // in ubl.z_values[][] and propagate through the
340
+                       // calculations. If our correction is NAN, we throw it out
341
+                       // because part of the Mesh is undefined and we don't have the
342
+                       // information we need to complete the height correction.
324 343
 
325 344
         #if ENABLED(DEBUG_LEVELING_FEATURE)
326 345
           if (DEBUGGING(MESH_ADJUST)) {
327
-            SERIAL_ECHOPAIR(" raw get_z_correction(", lx0);
346
+            SERIAL_ECHOPAIR("??? Yikes!  NAN in get_z_correction(", lx0);
328 347
             SERIAL_CHAR(',');
329 348
             SERIAL_ECHO(ly0);
330
-            SERIAL_ECHOPGM(") = ");
331
-            SERIAL_ECHO_F(z0, 6);
332
-          }
333
-        #endif
334
-
335
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
336
-          if (DEBUGGING(MESH_ADJUST)) {
337
-            SERIAL_ECHOPGM(" >>>---> ");
338
-            SERIAL_ECHO_F(z0, 6);
349
+            SERIAL_CHAR(')');
339 350
             SERIAL_EOL();
340 351
           }
341 352
         #endif
342
-
343
-        if (isnan(z0)) { // if part of the Mesh is undefined, it will show up as NAN
344
-          z0 = 0.0;      // in ubl.z_values[][] and propagate through the
345
-                         // calculations. If our correction is NAN, we throw it out
346
-                         // because part of the Mesh is undefined and we don't have the
347
-                         // information we need to complete the height correction.
348
-
349
-          #if ENABLED(DEBUG_LEVELING_FEATURE)
350
-            if (DEBUGGING(MESH_ADJUST)) {
351
-              SERIAL_ECHOPAIR("??? Yikes!  NAN in get_z_correction(", lx0);
352
-              SERIAL_CHAR(',');
353
-              SERIAL_ECHO(ly0);
354
-              SERIAL_CHAR(')');
355
-              SERIAL_EOL();
356
-            }
357
-          #endif
358
-        }
359
-        return z0; // there used to be a +state.z_offset on this line
360 353
       }
361
-
362
-      /**
363
-       * This function sets the Z leveling fade factor based on the given Z height,
364
-       * only re-calculating when necessary.
365
-       *
366
-       *  Returns 1.0 if planner.z_fade_height is 0.0.
367
-       *  Returns 0.0 if Z is past the specified 'Fade Height'.
368
-       */
369
-      #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
370
-        static inline float fade_scaling_factor_for_z(const float &lz) {
371
-          if (planner.z_fade_height == 0.0) return 1.0;
372
-          static float fade_scaling_factor = 1.0;
373
-          const float rz = RAW_Z_POSITION(lz);
374
-          if (last_specified_z != rz) {
375
-            last_specified_z = rz;
376
-            fade_scaling_factor =
377
-              rz < planner.z_fade_height
378
-                ? 1.0 - (rz * planner.inverse_z_fade_height)
379
-                : 0.0;
380
-          }
381
-          return fade_scaling_factor;
354
+      return z0; // there used to be a +state.z_offset on this line
355
+    }
356
+
357
+    /**
358
+     * This function sets the Z leveling fade factor based on the given Z height,
359
+     * only re-calculating when necessary.
360
+     *
361
+     *  Returns 1.0 if planner.z_fade_height is 0.0.
362
+     *  Returns 0.0 if Z is past the specified 'Fade Height'.
363
+     */
364
+    #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
365
+      static inline float fade_scaling_factor_for_z(const float &lz) {
366
+        if (planner.z_fade_height == 0.0) return 1.0;
367
+        static float fade_scaling_factor = 1.0;
368
+        const float rz = RAW_Z_POSITION(lz);
369
+        if (last_specified_z != rz) {
370
+          last_specified_z = rz;
371
+          fade_scaling_factor =
372
+            rz < planner.z_fade_height
373
+              ? 1.0 - (rz * planner.inverse_z_fade_height)
374
+              : 0.0;
382 375
         }
383
-      #else
384
-        FORCE_INLINE static float fade_scaling_factor_for_z(const float &lz) { return 1.0; }
385
-      #endif
386
-
387
-      FORCE_INLINE static float mesh_index_to_xpos(const uint8_t i) {
388
-        return i < GRID_MAX_POINTS_X ? pgm_read_float(&_mesh_index_to_xpos[i]) : UBL_MESH_MIN_X + i * (MESH_X_DIST);
389
-      }
390
-
391
-      FORCE_INLINE static float mesh_index_to_ypos(const uint8_t i) {
392
-        return i < GRID_MAX_POINTS_Y ? pgm_read_float(&_mesh_index_to_ypos[i]) : UBL_MESH_MIN_Y + i * (MESH_Y_DIST);
376
+        return fade_scaling_factor;
393 377
       }
378
+    #else
379
+      FORCE_INLINE static float fade_scaling_factor_for_z(const float &lz) { return 1.0; }
380
+    #endif
394 381
 
395
-      static bool prepare_segmented_line_to(const float ltarget[XYZE], const float &feedrate);
396
-      static void line_to_destination_cartesian(const float &fr, uint8_t e);
382
+    FORCE_INLINE static float mesh_index_to_xpos(const uint8_t i) {
383
+      return i < GRID_MAX_POINTS_X ? pgm_read_float(&_mesh_index_to_xpos[i]) : UBL_MESH_MIN_X + i * (MESH_X_DIST);
384
+    }
397 385
 
398
-  }; // class unified_bed_leveling
386
+    FORCE_INLINE static float mesh_index_to_ypos(const uint8_t i) {
387
+      return i < GRID_MAX_POINTS_Y ? pgm_read_float(&_mesh_index_to_ypos[i]) : UBL_MESH_MIN_Y + i * (MESH_Y_DIST);
388
+    }
399 389
 
400
-  extern unified_bed_leveling ubl;
390
+    static bool prepare_segmented_line_to(const float ltarget[XYZE], const float &feedrate);
391
+    static void line_to_destination_cartesian(const float &fr, uint8_t e);
401 392
 
402
-  #if ENABLED(UBL_G26_MESH_VALIDATION)
403
-    FORCE_INLINE void gcode_G26() { ubl.G26(); }
404
-  #endif
393
+}; // class unified_bed_leveling
405 394
 
406
-  FORCE_INLINE void gcode_G29() { ubl.G29(); }
395
+extern unified_bed_leveling ubl;
407 396
 
408
-#endif // AUTO_BED_LEVELING_UBL
409 397
 #endif // UNIFIED_BED_LEVELING_H

+ 10
- 9
Marlin/src/feature/ubl/ubl_G29.cpp 查看文件

@@ -20,21 +20,22 @@
20 20
  *
21 21
  */
22 22
 
23
-#include "MarlinConfig.h"
23
+#include "../../inc/MarlinConfig.h"
24 24
 
25 25
 #if ENABLED(AUTO_BED_LEVELING_UBL)
26 26
 
27 27
   #include "ubl.h"
28
-  #include "Marlin.h"
29
-  #include "hex_print_routines.h"
30
-  #include "configuration_store.h"
31
-  #include "ultralcd.h"
32
-  #include "stepper.h"
33
-  #include "planner.h"
34
-  #include "gcode.h"
28
+
29
+  #include "../../Marlin.h"
30
+  #include "../../libs/hex_print_routines.h"
31
+  #include "../../module/configuration_store.h"
32
+  #include "../../lcd/ultralcd.h"
33
+  #include "../../module/stepper.h"
34
+  #include "../../module/planner.h"
35
+  #include "../../gcode/parser.h"
36
+  #include "../../libs/least_squares_fit.h"
35 37
 
36 38
   #include <math.h>
37
-  #include "least_squares_fit.h"
38 39
 
39 40
   #define UBL_G29_P31
40 41
 

+ 6
- 4
Marlin/src/feature/ubl/ubl_motion.cpp 查看文件

@@ -19,14 +19,16 @@
19 19
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 20
  *
21 21
  */
22
-#include "MarlinConfig.h"
22
+#include "../../inc/MarlinConfig.h"
23 23
 
24 24
 #if ENABLED(AUTO_BED_LEVELING_UBL)
25 25
 
26
-  #include "Marlin.h"
27 26
   #include "ubl.h"
28
-  #include "planner.h"
29
-  #include "stepper.h"
27
+
28
+  #include "../../Marlin.h"
29
+  #include "../../module/planner.h"
30
+  #include "../../module/stepper.h"
31
+
30 32
   #include <math.h>
31 33
 
32 34
   extern float destination[XYZE];

Loading…
取消
儲存