Browse Source

Adapt G26 to work for all meshes

Scott Lahteine 7 years ago
parent
commit
c6b0c104bb

+ 3
- 3
.travis.yml View File

72
   # Test a probeless build of AUTO_BED_LEVELING_UBL
72
   # Test a probeless build of AUTO_BED_LEVELING_UBL
73
   #
73
   #
74
   - restore_configs
74
   - restore_configs
75
-  - opt_enable AUTO_BED_LEVELING_UBL UBL_G26_MESH_EDITING ENABLE_LEVELING_FADE_HEIGHT EEPROM_SETTINGS G3D_PANEL
75
+  - opt_enable AUTO_BED_LEVELING_UBL G26_MESH_EDITING ENABLE_LEVELING_FADE_HEIGHT EEPROM_SETTINGS G3D_PANEL
76
   - opt_enable_adv CUSTOM_USER_MENUS I2C_POSITION_ENCODERS BABYSTEPPING
76
   - opt_enable_adv CUSTOM_USER_MENUS I2C_POSITION_ENCODERS BABYSTEPPING
77
   - build_marlin_pio ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM}
77
   - build_marlin_pio ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM}
78
   #
78
   #
101
   # Test MESH_BED_LEVELING feature, with LCD
101
   # Test MESH_BED_LEVELING feature, with LCD
102
   #
102
   #
103
   - restore_configs
103
   - restore_configs
104
-  - opt_enable MESH_BED_LEVELING MESH_G28_REST_ORIGIN LCD_BED_LEVELING ULTIMAKERCONTROLLER
104
+  - opt_enable MESH_BED_LEVELING G26_MESH_EDITING MESH_G28_REST_ORIGIN LCD_BED_LEVELING ULTIMAKERCONTROLLER
105
   - build_marlin_pio ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM}
105
   - build_marlin_pio ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM}
106
   #
106
   #
107
   # Test MINIRAMBO for PWM_MOTOR_CURRENT
107
   # Test MINIRAMBO for PWM_MOTOR_CURRENT
115
   #
115
   #
116
   - restore_configs
116
   - restore_configs
117
   - opt_set MOTHERBOARD BOARD_MINIRAMBO
117
   - opt_set MOTHERBOARD BOARD_MINIRAMBO
118
-  - opt_enable PROBE_MANUALLY AUTO_BED_LEVELING_BILINEAR LCD_BED_LEVELING ULTIMAKERCONTROLLER
118
+  - opt_enable PROBE_MANUALLY AUTO_BED_LEVELING_BILINEAR G26_MESH_EDITING LCD_BED_LEVELING ULTIMAKERCONTROLLER
119
   - opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT M100_FREE_MEMORY_WATCHER M100_FREE_MEMORY_DUMPER M100_FREE_MEMORY_CORRUPTOR INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT
119
   - opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT M100_FREE_MEMORY_WATCHER M100_FREE_MEMORY_DUMPER M100_FREE_MEMORY_CORRUPTOR INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT
120
   - opt_enable ULTIMAKERCONTROLLER SDSUPPORT
120
   - opt_enable ULTIMAKERCONTROLLER SDSUPPORT
121
   - opt_enable PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE PCA9632 USE_XMAX_PLUG
121
   - opt_enable PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE PCA9632 USE_XMAX_PLUG

+ 3
- 0
Marlin/src/core/macros.h View File

95
 #define STRINGIFY(M) STRINGIFY_(M)
95
 #define STRINGIFY(M) STRINGIFY_(M)
96
 
96
 
97
 // Macros for bit masks
97
 // Macros for bit masks
98
+#ifndef _BV
99
+  #define _BV(B) (1UL<<(B))
100
+#endif
98
 #define TEST(n,b) (((n)&_BV(b))!=0)
101
 #define TEST(n,b) (((n)&_BV(b))!=0)
99
 #define SBI(n,b) (n |= _BV(b))
102
 #define SBI(n,b) (n |= _BV(b))
100
 #define CBI(n,b) (n &= ~_BV(b))
103
 #define CBI(n,b) (n &= ~_BV(b))

+ 13
- 1
Marlin/src/core/utility.h View File

23
 #ifndef __UTILITY_H__
23
 #ifndef __UTILITY_H__
24
 #define __UTILITY_H__
24
 #define __UTILITY_H__
25
 
25
 
26
-#include "../inc/MarlinConfig.h"
26
+#include "../inc/MarlinConfigPre.h"
27
 
27
 
28
 constexpr char axis_codes[XYZE] = { 'X', 'Y', 'Z', 'E' };
28
 constexpr char axis_codes[XYZE] = { 'X', 'Y', 'Z', 'E' };
29
 
29
 
33
   void crc16(uint16_t *crc, const void * const data, uint16_t cnt);
33
   void crc16(uint16_t *crc, const void * const data, uint16_t cnt);
34
 #endif
34
 #endif
35
 
35
 
36
+#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
37
+  /**
38
+   * These support functions allow the use of large bit arrays of flags that take very
39
+   * little RAM. Currently they are limited to being 16x16 in size. Changing the declaration
40
+   * to unsigned long will allow us to go to 32x32 if higher resolution Mesh's are needed
41
+   * in the future.
42
+   */
43
+  FORCE_INLINE void bit_clear(uint16_t bits[16], const uint8_t x, const uint8_t y)  { CBI(bits[y], x); }
44
+  FORCE_INLINE void bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y)    { SBI(bits[y], x); }
45
+  FORCE_INLINE bool is_bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y) { return TEST(bits[y], x); }
46
+#endif
47
+
36
 #if ENABLED(ULTRA_LCD)
