Browse Source

Misc changes from struct refactor (#15289)

Scott Lahteine 5 years ago
parent
commit
c353eaa146
No account linked to committer's email address

+ 1
- 1
Marlin/src/HAL/shared/Delay.h View File

29
  *  DELAY_US(count): Delay execution in microseconds
29
  *  DELAY_US(count): Delay execution in microseconds
30
  */
30
  */
31
 
31
 
32
-#include "../../core/macros.h"
33
 #include "../../core/millis_t.h"
32
 #include "../../core/millis_t.h"
33
+#include "../../core/macros.h"
34
 
34
 
35
 #if defined(__arm__) || defined(__thumb__)
35
 #if defined(__arm__) || defined(__thumb__)
36
 
36
 

+ 0
- 11
Marlin/src/core/enum.h View File

61
 #define LOOP_ABC(VAR) LOOP_S_LE_N(VAR, A_AXIS, C_AXIS)
61
 #define LOOP_ABC(VAR) LOOP_S_LE_N(VAR, A_AXIS, C_AXIS)
62
 #define LOOP_ABCE(VAR) LOOP_S_LE_N(VAR, A_AXIS, E_AXIS)
62
 #define LOOP_ABCE(VAR) LOOP_S_LE_N(VAR, A_AXIS, E_AXIS)
63
 #define LOOP_ABCE_N(VAR) LOOP_S_L_N(VAR, A_AXIS, XYZE_N)
63
 #define LOOP_ABCE_N(VAR) LOOP_S_L_N(VAR, A_AXIS, XYZE_N)
64
-
65
-typedef enum {
66
-  LINEARUNIT_MM,
67
-  LINEARUNIT_INCH
68
-} LinearUnit;
69
-
70
-typedef enum {
71
-  TEMPUNIT_C,
72
-  TEMPUNIT_K,
73
-  TEMPUNIT_F
74
-} TempUnit;

+ 16
- 6
Marlin/src/core/macros.h View File

198
   }while(0)
198
   }while(0)
199
 
199
 
200
 // Macros for initializing arrays
200
 // Macros for initializing arrays
201
-#define ARRAY_6(v1, v2, v3, v4, v5, v6, ...) { v1, v2, v3, v4, v5, v6 }
202
-#define ARRAY_5(v1, v2, v3, v4, v5, ...)     { v1, v2, v3, v4, v5 }
203
-#define ARRAY_4(v1, v2, v3, v4, ...)         { v1, v2, v3, v4 }
204
-#define ARRAY_3(v1, v2, v3, ...)             { v1, v2, v3 }
205
-#define ARRAY_2(v1, v2, ...)                 { v1, v2 }
206
-#define ARRAY_1(v1, ...)                     { v1 }
201
+#define ARRAY_16(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,...) { A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P }
202
+#define ARRAY_15(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,...) { A,B,C,D,E,F,G,H,I,J,K,L,M,N,O }
203
+#define ARRAY_14(A,B,C,D,E,F,G,H,I,J,K,L,M,N,...) { A,B,C,D,E,F,G,H,I,J,K,L,M,N }
204
+#define ARRAY_13(A,B,C,D,E,F,G,H,I,J,K,L,M,...) { A,B,C,D,E,F,G,H,I,J,K,L,M }
205
+#define ARRAY_12(A,B,C,D,E,F,G,H,I,J,K,L,...) { A,B,C,D,E,F,G,H,I,J,K,L }
206
+#define ARRAY_11(A,B,C,D,E,F,G,H,I,J,K,...) { A,B,C,D,E,F,G,H,I,J,K }
207
+#define ARRAY_10(A,B,C,D,E,F,G,H,I,J,...) { A,B,C,D,E,F,G,H,I,J }
208
+#define ARRAY_9( A,B,C,D,E,F,G,H,I,...) { A,B,C,D,E,F,G,H,I }
209
+#define ARRAY_8( A,B,C,D,E,F,G,H,...) { A,B,C,D,E,F,G,H }
210
+#define ARRAY_7( A,B,C,D,E,F,G,...) { A,B,C,D,E,F,G }
211
+#define ARRAY_6( A,B,C,D,E,F,...) { A,B,C,D,E,F }
212
+#define ARRAY_5( A,B,C,D,E,...) { A,B,C,D,E }
213
+#define ARRAY_4( A,B,C,D,...) { A,B,C,D }
214
+#define ARRAY_3( A,B,C,...) { A,B,C }
215
+#define ARRAY_2( A,B,...) { A,B }
216
+#define ARRAY_1( A,...) { A }
207
 
217
 
208
 #define _ARRAY_N(N,V...) ARRAY_##N(V)
218
 #define _ARRAY_N(N,V...) ARRAY_##N(V)
209
 #define ARRAY_N(N,V...) _ARRAY_N(N,V)
219
 #define ARRAY_N(N,V...) _ARRAY_N(N,V)

+ 4
- 5
Marlin/src/feature/I2CPositionEncoder.cpp View File

334
 
334
 
335
   ec = false;
335
   ec = false;
336
 
336
 
337
-  LOOP_NA(i) {
337
+  LOOP_XYZ(i) {
338
     startCoord[i] = planner.get_axis_position_mm((AxisEnum)i);
338
     startCoord[i] = planner.get_axis_position_mm((AxisEnum)i);
339
     endCoord[i] = planner.get_axis_position_mm((AxisEnum)i);
339
     endCoord[i] = planner.get_axis_position_mm((AxisEnum)i);
340
   }
340
   }