48
 #if ENABLED(ULTRA_LCD)
37
 
49
 
38
   // Convert uint8_t to string with 123 format
50
   // Convert uint8_t to string with 123 format

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

41
   #endif
41
   #endif
42
 #endif
42
 #endif
43
 
43
 
44
+#if G26_MESH_VALIDATION
45
+  bool g26_debug_flag; // = false
46
+#endif
47
+
44
 bool leveling_is_valid() {
48
 bool leveling_is_valid() {
45
   return
49
   return
46
     #if ENABLED(MESH_BED_LEVELING)
50
     #if ENABLED(MESH_BED_LEVELING)

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

23
 #ifndef __BEDLEVEL_H__
23
 #ifndef __BEDLEVEL_H__
24
 #define __BEDLEVEL_H__
24
 #define __BEDLEVEL_H__
25
 
25
 
26
-#include "../../inc/MarlinConfig.h"
26
+#include "../../inc/MarlinConfigPre.h"
27
 
27
 
28
-#if ENABLED(MESH_BED_LEVELING)
29
-  #include "mbl/mesh_bed_leveling.h"
30
-#elif ENABLED(AUTO_BED_LEVELING_UBL)
31
-  #include "ubl/ubl.h"
32
-#elif HAS_ABL
33
-  #include "abl/abl.h"
28
+typedef struct {
29
+  int8_t x_index, y_index;
30
+  float distance; // When populated, the distance from the search location
31
+} mesh_index_pair;
32
+
33
+#if ENABLED(G26_MESH_VALIDATION)
34
+  extern bool g26_debug_flag;
35
+#else
36
+  constexpr bool g26_debug_flag = false;
34
 #endif
37
 #endif
35
 
38
 
36
 #if ENABLED(PROBE_MANUALLY)
39
 #if ENABLED(PROBE_MANUALLY)
68
   void out_of_range_error(const char* p_edge);
71
   void out_of_range_error(const char* p_edge);
69
 #endif
72
 #endif
70
 
73
 
74
+#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
75
+  #define _GET_MESH_X(I) bilinear_start[X_AXIS] + I * bilinear_grid_spacing[X_AXIS]
76
+  #define _GET_MESH_Y(J) bilinear_start[Y_AXIS] + J * bilinear_grid_spacing[Y_AXIS]
77
+#elif ENABLED(AUTO_BED_LEVELING_UBL)
78
+  #define _GET_MESH_X(I) ubl.mesh_index_to_xpos(I)
79
+  #define _GET_MESH_Y(J) ubl.mesh_index_to_ypos(J)
80
+#elif ENABLED(MESH_BED_LEVELING)
81
+  #define _GET_MESH_X(I) mbl.index_to_xpos[I]
82
+  #define _GET_MESH_Y(J) mbl.index_to_ypos[J]
83
+#endif
84
+
85
+#if ENABLED(MESH_BED_LEVELING)
86
+  #include "mbl/mesh_bed_leveling.h"
87
+#elif ENABLED(AUTO_BED_LEVELING_UBL)
88
+  #include "ubl/ubl.h"
89
+#elif HAS_ABL
90
+  #include "abl/abl.h"
91
+#endif
92
+
71
 #endif // __BEDLEVEL_H__
93
 #endif // __BEDLEVEL_H__

+ 0
- 13
Marlin/src/feature/bedlevel/ubl/ubl.cpp View File

34
 
34
 
35
   #include "math.h"
35
   #include "math.h"
36
 
36
 
37
-  /**
38
-   * These support functions allow the use of large bit arrays of flags that take very
39
-   * little RAM. Currently they are limited to being 16x16 in size. Changing the declaration
40
-   * to unsigned long will allow us to go to 32x32 if higher resolution Mesh's are needed
41
-   * in the future.
42
-   */
43
-  void bit_clear(uint16_t bits[16], const uint8_t x, const uint8_t y) { CBI(bits[y], x); }
44
-  void bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y) { SBI(bits[y], x); }
45
-  bool is_bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y) { return TEST(bits[y], x); }
46
-
47
   uint8_t ubl_cnt = 0;
37
   uint8_t ubl_cnt = 0;
48
 
38
 
49
   void unified_bed_leveling::echo_name() { SERIAL_PROTOCOLPGM("Unified Bed Leveling"); }
39
   void unified_bed_leveling::echo_name() { SERIAL_PROTOCOLPGM("Unified Bed Leveling"); }
74
   constexpr float unified_bed_leveling::_mesh_index_to_xpos[16],
64
   constexpr float unified_bed_leveling::_mesh_index_to_xpos[16],
75
                   unified_bed_leveling::_mesh_index_to_ypos[16];
65
                   unified_bed_leveling::_mesh_index_to_ypos[16];
76
 
66
 
77
-  bool unified_bed_leveling::g26_debug_flag = false,
78
-       unified_bed_leveling::has_control_of_lcd_panel = false;
79
-
80
   #if ENABLED(ULTRA_LCD)
67
   #if ENABLED(ULTRA_LCD)
81
     bool unified_bed_leveling::lcd_map_control = false;
68
     bool unified_bed_leveling::lcd_map_control = false;
82
   #endif
69
   #endif

+ 2
- 50
Marlin/src/feature/bedlevel/ubl/ubl.h View File

23
 #ifndef UNIFIED_BED_LEVELING_H
23
 #ifndef UNIFIED_BED_LEVELING_H
24
 #define UNIFIED_BED_LEVELING_H
24
 #define UNIFIED_BED_LEVELING_H
25
 
25
 
26
-#include "../../../Marlin.h"
26
+#include "../bedlevel.h"
27
 #include "../../../module/planner.h"
27
 #include "../../../module/planner.h"
28
 #include "../../../module/motion.h"
28
 #include "../../../module/motion.h"
29
+#include "../../../Marlin.h"
29
 
30
 
30
 #define UBL_VERSION "1.01"
31
 #define UBL_VERSION "1.01"
31
 #define UBL_OK false
32
 #define UBL_OK false
34
 #define USE_NOZZLE_AS_REFERENCE 0
35
 #define USE_NOZZLE_AS_REFERENCE 0
35
 #define USE_PROBE_AS_REFERENCE 1
36
 #define USE_PROBE_AS_REFERENCE 1
36
 
37
 
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
38
 // ubl_motion.cpp
49
 
39
 
50
 void debug_current_and_destination(const char * const title);
40
 void debug_current_and_destination(const char * const title);
56
 // External references
46
 // External references
57
 
47
 
58
 char *ftostr43sign(const float&, char);
48
 char *ftostr43sign(const float&, char);
59
-bool ubl_lcd_clicked();
60
 
49
 
61
 extern uint8_t ubl_cnt;
50
 extern uint8_t ubl_cnt;
62
 
51
 
87
       static int  g29_grid_size;
76
       static int  g29_grid_size;
88
     #endif
77
     #endif
89
 
78
 
90
-    #if ENABLED(UBL_G26_MESH_VALIDATION)
91
-      static float   g26_extrusion_multiplier,
92
-                     g26_retraction_multiplier,
93
-                     g26_nozzle,
94
-                     g26_filament_diameter,
95
-                     g26_prime_length,
96
-                     g26_x_pos, g26_y_pos,
97
-                     g26_ooze_amount,
98
-                     g26_layer_height;
99
-      static int16_t g26_bed_temp,
100
-                     g26_hotend_temp,
101
-                     g26_repeats;
102
-      static int8_t  g26_prime_flag;
103
-      static bool    g26_continue_with_closest, g26_keep_heaters_on;
104
-    #endif
105
-
106
     static float measure_point_with_encoder();
79
     static float measure_point_with_encoder();
107
     static float measure_business_card_thickness(float);
80
     static float measure_business_card_thickness(float);
108
     static bool g29_parameter_parsing();
81
     static bool g29_parameter_parsing();
119
     static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir);
92
     static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir);
120
     static void smart_fill_mesh();
93
     static void smart_fill_mesh();
121
 
94
 
122
-    #if ENABLED(UBL_G26_MESH_VALIDATION)
123
-      static bool exit_from_g26();
124
-      static bool parse_G26_parameters();
125
-      static void G26_line_to_destination(const float &feed_rate);
126
-      static mesh_index_pair find_closest_circle_to_print(const float&, const float&);
127
-      static bool look_for_lines_to_connect();
128
-      static bool turn_on_heaters();
129
-      static bool prime_nozzle();
130
-      static void retract_filament(const float where[XYZE]);
131
-      static void recover_filament(const float where[XYZE]);
132
-      static void print_line_from_here_to_there(const float&, const float&, const float&, const float&, const float&, const float&);
133
-      static void move_to(const float&, const float&, const float&, const float&);
134
-      inline static void move_to(const float where[XYZE], const float &de) { move_to(where[X_AXIS], where[Y_AXIS], where[Z_AXIS], de); }
135
-    #endif
136
-
137
   public:
95
   public:
138
 
96
 
139
     static void echo_name();
97
     static void echo_name();
151
     static void G29() _O0;                          // O0 for no optimization
109
     static void G29() _O0;                          // O0 for no optimization
152
     static void smart_fill_wlsf(const float &) _O2; // O2 gives smaller code than Os on A2560
110
     static void smart_fill_wlsf(const float &) _O2; // O2 gives smaller code than Os on A2560
153
 
111
 
154
-    #if ENABLED(UBL_G26_MESH_VALIDATION)
155
-      static void G26();
156
-    #endif
157
-
158
     static int8_t storage_slot;
112
     static int8_t storage_slot;
159
 
113
 
160
     static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
114
     static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
183
                               MESH_MIN_Y + 14 * (MESH_Y_DIST), MESH_MIN_Y + 15 * (MESH_Y_DIST)
137
                               MESH_MIN_Y + 14 * (MESH_Y_DIST), MESH_MIN_Y + 15 * (MESH_Y_DIST)
184
                             };
138
                             };
185
 
139
 
186
-    static bool g26_debug_flag, has_control_of_lcd_panel;
187
-
188
     #if ENABLED(ULTRA_LCD)
140
     #if ENABLED(ULTRA_LCD)
189
       static bool lcd_map_control;
141
       static bool lcd_map_control;
190
     #endif
142
     #endif

+ 27
- 25
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp View File

677
       lcd_reset_alert_level();
677
       lcd_reset_alert_level();
678
       LCD_MESSAGEPGM("");
678
       LCD_MESSAGEPGM("");
679
       lcd_quick_feedback();