341
-
342
   startCoord[encoderAxis] = startPosition;
341
   startCoord[encoderAxis] = startPosition;
343
   endCoord[encoderAxis] = endPosition;
342
   endCoord[encoderAxis] = endPosition;
344
 
343
 
393
   endDistance = soft_endstop[encoderAxis].max - 20;
392
   endDistance = soft_endstop[encoderAxis].max - 20;
394
   travelDistance = endDistance - startDistance;
393
   travelDistance = endDistance - startDistance;
395
 
394
 
396
-  LOOP_NA(i) {
397
-    startCoord[i] = planner.get_axis_position_mm((AxisEnum)i);
398
-    endCoord[i] = planner.get_axis_position_mm((AxisEnum)i);
395
+  LOOP_XYZ(a) {
396
+    startCoord[a] = planner.get_axis_position_mm((AxisEnum)a);
397
+    endCoord[a] = planner.get_axis_position_mm((AxisEnum)a);
399
   }
398
   }
400
 
399
 
401
   startCoord[encoderAxis] = startDistance;
400
   startCoord[encoderAxis] = startDistance;

+ 0
- 1
Marlin/src/feature/babystep.h View File

22
 #pragma once
22
 #pragma once
23
 
23
 
24
 #include "../inc/MarlinConfigPre.h"
24
 #include "../inc/MarlinConfigPre.h"
25
-#include "../core/enum.h"
26
 
25
 
27
 #if IS_CORE || EITHER(BABYSTEP_XY, I2C_POSITION_ENCODERS)
26
 #if IS_CORE || EITHER(BABYSTEP_XY, I2C_POSITION_ENCODERS)
28
   #define BS_TODO_AXIS(A) A
27
   #define BS_TODO_AXIS(A) A

+ 0
- 1
Marlin/src/feature/bedlevel/abl/abl.cpp View File

24
 
24
 
25
 #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
25
 #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
26
 
26
 
27
-#include "abl.h"
28
 #include "../bedlevel.h"
27
 #include "../bedlevel.h"
29
 
28
 
30
 #include "../../../module/motion.h"
29
 #include "../../../module/motion.h"

+ 6
- 6
Marlin/src/feature/bedlevel/bedlevel.h View File

23
 
23
 
24
 #include "../../inc/MarlinConfigPre.h"
24
 #include "../../inc/MarlinConfigPre.h"
25
 
25
 
26
-typedef struct {
27
-  int8_t x_index, y_index;
28
-  float distance; // When populated, the distance from the search location
29
-} mesh_index_pair;
30
-
31
 #if ENABLED(PROBE_MANUALLY)
26
 #if ENABLED(PROBE_MANUALLY)
32
   extern bool g29_in_progress;
27
   extern bool g29_in_progress;
33
 #else
28
 #else
60
 
55
 
61
 #if HAS_MESH
56
 #if HAS_MESH
62
 
57
 
63
-  typedef float (&bed_mesh_t)[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
58
+  typedef float bed_mesh_t[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
59
+
60
+  typedef struct {
61
+    int8_t x_index, y_index;
62
+    float distance; // When populated, the distance from the search location
63
+  } mesh_index_pair;
64
 
64
 
65
   #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
65
   #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
66
     #include "abl/abl.h"
66
     #include "abl/abl.h"

+ 2
- 2
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h View File

32
   MeshReset       // G29 S5
32
   MeshReset       // G29 S5
33
 };
33
 };
34
 
34
 
35
-#define MESH_X_DIST ((MESH_MAX_X - (MESH_MIN_X)) / (GRID_MAX_POINTS_X - 1))
36
-#define MESH_Y_DIST ((MESH_MAX_Y - (MESH_MIN_Y)) / (GRID_MAX_POINTS_Y - 1))
35
+#define MESH_X_DIST (float(MESH_MAX_X - (MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1))
36
+#define MESH_Y_DIST (float(MESH_MAX_Y - (MESH_MIN_Y)) / float(GRID_MAX_POINTS_Y - 1))
37
 #define _GET_MESH_X(I) mbl.index_to_xpos[I]
37
 #define _GET_MESH_X(I) mbl.index_to_xpos[I]
38
 #define _GET_MESH_Y(J) mbl.index_to_ypos[J]
38
 #define _GET_MESH_Y(J) mbl.index_to_ypos[J]
39
 #define Z_VALUES_ARR mbl.z_values
39
 #define Z_VALUES_ARR mbl.z_values

+ 18
- 6
Marlin/src/feature/bedlevel/ubl/ubl.cpp View File

24
 
24
 
25
 #if ENABLED(AUTO_BED_LEVELING_UBL)
25
 #if ENABLED(AUTO_BED_LEVELING_UBL)
26
 
26
 
27
-  #include "ubl.h"
27
+  #include "../bedlevel.h"
28
+
28
   unified_bed_leveling ubl;
29
   unified_bed_leveling ubl;
29
 
30
 
30
   #include "../../../module/configuration_store.h"
31
   #include "../../../module/configuration_store.h"
31
   #include "../../../module/planner.h"
32
   #include "../../../module/planner.h"
32
   #include "../../../module/motion.h"
33
   #include "../../../module/motion.h"
33
-  #include "../../bedlevel/bedlevel.h"
34
+  #include "../../../module/probe.h"
34
 
35
 
35
   #if ENABLED(EXTENSIBLE_UI)
36
   #if ENABLED(EXTENSIBLE_UI)
36
     #include "../../../lcd/extensible_ui/ui_api.h"
37
     #include "../../../lcd/extensible_ui/ui_api.h"