679
       lcd_quick_feedback();
680
-
681
-      has_control_of_lcd_panel = false;
680
+      lcd_external_control = false;
682
     #endif
681
     #endif
683
 
682
 
684
     return;
683
     return;
738
     void unified_bed_leveling::probe_entire_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map, const bool stow_probe, bool close_or_far) {
737
     void unified_bed_leveling::probe_entire_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map, const bool stow_probe, bool close_or_far) {
739
       mesh_index_pair location;
738
       mesh_index_pair location;
740
 
739
 
741
-      has_control_of_lcd_panel = true;
740
+      #if ENABLED(NEWPANEL)
741
+        lcd_external_control = true;
742
+      #endif
743
+
742
       save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
744
       save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
743
       DEPLOY_PROBE();
745
       DEPLOY_PROBE();
744
 
746
 
748
         if (do_ubl_mesh_map) display_map(g29_map_type);
750
         if (do_ubl_mesh_map) display_map(g29_map_type);
749
 
751
 
750
         #if ENABLED(NEWPANEL)
752
         #if ENABLED(NEWPANEL)
751
-          if (ubl_lcd_clicked()) {
753
+          if (is_lcd_clicked()) {
752
             SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.\n");
754
             SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.\n");
753
             lcd_quick_feedback();
755
             lcd_quick_feedback();
754
             STOW_PROBE();
756
             STOW_PROBE();
755
-            while (ubl_lcd_clicked()) idle();
756
-            has_control_of_lcd_panel = false;
757
+            while (is_lcd_clicked()) idle();
758
+            lcd_external_control = false;
757
             restore_ubl_active_state_and_leave();
759
             restore_ubl_active_state_and_leave();
758
             safe_delay(50);  // Debounce the Encoder wheel
760
             safe_delay(50);  // Debounce the Encoder wheel
759
             return;
761
             return;
894
 
896
 
895
     float unified_bed_leveling::measure_point_with_encoder() {
897
     float unified_bed_leveling::measure_point_with_encoder() {
896
 
898
 
897
-      while (ubl_lcd_clicked()) delay(50);  // wait for user to release encoder wheel
899
+      while (is_lcd_clicked()) delay(50);  // wait for user to release encoder wheel
898
       delay(50);  // debounce
900
       delay(50);  // debounce
899
 
901
 
900
       KEEPALIVE_STATE(PAUSED_FOR_USER);
902
       KEEPALIVE_STATE(PAUSED_FOR_USER);
901
-      while (!ubl_lcd_clicked()) {     // we need the loop to move the nozzle based on the encoder wheel here!
903
+      while (!is_lcd_clicked()) {     // we need the loop to move the nozzle based on the encoder wheel here!
902
         idle();
904
         idle();
903
         if (encoder_diff) {
905
         if (encoder_diff) {
904
           do_blocking_move_to_z(current_position[Z_AXIS] + 0.01 * float(encoder_diff));
906
           do_blocking_move_to_z(current_position[Z_AXIS] + 0.01 * float(encoder_diff));
912
     static void echo_and_take_a_measurement() { SERIAL_PROTOCOLLNPGM(" and take a measurement."); }
914
     static void echo_and_take_a_measurement() { SERIAL_PROTOCOLLNPGM(" and take a measurement."); }
913
 
915
 
914
     float unified_bed_leveling::measure_business_card_thickness(const float in_height) {
916
     float unified_bed_leveling::measure_business_card_thickness(const float in_height) {
915
-      has_control_of_lcd_panel = true;
917
+      lcd_external_control = true;
916
       save_ubl_active_state_and_disable();   // Disable bed level correction for probing
918
       save_ubl_active_state_and_disable();   // Disable bed level correction for probing
917
 
919
 
918
       do_blocking_move_to(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
920
       do_blocking_move_to(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
944
         SERIAL_PROTOCOLLNPGM("mm thick.");
946
         SERIAL_PROTOCOLLNPGM("mm thick.");
945
       }
947
       }
946
 
948
 
947
-      has_control_of_lcd_panel = false;
949
+      lcd_external_control = false;
948
 
950
 
949
       restore_ubl_active_state_and_leave();
951
       restore_ubl_active_state_and_leave();
950
 
952
 
953
 
955
 
954
     void unified_bed_leveling::manually_probe_remaining_mesh(const float &rx, const float &ry, const float &z_clearance, const float &thick, const bool do_ubl_mesh_map) {
956
     void unified_bed_leveling::manually_probe_remaining_mesh(const float &rx, const float &ry, const float &z_clearance, const float &thick, const bool do_ubl_mesh_map) {
955
 
957
 
956
-      has_control_of_lcd_panel = true;
958
+      lcd_external_control = true;
957
 
959
 
958
       save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
960
       save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
959
 
961
 
978
         do_blocking_move_to_z(z_clearance);
980
         do_blocking_move_to_z(z_clearance);
979
 
981
 
980
         KEEPALIVE_STATE(PAUSED_FOR_USER);
982
         KEEPALIVE_STATE(PAUSED_FOR_USER);
981
-        has_control_of_lcd_panel = true;
983
+        lcd_external_control = true;
982
 
984
 
983
         if (do_ubl_mesh_map) display_map(g29_map_type);  // show user where we're probing
985
         if (do_ubl_mesh_map) display_map(g29_map_type);  // show user where we're probing
984
 
986
 
987
         const float z_step = 0.01;                                        // existing behavior: 0.01mm per click, occasionally step
989
         const float z_step = 0.01;                                        // existing behavior: 0.01mm per click, occasionally step
988
         //const float z_step = 1.0 / planner.axis_steps_per_mm[Z_AXIS];   // approx one step each click
990
         //const float z_step = 1.0 / planner.axis_steps_per_mm[Z_AXIS];   // approx one step each click
989
 
991
 
990
-        while (ubl_lcd_clicked()) delay(50);             // wait for user to release encoder wheel
992
+        while (is_lcd_clicked()) delay(50);             // wait for user to release encoder wheel
991
         delay(50);                                       // debounce
993
         delay(50);                                       // debounce
992
-        while (!ubl_lcd_clicked()) {                     // we need the loop to move the nozzle based on the encoder wheel here!
994
+        while (!is_lcd_clicked()) {                     // we need the loop to move the nozzle based on the encoder wheel here!
993
           idle();
995
           idle();
994
           if (encoder_diff) {
996
           if (encoder_diff) {
995
             do_blocking_move_to_z(current_position[Z_AXIS] + float(encoder_diff) * z_step);
997
             do_blocking_move_to_z(current_position[Z_AXIS] + float(encoder_diff) * z_step);
997
           }
999
           }
998
         }
1000
         }
999
 
1001
 
1000
-        // this sequence to detect an ubl_lcd_clicked() debounce it and leave if it is
1002
+        // this sequence to detect an is_lcd_clicked() debounce it and leave if it is
1001
         // a Press and Hold is repeated in a lot of places (including G26_Mesh_Validation.cpp).   This
1003
         // a Press and Hold is repeated in a lot of places (including G26_Mesh_Validation.cpp).   This
1002
         // should be redone and compressed.
1004
         // should be redone and compressed.
1003
         const millis_t nxt = millis() + 1500L;
1005
         const millis_t nxt = millis() + 1500L;
1004
-        while (ubl_lcd_clicked()) {     // debounce and watch for abort
1006
+        while (is_lcd_clicked()) {     // debounce and watch for abort
1005
           idle();
1007
           idle();
1006
           if (ELAPSED(millis(), nxt)) {
1008
           if (ELAPSED(millis(), nxt)) {
1007
             SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.");
1009
             SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.");
1009
 
1011
 
1010
             #if ENABLED(NEWPANEL)
1012
             #if ENABLED(NEWPANEL)
1011
               lcd_quick_feedback();
1013
               lcd_quick_feedback();
1012
-              while (ubl_lcd_clicked()) idle();
1013
-              has_control_of_lcd_panel = false;
1014
+              while (is_lcd_clicked()) idle();
1015
+              lcd_external_control = false;
1014
             #endif
1016
             #endif
1015
 
1017
 
1016
             KEEPALIVE_STATE(IN_HANDLER);
1018
             KEEPALIVE_STATE(IN_HANDLER);
1509
         new_z = FLOOR(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place
1511
         new_z = FLOOR(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place
1510
 
1512
 
1511
         KEEPALIVE_STATE(PAUSED_FOR_USER);
1513
         KEEPALIVE_STATE(PAUSED_FOR_USER);
1512
-        has_control_of_lcd_panel = true;
1514
+        lcd_external_control = true;
1513
 
1515
 
1514
         if (do_ubl_mesh_map) display_map(g29_map_type);  // show the user which point is being adjusted
1516
         if (do_ubl_mesh_map) display_map(g29_map_type);  // show the user which point is being adjusted
1515
 
1517
 
1523
             do_blocking_move_to_z(h_offset + new_z); // Move the nozzle as the point is edited
1525
             do_blocking_move_to_z(h_offset + new_z); // Move the nozzle as the point is edited
1524
           #endif
1526
           #endif
1525
           idle();
1527
           idle();
1526
-        } while (!ubl_lcd_clicked());
1528
+        } while (!is_lcd_clicked());
1527
 
1529
 
1528
         if (!lcd_map_control) lcd_return_to_status();
1530
         if (!lcd_map_control) lcd_return_to_status();
1529
 
1531
 
1530
         // The technique used here generates a race condition for the encoder click.
1532
         // The technique used here generates a race condition for the encoder click.
1531
         // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune) or here.
1533
         // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune) or here.
1532
         // Let's work on specifying a proper API for the LCD ASAP, OK?
1534
         // Let's work on specifying a proper API for the LCD ASAP, OK?
1533
-        has_control_of_lcd_panel = true;
1535
+        lcd_external_control = true;
1534
 
1536
 
1535
-        // this sequence to detect an ubl_lcd_clicked() debounce it and leave if it is
1537
+        // this sequence to detect an is_lcd_clicked() debounce it and leave if it is
1536
         // a Press and Hold is repeated in a lot of places (including G26_Mesh_Validation.cpp).   This
1538
         // a Press and Hold is repeated in a lot of places (including G26_Mesh_Validation.cpp).   This
1537
         // should be redone and compressed.
1539
         // should be redone and compressed.
1538
         const millis_t nxt = millis() + 1500UL;
1540
         const millis_t nxt = millis() + 1500UL;
1539
-        while (ubl_lcd_clicked()) { // debounce and watch for abort
1541
+        while (is_lcd_clicked()) { // debounce and watch for abort
1540
           idle();
1542
           idle();
1541
           if (ELAPSED(millis(), nxt)) {
1543
           if (ELAPSED(millis(), nxt)) {
1542
             lcd_return_to_status();
1544
             lcd_return_to_status();
1543
             do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
1545
             do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
1544
             LCD_MESSAGEPGM(MSG_EDITING_STOPPED);
1546
             LCD_MESSAGEPGM(MSG_EDITING_STOPPED);
1545
 
1547
 
1546
-            while (ubl_lcd_clicked()) idle();
1548
+            while (is_lcd_clicked()) idle();
1547
 
1549
 
1548
             goto FINE_TUNE_EXIT;
1550
             goto FINE_TUNE_EXIT;
1549
           }
1551
           }
1559
 
1561
 
1560
       FINE_TUNE_EXIT:
1562
       FINE_TUNE_EXIT:
1561
 
1563
 
1562
-      has_control_of_lcd_panel = false;
1564
+      lcd_external_control = false;
1563
       KEEPALIVE_STATE(IN_HANDLER);
1565
       KEEPALIVE_STATE(IN_HANDLER);
1564
 
1566
 
1565
       if (do_ubl_mesh_map) display_map(g29_map_type);
1567
       if (do_ubl_mesh_map) display_map(g29_map_type);

+ 3
- 4
Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp View File

23
 
23
 
24
 #if ENABLED(AUTO_BED_LEVELING_UBL)
24
 #if ENABLED(AUTO_BED_LEVELING_UBL)
25
 
25
 
26
-  #include "ubl.h"
27
-
28
-  #include "../../../Marlin.h"
26
+  #include "../bedlevel.h"
29
   #include "../../../module/planner.h"
27
   #include "../../../module/planner.h"
30
   #include "../../../module/stepper.h"
28
   #include "../../../module/stepper.h"
31
   #include "../../../module/motion.h"
29
   #include "../../../module/motion.h"
34
     #include "../../../module/delta.h"
32
     #include "../../../module/delta.h"
35
   #endif
33
   #endif
36
 
34
 
35
+  #include "../../../Marlin.h"
37
   #include <math.h>
36
   #include <math.h>
38
 
37
 
39
   extern float destination[XYZE];
38
   extern float destination[XYZE];
55
 
54
 
56
     // if the title message starts with a '!' it is so important, we are going to
55
     // if the title message starts with a '!' it is so important, we are going to
57
     // ignore the status of the g26_debug_flag
56
     // ignore the status of the g26_debug_flag
58
-    if (*title != '!' && !ubl.g26_debug_flag) return;
57
+    if (*title != '!' && !g26_debug_flag) return;
59
 
58
 
60
     const float de = destination[E_AXIS] - current_position[E_AXIS];
59
     const float de = destination[E_AXIS] - current_position[E_AXIS];
61
 
60
 

+ 463
- 482
Marlin/src/gcode/bedlevel/G26.cpp
File diff suppressed because it is too large
View File


+ 0
- 11
Marlin/src/gcode/bedlevel/G42.cpp View File

44
       return;
44
       return;
45
     }
45
     }
46
 
46
 
47
-    #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
48
-      #define _GET_MESH_X(I) bilinear_start[X_AXIS] + I * bilinear_grid_spacing[X_AXIS]
49
-      #define _GET_MESH_Y(J) bilinear_start[Y_AXIS] + J * bilinear_grid_spacing[Y_AXIS]
50
-    #elif ENABLED(AUTO_BED_LEVELING_UBL)
51
-      #define _GET_MESH_X(I) ubl.mesh_index_to_xpos(I)
52
-      #define _GET_MESH_Y(J) ubl.mesh_index_to_ypos(J)
53
-    #elif ENABLED(MESH_BED_LEVELING)
54
-      #define _GET_MESH_X(I) mbl.index_to_xpos[I]
55
-      #define _GET_MESH_Y(J) mbl.index_to_ypos[J]
56
-    #endif
57
-
58
     set_destination_from_current();
47
     set_destination_from_current();
59
     if (hasI) destination[X_AXIS] = _GET_MESH_X(ix);
48
     if (hasI) destination[X_AXIS] = _GET_MESH_X(ix);
60
     if (hasJ) destination[Y_AXIS] = _GET_MESH_Y(iy);
49
     if (hasJ) destination[Y_AXIS] = _GET_MESH_Y(iy);

+ 0
- 36
Marlin/src/gcode/bedlevel/ubl/G26.cpp View File

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
-/**
24
- * G26.cpp - Unified Bed Leveling
25
- */
26
-
27
-#include "../../../inc/MarlinConfig.h"
28
-
29
-#if ENABLED(UBL_G26_MESH_VALIDATION)
30
-
31
-#include "../../gcode.h"
32
-#include "../../../feature/bedlevel/ubl/ubl.h"
33
-
34
-void GcodeSuite::G26() { ubl.G26(); }
35
-
36
-#endif // UBL_G26_MESH_VALIDATION

+ 1
- 1
Marlin/src/gcode/bedlevel/ubl/M421.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
 /**
34
 /**
35
  * M421: Set a single Mesh Bed Leveling Z coordinate
35
  * M421: Set a single Mesh Bed Leveling Z coordinate

+ 6
- 6
Marlin/src/gcode/bedlevel/ubl/M49.cpp View File

21
  */
21
  */
22
 
22
 
23
 /**
23
 /**
24
- * M49.cpp - Unified Bed Leveling
24
+ * M49.cpp - Toggle the G26 debug flag
25
  */
25
  */
26
 
26
 
27
 #include "../../../inc/MarlinConfig.h"
27
 #include "../../../inc/MarlinConfig.h"
28
 
28
 
29
-#if ENABLED(UBL_G26_MESH_VALIDATION)
29
+#if ENABLED(G26_MESH_VALIDATION)
30
 
30
 
31
 #include "../../gcode.h"
31
 #include "../../gcode.h"
32
 #include "../../../feature/bedlevel/bedlevel.h"
32
 #include "../../../feature/bedlevel/bedlevel.h"
33
 
33
 
34
 void GcodeSuite::M49() {
34
 void GcodeSuite::M49() {
35
-  ubl.g26_debug_flag ^= true;
36
-  SERIAL_PROTOCOLPGM("UBL Debug Flag turned ");
37
-  serialprintPGM(ubl.g26_debug_flag ? PSTR("on.") : PSTR("off."));
35
+  g26_debug_flag ^= true;
36
+  SERIAL_PROTOCOLPGM("G26 Debug ");
37
+  serialprintPGM(g26_debug_flag ? PSTR("on.") : PSTR("off."));
38
 }
38
 }
39
 
39
 
40
-#endif // UBL_G26_MESH_VALIDATION
40
+#endif // G26_MESH_VALIDATION

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

207
           break;
207
           break;
208
       #endif // INCH_MODE_SUPPORT
208
       #endif // INCH_MODE_SUPPORT
209
 
209
 
210
-      #if ENABLED(UBL_G26_MESH_VALIDATION)
210
+      #if ENABLED(G26_MESH_VALIDATION)
211
         case 26: // G26: Mesh Validation Pattern generation
211
         case 26: // G26: Mesh Validation Pattern generation
212
           G26();
212
           G26();
213
           break;
213
           break;
342
         case 48: M48(); break;    // M48: Z probe repeatability test
342
         case 48: M48(); break;    // M48: Z probe repeatability test
343
       #endif
343
       #endif
344
 
344
 
345
-      #if ENABLED(UBL_G26_MESH_VALIDATION)
345
+      #if ENABLED(G26_MESH_VALIDATION)
346
         case 49: M49(); break;    // M49: Turn on or off G26 debug flag for verbose output
346
         case 49: M49(); break;    // M49: Turn on or off G26 debug flag for verbose output
347
       #endif
347
       #endif
348
 
348
 

+ 3
- 3
Marlin/src/gcode/gcode.h View File

55
  * G19  - Select Plane YZ (Requires CNC_WORKSPACE_PLANES)
55
  * G19  - Select Plane YZ (Requires CNC_WORKSPACE_PLANES)
56
  * G20  - Set input units to inches (Requires INCH_MODE_SUPPORT)
56
  * G20  - Set input units to inches (Requires INCH_MODE_SUPPORT)
57
  * G21  - Set input units to millimeters (Requires INCH_MODE_SUPPORT)
57
  * G21  - Set input units to millimeters (Requires INCH_MODE_SUPPORT)
58
- * G26  - Mesh Validation Pattern (Requires UBL_G26_MESH_VALIDATION)
58
+ * G26  - Mesh Validation Pattern (Requires G26_MESH_VALIDATION)
59
  * G27  - Park Nozzle (Requires NOZZLE_PARK_FEATURE)
59
  * G27  - Park Nozzle (Requires NOZZLE_PARK_FEATURE)
60
  * G28  - Home one or more axes
60
  * G28  - Home one or more axes
61
  * G29  - Start or continue the bed leveling probe procedure (Requires bed leveling)
61
  * G29  - Start or continue the bed leveling probe procedure (Requires bed leveling)
357
     static void G21();
357
     static void G21();
358
   #endif
358
   #endif
359
 
359
 
360
-  #if ENABLED(UBL_G26_MESH_VALIDATION)
360
+  #if ENABLED(G26_MESH_VALIDATION)
361
     static void G26();
361
     static void G26();
362
   #endif
362
   #endif
363
 
363
 
453
     static void M48();
453
     static void M48();
454
   #endif
454
   #endif
455
 
455
 
456
-  #if ENABLED(UBL_G26_MESH_VALIDATION)
456
+  #if ENABLED(G26_MESH_VALIDATION)
457
     static void M49();
457
     static void M49();
458
   #endif
458
   #endif
459
 
459
 

+ 3
- 4
Marlin/src/inc/MarlinConfig.h View File

20
  *
20
  *
21
  */
21
  */
22
 
22
 
23
-#ifndef MARLIN_CONFIG_H
24
-#define MARLIN_CONFIG_H
23
+#ifndef _MARLIN_CONFIG_H_
24
+#define _MARLIN_CONFIG_H_
25
 
25
 
26
 #include "MarlinConfigPre.h"
26
 #include "MarlinConfigPre.h"
27
 
27
 
36
 // Include all core headers
36
 // Include all core headers
37
 #include "../core/enum.h"
37
 #include "../core/enum.h"
38
 #include "../core/language.h"
38
 #include "../core/language.h"
39
-#include "../core/types.h"
40
 #include "../core/utility.h"
39
 #include "../core/utility.h"
41
 #include "../core/serial.h"
40
 #include "../core/serial.h"
42
 
41
 
43
-#endif // MARLIN_CONFIG_H
42
+#endif // _MARLIN_CONFIG_H_

+ 5
- 3
Marlin/src/inc/MarlinConfigPre.h View File

20
  *
20
  *
21
  */
21
  */
22
 
22
 
23
-#ifndef MARLIN_CONFIGPRE_H
24
-#define MARLIN_CONFIGPRE_H
23
+#ifndef _MARLIN_CONFIGPRE_H_
24
+#define _MARLIN_CONFIGPRE_H_
25
 
25
 
26
 #include "../core/boards.h"
26
 #include "../core/boards.h"
27
 #include "../core/macros.h"
27
 #include "../core/macros.h"
31
 #include "../../Configuration_adv.h"
31
 #include "../../Configuration_adv.h"
32
 #include "Conditionals_adv.h"
32
 #include "Conditionals_adv.h"
33
 
33
 
34
-#endif // MARLIN_CONFIGPRE_H
34
+#include "../core/types.h"
35
+
36
+#endif // _MARLIN_CONFIGPRE_H_

+ 11
- 7
Marlin/src/lcd/ultralcd.cpp View File

60
   #include "../libs/buzzer.h"
60
   #include "../libs/buzzer.h"
61
 #endif
61
 #endif
62
 
62
 
63
+#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
64
+  bool lcd_external_control; // = false
65
+#endif
66
+
63
 // Initialized by settings.load()
67
 // Initialized by settings.load()
64
 int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
68
 int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
65
 
69
 
4599
 
4603
 
4600
     #if ENABLED(AUTO_BED_LEVELING_UBL)
4604
     #if ENABLED(AUTO_BED_LEVELING_UBL)
4601
       // Don't run the debouncer if UBL owns the display
4605
       // Don't run the debouncer if UBL owns the display
4602
-      #define UBL_CONDITION !ubl.has_control_of_lcd_panel
4606
+      #define UBL_CONDITION !lcd_external_control
4603
     #else
4607
     #else
4604
       #define UBL_CONDITION true
4608
       #define UBL_CONDITION true
4605
     #endif
4609
     #endif
5070
         case encrot3: ENCODER_SPIN(encrot2, encrot0); break;
5074
         case encrot3: ENCODER_SPIN(encrot2, encrot0); break;
5071
       }
5075
       }
5072
       #if ENABLED(AUTO_BED_LEVELING_UBL)
5076
       #if ENABLED(AUTO_BED_LEVELING_UBL)
5073
-        if (ubl.has_control_of_lcd_panel) {
5077
+        if (lcd_external_control) {
5074
           ubl.encoder_diff = encoderDiff;   // Make the encoder's rotation available to G29's Mesh Editor
5078
           ubl.encoder_diff = encoderDiff;   // Make the encoder's rotation available to G29's Mesh Editor
5075
           encoderDiff = 0;                  // We are going to lie to the LCD Panel and claim the encoder
5079
           encoderDiff = 0;                  // We are going to lie to the LCD Panel and claim the encoder
5076
                                             // knob has not turned.
5080
                                             // knob has not turned.
5086
     bool lcd_detected() { return true; }
5090
     bool lcd_detected() { return true; }
5087
   #endif
5091
   #endif
5088
 
5092
 
5089
-  #if ENABLED(AUTO_BED_LEVELING_UBL)
5090
-
5091
-    void chirp_at_user() {
5093
+  #if ENABLED(G26_MESH_VALIDATION)
5094
+    void lcd_chirp() {
5092
       lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
5095
       lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
5093
     }
5096
     }
5097
+  #endif
5094
 
5098
 
5095
-    bool ubl_lcd_clicked() { return LCD_CLICKED; }
5096
-
5099
+  #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
5100
+    bool is_lcd_clicked() { return LCD_CLICKED; }
5097
   #endif
5101
   #endif
5098
 
5102
 
5099
 #endif // ULTIPANEL
5103
 #endif // ULTIPANEL

+ 14
- 0
Marlin/src/lcd/ultralcd.h View File

29
 
29
 
30
   #include "../Marlin.h"
30
   #include "../Marlin.h"
31
 
31
 
32
+  #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
33
+    extern bool lcd_external_control;
34
+  #else
35
+    constexpr bool lcd_external_control = false;
36
+  #endif
37
+
32
   #define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
38
   #define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
33
   #define BUTTON_PRESSED(BN) !READ(BTN_## BN)
39
   #define BUTTON_PRESSED(BN) !READ(BTN_## BN)
34
 
40
 
123
       void lcd_advanced_pause_show_message(const AdvancedPauseMessage message);
129
       void lcd_advanced_pause_show_message(const AdvancedPauseMessage message);
124
     #endif
130
     #endif
125
 
131
 
132
+    #if ENABLED(G26_MESH_VALIDATION)
133
+      void lcd_chirp();
134
+    #endif
135
+
126
     #if ENABLED(AUTO_BED_LEVELING_UBL)
136
     #if ENABLED(AUTO_BED_LEVELING_UBL)
127
       void lcd_mesh_edit_setup(float initial);
137
       void lcd_mesh_edit_setup(float initial);
128
       float lcd_mesh_edit();
138
       float lcd_mesh_edit();
208
     #define LCD_CLICKED false
218
     #define LCD_CLICKED false
209
   #endif
219
   #endif
210
 
220
 
221
+  #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
222
+    bool is_lcd_clicked();
223
+  #endif
224
+
211
 #else // no LCD
225
 #else // no LCD
212
 
226
 
213
   inline void lcd_update() {}
227
   inline void lcd_update() {}

Loading…
Cancel
Save