66
 
67
 
67
   float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
68
   float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
68
 
69
 
69
-  // 15 is the maximum nubmer of grid points supported + 1 safety margin for now,
70
-  // until determinism prevails
71
-  constexpr float unified_bed_leveling::_mesh_index_to_xpos[16],
72
-                  unified_bed_leveling::_mesh_index_to_ypos[16];
70
+  #define _GRIDPOS(A,N) (MESH_MIN_##A + N * (MESH_##A##_DIST))
71
+
72
+  const float
73
+  unified_bed_leveling::_mesh_index_to_xpos[GRID_MAX_POINTS_X] PROGMEM = ARRAY_N(GRID_MAX_POINTS_X,
74
+    _GRIDPOS(X,  0), _GRIDPOS(X,  1), _GRIDPOS(X,  2), _GRIDPOS(X,  3),
75
+    _GRIDPOS(X,  4), _GRIDPOS(X,  5), _GRIDPOS(X,  6), _GRIDPOS(X,  7),
76
+    _GRIDPOS(X,  8), _GRIDPOS(X,  9), _GRIDPOS(X, 10), _GRIDPOS(X, 11),
77
+    _GRIDPOS(X, 12), _GRIDPOS(X, 13), _GRIDPOS(X, 14), _GRIDPOS(X, 15)
78
+  ),
79
+  unified_bed_leveling::_mesh_index_to_ypos[GRID_MAX_POINTS_Y] PROGMEM = ARRAY_N(GRID_MAX_POINTS_Y,
80
+    _GRIDPOS(Y,  0), _GRIDPOS(Y,  1), _GRIDPOS(Y,  2), _GRIDPOS(Y,  3),
81
+    _GRIDPOS(Y,  4), _GRIDPOS(Y,  5), _GRIDPOS(Y,  6), _GRIDPOS(Y,  7),
82
+    _GRIDPOS(Y,  8), _GRIDPOS(Y,  9), _GRIDPOS(Y, 10), _GRIDPOS(Y, 11),
83
+    _GRIDPOS(Y, 12), _GRIDPOS(Y, 13), _GRIDPOS(Y, 14), _GRIDPOS(Y, 15)
84
+  );
73
 
85
 
74
   #if HAS_LCD_MENU
86
   #if HAS_LCD_MENU
75
     bool unified_bed_leveling::lcd_map_control = false;
87
     bool unified_bed_leveling::lcd_map_control = false;

+ 3
- 29
Marlin/src/feature/bedlevel/ubl/ubl.h View File

23
 
23
 
24
 //#define UBL_DEVEL_DEBUGGING
24
 //#define UBL_DEVEL_DEBUGGING
25
 
25
 
26
-#include "../bedlevel.h"
27
-#include "../../../module/planner.h"
28
 #include "../../../module/motion.h"
26
 #include "../../../module/motion.h"
29
-#include "../../../lcd/ultralcd.h"
30
-#include "../../../Marlin.h"
31
 
27
 
32
 #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
28
 #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
33
 #include "../../../core/debug_out.h"
29
 #include "../../../core/debug_out.h"
108
 
104
 
109
     static int8_t storage_slot;
105
     static int8_t storage_slot;
110
 
106
 
111
-    static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
112
-
113
-    // 15 is the maximum nubmer of grid points supported + 1 safety margin for now,
114
-    // until determinism prevails
115
-    static constexpr float _mesh_index_to_xpos[16] PROGMEM = {
116
-                              MESH_MIN_X +  0 * (MESH_X_DIST), MESH_MIN_X +  1 * (MESH_X_DIST),
117
-                              MESH_MIN_X +  2 * (MESH_X_DIST), MESH_MIN_X +  3 * (MESH_X_DIST),
118
-                              MESH_MIN_X +  4 * (MESH_X_DIST), MESH_MIN_X +  5 * (MESH_X_DIST),
119
-                              MESH_MIN_X +  6 * (MESH_X_DIST), MESH_MIN_X +  7 * (MESH_X_DIST),
120
-                              MESH_MIN_X +  8 * (MESH_X_DIST), MESH_MIN_X +  9 * (MESH_X_DIST),
121
-                              MESH_MIN_X + 10 * (MESH_X_DIST), MESH_MIN_X + 11 * (MESH_X_DIST),
122
-                              MESH_MIN_X + 12 * (MESH_X_DIST), MESH_MIN_X + 13 * (MESH_X_DIST),
123
-                              MESH_MIN_X + 14 * (MESH_X_DIST), MESH_MIN_X + 15 * (MESH_X_DIST)
124
-                            };
125
-
126
-    static constexpr float _mesh_index_to_ypos[16] PROGMEM = {
127
-                              MESH_MIN_Y +  0 * (MESH_Y_DIST), MESH_MIN_Y +  1 * (MESH_Y_DIST),
128
-                              MESH_MIN_Y +  2 * (MESH_Y_DIST), MESH_MIN_Y +  3 * (MESH_Y_DIST),
129
-                              MESH_MIN_Y +  4 * (MESH_Y_DIST), MESH_MIN_Y +  5 * (MESH_Y_DIST),
130
-                              MESH_MIN_Y +  6 * (MESH_Y_DIST), MESH_MIN_Y +  7 * (MESH_Y_DIST),
131
-                              MESH_MIN_Y +  8 * (MESH_Y_DIST), MESH_MIN_Y +  9 * (MESH_Y_DIST),
132
-                              MESH_MIN_Y + 10 * (MESH_Y_DIST), MESH_MIN_Y + 11 * (MESH_Y_DIST),
133
-                              MESH_MIN_Y + 12 * (MESH_Y_DIST), MESH_MIN_Y + 13 * (MESH_Y_DIST),
134
-                              MESH_MIN_Y + 14 * (MESH_Y_DIST), MESH_MIN_Y + 15 * (MESH_Y_DIST)
135
-                            };
107
+    static bed_mesh_t z_values;
108
+    static const float _mesh_index_to_xpos[GRID_MAX_POINTS_X],
109
+                       _mesh_index_to_ypos[GRID_MAX_POINTS_Y];
136
 
110
 
137
     #if HAS_LCD_MENU
111
     #if HAS_LCD_MENU
138
       static bool lcd_map_control;
112
       static bool lcd_map_control;

+ 7
- 9
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp View File

24
 
24
 
25
 #if ENABLED(AUTO_BED_LEVELING_UBL)
25
 #if ENABLED(AUTO_BED_LEVELING_UBL)
26
 
26
 
27
-  #include "ubl.h"
27
+  #include "../bedlevel.h"
28
 
28
 
29
   #include "../../../Marlin.h"
29
   #include "../../../Marlin.h"
30
   #include "../../../HAL/shared/persistent_store_api.h"
30
   #include "../../../HAL/shared/persistent_store_api.h"
33
   #include "../../../lcd/ultralcd.h"
33
   #include "../../../lcd/ultralcd.h"
34
   #include "../../../module/stepper.h"
34
   #include "../../../module/stepper.h"
35
   #include "../../../module/planner.h"
35
   #include "../../../module/planner.h"
36
+  #include "../../../module/motion.h"
36
   #include "../../../module/probe.h"
37
   #include "../../../module/probe.h"
37
   #include "../../../gcode/gcode.h"
38
   #include "../../../gcode/gcode.h"
38
-  #include "../../../core/serial.h"
39
-  #include "../../../gcode/parser.h"
40
-  #include "../../../feature/bedlevel/bedlevel.h"
41
   #include "../../../libs/least_squares_fit.h"
39
   #include "../../../libs/least_squares_fit.h"
42
 
40
 
43
   #if ENABLED(DUAL_X_CARRIAGE)
41
   #if ENABLED(DUAL_X_CARRIAGE)
783
         if (location.x_index >= 0) {    // mesh point found and is reachable by probe
781
         if (location.x_index >= 0) {    // mesh point found and is reachable by probe
784
           const float rawx = mesh_index_to_xpos(location.x_index),
782
           const float rawx = mesh_index_to_xpos(location.x_index),
785
                       rawy = mesh_index_to_ypos(location.y_index),
783
                       rawy = mesh_index_to_ypos(location.y_index),
786
-                      measured_z = probe_pt(rawx, rawy, stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling
784
+                      measured_z = probe_at_point(rawx, rawy, stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling
787
           z_values[location.x_index][location.y_index] = measured_z;
785
           z_values[location.x_index][location.y_index] = measured_z;
788
           #if ENABLED(EXTENSIBLE_UI)
786
           #if ENABLED(EXTENSIBLE_UI)
789
             ExtUI::onMeshUpdate(location.x_index, location.y_index, measured_z);
787
             ExtUI::onMeshUpdate(location.x_index, location.y_index, measured_z);
1410
           ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " 1/3"));
1408
           ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " 1/3"));
1411
         #endif
1409
         #endif
1412
 
1410
 
1413
-        measured_z = probe_pt(PROBE_PT_1_X, PROBE_PT_1_Y, PROBE_PT_RAISE, g29_verbose_level);
1411
+        measured_z = probe_at_point(PROBE_PT_1_X, PROBE_PT_1_Y, PROBE_PT_RAISE, g29_verbose_level);
1414
         if (isnan(measured_z))
1412
         if (isnan(measured_z))
1415
           abort_flag = true;
1413
           abort_flag = true;
1416
         else {
1414
         else {
1429
             ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " 2/3"));
1427
             ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " 2/3"));
1430
           #endif
1428
           #endif
1431
 
1429
 
1432
-          measured_z = probe_pt(PROBE_PT_2_X, PROBE_PT_2_Y, PROBE_PT_RAISE, g29_verbose_level);
1430
+          measured_z = probe_at_point(PROBE_PT_2_X, PROBE_PT_2_Y, PROBE_PT_RAISE, g29_verbose_level);
1433
           //z2 = measured_z;
1431
           //z2 = measured_z;
1434
           if (isnan(measured_z))
1432
           if (isnan(measured_z))
1435
             abort_flag = true;
1433
             abort_flag = true;
1449
             ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " 3/3"));
1447
             ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " 3/3"));
1450
           #endif
1448
           #endif
1451
 
1449
 
1452
-          measured_z = probe_pt(PROBE_PT_3_X, PROBE_PT_3_Y, PROBE_PT_STOW, g29_verbose_level);
1450
+          measured_z = probe_at_point(PROBE_PT_3_X, PROBE_PT_3_Y, PROBE_PT_STOW, g29_verbose_level);
1453
           //z3 = measured_z;
1451
           //z3 = measured_z;
1454
           if (isnan(measured_z))
1452
           if (isnan(measured_z))
1455
             abort_flag = true;
1453
             abort_flag = true;
1490
                 ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " %i/%i"), point_num, total_points);
1488
                 ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " %i/%i"), point_num, total_points);
1491
               #endif
1489
               #endif
1492
 
1490
 
1493
-              measured_z = probe_pt(rx, ry, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling
1491
+              measured_z = probe_at_point(rx, ry, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling
1494
 
1492
 
1495
               abort_flag = isnan(measured_z);
1493
               abort_flag = isnan(measured_z);
1496
 
1494
 

+ 0
- 1
Marlin/src/feature/digipot/digipot_mcp4018.cpp View File

24
 
24
 
25
 #if BOTH(DIGIPOT_I2C, DIGIPOT_MCP4018)
25
 #if BOTH(DIGIPOT_I2C, DIGIPOT_MCP4018)
26
 
26
 
27
-#include "../../core/enum.h"
28
 #include "Stream.h"
27
 #include "Stream.h"
29
 #include "utility/twi.h"
28
 #include "utility/twi.h"
30
 #include <SlowSoftI2CMaster.h>  //https://github.com/stawel/SlowSoftI2CMaster
29
 #include <SlowSoftI2CMaster.h>  //https://github.com/stawel/SlowSoftI2CMaster

+ 0
- 2
Marlin/src/feature/host_actions.h View File

23
 
23
 
24
 #include "../inc/MarlinConfigPre.h"
24
 #include "../inc/MarlinConfigPre.h"
25
 
25
 
26
-#include <stddef.h>
27
-
28
 void host_action(const char * const pstr, const bool eol=true);
26
 void host_action(const char * const pstr, const bool eol=true);
29
 
27
 
30
 #ifdef ACTION_ON_KILL
28
 #ifdef ACTION_ON_KILL

+ 2
- 2
Marlin/src/gcode/bedlevel/abl/G29.cpp View File

714
             ui.status_printf_P(0, PSTR(MSG_PROBING_MESH " %i/%i"), int(pt_index), int(GRID_MAX_POINTS));
714
             ui.status_printf_P(0, PSTR(MSG_PROBING_MESH " %i/%i"), int(pt_index), int(GRID_MAX_POINTS));
715
           #endif
715
           #endif
716
 
716
 
717
-          measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, raise_after, verbose_level);
717
+          measured_z = faux ? 0.001 * random(-100, 101) : probe_at_point(xProbe, yProbe, raise_after, verbose_level);
718
 
718
 
719
           if (isnan(measured_z)) {
719
           if (isnan(measured_z)) {
720
             set_bed_leveling_enabled(abl_should_enable);
720
             set_bed_leveling_enabled(abl_should_enable);
759
         // Retain the last probe position
759
         // Retain the last probe position
760
         xProbe = points[i].x;
760
         xProbe = points[i].x;
761
         yProbe = points[i].y;
761
         yProbe = points[i].y;
762
-        measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, raise_after, verbose_level);
762
+        measured_z = faux ? 0.001 * random(-100, 101) : probe_at_point(xProbe, yProbe, raise_after, verbose_level);
763
         if (isnan(measured_z)) {
763
         if (isnan(measured_z)) {
764
           set_bed_leveling_enabled(abl_should_enable);
764
           set_bed_leveling_enabled(abl_should_enable);
765
           break;
765
           break;

+ 1
- 1
Marlin/src/gcode/bedlevel/abl/M421.cpp View File

29
 #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
29
 #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
30
 
30
 
31
 #include "../../gcode.h"
31
 #include "../../gcode.h"
32
-#include "../../../feature/bedlevel/abl/abl.h"
32
+#include "../../../feature/bedlevel/bedlevel.h"
33
 
33
 
34
 #if ENABLED(EXTENSIBLE_UI)
34
 #if ENABLED(EXTENSIBLE_UI)
35
   #include "../../../lcd/extensible_ui/ui_api.h"
35
   #include "../../../lcd/extensible_ui/ui_api.h"

+ 1
- 1
Marlin/src/gcode/bedlevel/ubl/G29.cpp View File

29
 #if ENABLED(AUTO_BED_LEVELING_UBL)
29
 #if ENABLED(AUTO_BED_LEVELING_UBL)
30
 
30
 
31
 #include "../../gcode.h"
31
 #include "../../gcode.h"
32
-#include "../../../feature/bedlevel/ubl/ubl.h"
32
+#include "../../../feature/bedlevel/bedlevel.h"
33
 
33
 
34
 void GcodeSuite::G29() { ubl.G29(); }
34
 void GcodeSuite::G29() { ubl.G29(); }
35
 
35
 

+ 1
- 1
Marlin/src/gcode/calibrate/G33.cpp View File

190
  */
190
  */
191
 static float calibration_probe(const float &nx, const float &ny, const bool stow) {
191
 static float calibration_probe(const float &nx, const float &ny, const bool stow) {
192
   #if HAS_BED_PROBE
192
   #if HAS_BED_PROBE
193
-    return probe_pt(nx, ny, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, false);
193
+    return probe_at_point(nx, ny, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, false);
194
   #else
194
   #else
195
     UNUSED(stow);
195
     UNUSED(stow);
196
     return lcd_probe_pt(nx, ny);
196
     return lcd_probe_pt(nx, ny);

+ 1
- 1
Marlin/src/gcode/calibrate/G34_M422.cpp View File

162
         if (iteration == 0 || izstepper > 0) do_blocking_move_to_z(z_probe);
162
         if (iteration == 0 || izstepper > 0) do_blocking_move_to_z(z_probe);
163
 
163
 
164
         // Probe a Z height for each stepper.
164
         // Probe a Z height for each stepper.
165
-        const float z_probed_height = probe_pt(z_auto_align_xpos[zstepper], z_auto_align_ypos[zstepper], raise_after, 0, true);
165
+        const float z_probed_height = probe_at_point(z_auto_align_xpos[zstepper], z_auto_align_ypos[zstepper], raise_after, 0, true);
166
         if (isnan(z_probed_height)) {
166
         if (isnan(z_probed_height)) {
167
           SERIAL_ECHOLNPGM("Probing failed.");
167
           SERIAL_ECHOLNPGM("Probing failed.");
168
           err_break = true;
168
           err_break = true;

+ 2
- 2
Marlin/src/gcode/calibrate/M48.cpp View File

116
   float mean = 0.0, sigma = 0.0, min = 99999.9, max = -99999.9, sample_set[n_samples];
116
   float mean = 0.0, sigma = 0.0, min = 99999.9, max = -99999.9, sample_set[n_samples];
117
 
117
 
118
   // Move to the first point, deploy, and probe
118
   // Move to the first point, deploy, and probe
119
-  const float t = probe_pt(X_probe_location, Y_probe_location, raise_after, verbose_level);
119
+  const float t = probe_at_point(X_probe_location, Y_probe_location, raise_after, verbose_level);
120
   bool probing_good = !isnan(t);
120
   bool probing_good = !isnan(t);
121
 
121
 
122
   if (probing_good) {
122
   if (probing_good) {
190
       } // n_legs
190
       } // n_legs
191
 
191
 
192
       // Probe a single point
192
       // Probe a single point
193
-      sample_set[n] = probe_pt(X_probe_location, Y_probe_location, raise_after, 0);
193
+      sample_set[n] = probe_at_point(X_probe_location, Y_probe_location, raise_after, 0);
194
 
194
 
195
       // Break the loop if the probe fails
195
       // Break the loop if the probe fails
196
       probing_good = !isnan(sample_set[n]);
196
       probing_good = !isnan(sample_set[n]);

+ 9
- 2
Marlin/src/gcode/parser.h View File

34
   #include "../libs/hex_print_routines.h"
34
   #include "../libs/hex_print_routines.h"
35
 #endif
35
 #endif
36
 
36
 
37
+#if ENABLED(TEMPERATURE_UNITS_SUPPORT)
38
+  typedef enum : uint8_t { TEMPUNIT_C, TEMPUNIT_K, TEMPUNIT_F } TempUnit;
39
+#endif
40
+
41
+#if ENABLED(INCH_MODE_SUPPORT)
42
+  typedef enum : uint8_t { LINEARUNIT_MM, LINEARUNIT_INCH } LinearUnit;
43
+#endif
44
+
37
 /**
45
 /**
38
  * GCode parser
46
  * GCode parser
39
  *
47
  *
254
   // Units modes: Inches, Fahrenheit, Kelvin
262
   // Units modes: Inches, Fahrenheit, Kelvin
255
 
263
 
256
   #if ENABLED(INCH_MODE_SUPPORT)
264
   #if ENABLED(INCH_MODE_SUPPORT)
257
-
258
     static inline float mm_to_linear_unit(const float mm)     { return mm / linear_unit_factor; }
265
     static inline float mm_to_linear_unit(const float mm)     { return mm / linear_unit_factor; }
259
     static inline float mm_to_volumetric_unit(const float mm) { return mm / (volumetric_enabled ? volumetric_unit_factor : linear_unit_factor); }
266
     static inline float mm_to_volumetric_unit(const float mm) { return mm / (volumetric_enabled ? volumetric_unit_factor : linear_unit_factor); }
260
 
267
 
298
 
305
 
299
   #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
306
   #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
300
 
307
 
301
-    static inline void set_input_temp_units(TempUnit units) { input_temp_units = units; }
308
+    static inline void set_input_temp_units(const TempUnit units) { input_temp_units = units; }
302
 
309
 
303
     #if HAS_LCD_MENU && DISABLED(DISABLE_M503)
310
     #if HAS_LCD_MENU && DISABLED(DISABLE_M503)
304
 
311
 

+ 1
- 1
Marlin/src/gcode/probe/G30.cpp View File

52
   setup_for_endstop_or_probe_move();
52
   setup_for_endstop_or_probe_move();
53
 
53
 
54
   const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
54
   const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
55
-  const float measured_z = probe_pt(xpos, ypos, raise_after, 1);
55
+  const float measured_z = probe_at_point(xpos, ypos, raise_after, 1);
56
 
56
 
57
   if (!isnan(measured_z))
57
   if (!isnan(measured_z))
58
     SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(xpos), " Y: ", FIXFLOAT(ypos), " Z: ", FIXFLOAT(measured_z));
58
     SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(xpos), " Y: ", FIXFLOAT(ypos), " Z: ", FIXFLOAT(measured_z));

+ 1
- 2
Marlin/src/inc/MarlinConfigPre.h View File

28
 //
28
 //
29
 // Prefix header to acquire configurations
29
 // Prefix header to acquire configurations
30
 //
30
 //
31
+#include <stdint.h>
31
 
32
 
32
 #include "../HAL/platforms.h"
33
 #include "../HAL/platforms.h"
33
 
34
 
45
 
46
 
46
 #include "Conditionals_adv.h"
47
 #include "Conditionals_adv.h"
47
 #include HAL_PATH(../HAL, inc/Conditionals_adv.h)
48
 #include HAL_PATH(../HAL, inc/Conditionals_adv.h)
48
-
49
-#include <stdint.h>

+ 1
- 1
Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp View File

47
 #endif
47
 #endif
48
 
48
 
49
 #if ENABLED(AUTO_BED_LEVELING_UBL)
49
 #if ENABLED(AUTO_BED_LEVELING_UBL)
50
-  #include "../../feature/bedlevel/ubl/ubl.h"
50
+  #include "../../feature/bedlevel/bedlevel.h"
51
 #endif
51
 #endif
52
 
52
 
53
 //
53
 //

+ 1
- 1
Marlin/src/lcd/dogm/ultralcd_DOGM.cpp View File

60
 #endif
60
 #endif
61
 
61
 
62
 #if ENABLED(AUTO_BED_LEVELING_UBL)
62
 #if ENABLED(AUTO_BED_LEVELING_UBL)
63
-  #include "../../feature/bedlevel/ubl/ubl.h"
63
+  #include "../../feature/bedlevel/bedlevel.h"
64
 #endif
64
 #endif
65
 
65
 
66
 /**
66
 /**

+ 1
- 1
Marlin/src/lcd/extensible_ui/ui_api.cpp View File

809
     void setLevelingActive(const bool state) { set_bed_leveling_enabled(state); }
809
     void setLevelingActive(const bool state) { set_bed_leveling_enabled(state); }
810
     bool getMeshValid() { return leveling_is_valid(); }
810
     bool getMeshValid() { return leveling_is_valid(); }
811
     #if HAS_MESH
811
     #if HAS_MESH
812
-      bed_mesh_t getMeshArray() { return Z_VALUES_ARR; }
812
+      bed_mesh_t& getMeshArray() { return Z_VALUES_ARR; }
813
       float getMeshPoint(const uint8_t xpos, const uint8_t ypos) { return Z_VALUES(xpos,ypos); }
813
       float getMeshPoint(const uint8_t xpos, const uint8_t ypos) { return Z_VALUES(xpos,ypos); }
814
       void setMeshPoint(const uint8_t xpos, const uint8_t ypos, const float zoff) {
814
       void setMeshPoint(const uint8_t xpos, const uint8_t ypos, const float zoff) {
815
         if (WITHIN(xpos, 0, GRID_MAX_POINTS_X) && WITHIN(ypos, 0, GRID_MAX_POINTS_Y)) {
815
         if (WITHIN(xpos, 0, GRID_MAX_POINTS_X) && WITHIN(ypos, 0, GRID_MAX_POINTS_Y)) {

+ 2
- 2
Marlin/src/lcd/extensible_ui/ui_api.h View File

61
   constexpr uint8_t fanCount      = FAN_COUNT;
61
   constexpr uint8_t fanCount      = FAN_COUNT;
62
 
62
 
63
   #if HAS_MESH
63
   #if HAS_MESH
64
-    typedef float (&bed_mesh_t)[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
64
+    typedef float bed_mesh_t[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
65
   #endif
65
   #endif
66
 
66
 
67
   bool isMoving();
67
   bool isMoving();
128
     void setLevelingActive(const bool);
128
     void setLevelingActive(const bool);
129
     bool getMeshValid();
129
     bool getMeshValid();
130
     #if HAS_MESH
130
     #if HAS_MESH
131
-      bed_mesh_t getMeshArray();
131
+      bed_mesh_t& getMeshArray();
132
       float getMeshPoint(const uint8_t xpos, const uint8_t ypos);
132
       float getMeshPoint(const uint8_t xpos, const uint8_t ypos);
133
       void setMeshPoint(const uint8_t xpos, const uint8_t ypos, const float zval);
133
       void setMeshPoint(const uint8_t xpos, const uint8_t ypos, const float zval);
134
       void onMeshUpdate(const uint8_t xpos, const uint8_t ypos, const float zval);
134
       void onMeshUpdate(const uint8_t xpos, const uint8_t ypos, const float zval);

+ 3
- 3
Marlin/src/lcd/fontutils.h View File

8
  */
8
  */
9
 #pragma once
9
 #pragma once
10
 
10
 
11
-#include "../HAL/shared/Marduino.h"
12
-#include "../core/macros.h"
13
-
14
 #include <stdlib.h>
11
 #include <stdlib.h>
15
 #include <stddef.h> // wchar_t
12
 #include <stddef.h> // wchar_t
16
 #include <stdint.h> // uint32_t
13
 #include <stdint.h> // uint32_t
17
 
14
 
15
+#include "../HAL/shared/Marduino.h"
16
+#include "../core/macros.h"
17
+
18
 // read a byte from ROM or RAM
18
 // read a byte from ROM or RAM
19
 typedef uint8_t (*read_byte_cb_t)(uint8_t * str);
19
 typedef uint8_t (*read_byte_cb_t)(uint8_t * str);
20
 
20
 

+ 2
- 2
Marlin/src/lcd/menu/menu_ubl.cpp View File

420
  */
420
  */
421
 void _lcd_ubl_map_lcd_edit_cmd() {
421
 void _lcd_ubl_map_lcd_edit_cmd() {
422
   char ubl_lcd_gcode[50], str[10], str2[10];
422
   char ubl_lcd_gcode[50], str[10], str2[10];
423
-  dtostrf(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]), 0, 2, str);
424
-  dtostrf(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]), 0, 2, str2);
423
+  dtostrf(ubl.mesh_index_to_xpos(x_plot), 0, 2, str);
424
+  dtostrf(ubl.mesh_index_to_ypos(y_plot), 0, 2, str2);
425
   snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29 P4 X%s Y%s R%i"), str, str2, int(n_edit_pts));
425
   snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29 P4 X%s Y%s R%i"), str, str2, int(n_edit_pts));
426
   lcd_enqueue_one_now(ubl_lcd_gcode);
426
   lcd_enqueue_one_now(ubl_lcd_gcode);
427
 }
427
 }

+ 3
- 3
Marlin/src/libs/least_squares_fit.h View File

44
         A, B, D, N;
44
         A, B, D, N;
45
 };
45
 };
46
 
46
 
47
-void inline incremental_LSF_reset(struct linear_fit_data *lsf) {
47
+inline void incremental_LSF_reset(struct linear_fit_data *lsf) {
48
   memset(lsf, 0, sizeof(linear_fit_data));
48
   memset(lsf, 0, sizeof(linear_fit_data));
49
 }
49
 }
50
 
50
 
51
-void inline incremental_WLSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z, const float &w) {
51
+inline void incremental_WLSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z, const float &w) {
52
   // weight each accumulator by factor w, including the "number" of samples
52
   // weight each accumulator by factor w, including the "number" of samples
53
   // (analogous to calling inc_LSF twice with same values to weight it by 2X)
53
   // (analogous to calling inc_LSF twice with same values to weight it by 2X)
54
   const float wx = w * x, wy = w * y, wz = w * z;
54
   const float wx = w * x, wy = w * y, wz = w * z;
66
   lsf->max_absy = _MAX(ABS(wy), lsf->max_absy);
66
   lsf->max_absy = _MAX(ABS(wy), lsf->max_absy);
67
 }
67
 }
68
 
68
 
69
-void inline incremental_LSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z) {
69
+inline void incremental_LSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z) {
70
   lsf->xbar += x;
70
   lsf->xbar += x;
71
   lsf->ybar += y;
71
   lsf->ybar += y;
72
   lsf->zbar += z;
72
   lsf->zbar += z;

+ 4
- 0
Marlin/src/module/motion.h View File

34
   #include "scara.h"
34
   #include "scara.h"
35
 #endif
35
 #endif
36
 
36
 
37
+#if HAS_BED_PROBE
38
+  #include "probe.h"
39
+#endif
40
+
37
 // Axis homed and known-position states
41
 // Axis homed and known-position states
38
 extern uint8_t axis_homed, axis_known_position;
42
 extern uint8_t axis_homed, axis_known_position;
39
 constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS);
43
 constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS);

+ 1
- 1
Marlin/src/module/probe.cpp View File

683
  *   - Raise to the BETWEEN height
683
  *   - Raise to the BETWEEN height
684
  * - Return the probed Z position
684
  * - Return the probed Z position
685
  */
685
  */
686
-float probe_pt(const float &rx, const float &ry, const ProbePtRaise raise_after/*=PROBE_PT_NONE*/, const uint8_t verbose_level/*=0*/, const bool probe_relative/*=true*/) {
686
+float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after/*=PROBE_PT_NONE*/, const uint8_t verbose_level/*=0*/, const bool probe_relative/*=true*/) {
687
   if (DEBUGGING(LEVELING)) {
687
   if (DEBUGGING(LEVELING)) {
688
     DEBUG_ECHOLNPAIR(
688
     DEBUG_ECHOLNPAIR(
689
       ">>> probe_pt(", LOGICAL_X_POSITION(rx), ", ", LOGICAL_Y_POSITION(ry),
689
       ">>> probe_pt(", LOGICAL_X_POSITION(rx), ", ", LOGICAL_Y_POSITION(ry),

+ 1
- 1
Marlin/src/module/probe.h View File

39
     PROBE_PT_RAISE, // Raise to "between" clearance after run_z_probe
39
     PROBE_PT_RAISE, // Raise to "between" clearance after run_z_probe
40
     PROBE_PT_BIG_RAISE  // Raise to big clearance after run_z_probe
40
     PROBE_PT_BIG_RAISE  // Raise to big clearance after run_z_probe
41
   };
41
   };
42
-  float probe_pt(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true);
42
+  float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true);
43
   #define DEPLOY_PROBE() set_probe_deployed(true)
43
   #define DEPLOY_PROBE() set_probe_deployed(true)
44
   #define STOW_PROBE() set_probe_deployed(false)
44
   #define STOW_PROBE() set_probe_deployed(false)
45
   #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
45
   #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)

+ 2
- 2
Marlin/src/module/temperature.cpp View File

245
       int16_t Temperature::maxtemp_raw_CHAMBER = HEATER_CHAMBER_RAW_HI_TEMP;
245
       int16_t Temperature::maxtemp_raw_CHAMBER = HEATER_CHAMBER_RAW_HI_TEMP;
246
     #endif
246
     #endif
247
     #if WATCH_CHAMBER
247
     #if WATCH_CHAMBER
248
-      heater_watch_t Temperature::watch_chamber = { 0 };
248
+      heater_watch_t Temperature::watch_chamber{0};
249
     #endif
249
     #endif
250
     millis_t Temperature::next_chamber_check_ms;
250
     millis_t Temperature::next_chamber_check_ms;
251
   #endif // HAS_HEATED_CHAMBER
251
   #endif // HAS_HEATED_CHAMBER
930
 
930
 
931
     #if DISABLED(PID_OPENLOOP)
931
     #if DISABLED(PID_OPENLOOP)
932
 
932
 
933
-      static PID_t work_pid = { 0 };
933
+      static PID_t work_pid{0};
934
       static float temp_iState = 0, temp_dState = 0;
934
       static float temp_iState = 0, temp_dState = 0;
935
       static bool pid_reset = true;
935
       static bool pid_reset = true;
936
       float pid_output = 0;
936
       float pid_output = 0;

Loading…
Cancel
Save