Переглянути джерело

🐛 Fix and improve Polargraph (#24847)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Dan Royer 2 роки тому
джерело
коміт
5a80fc2617
Аккаунт користувача з таким Email не знайдено

+ 24
- 3
Marlin/src/feature/host_actions.cpp Переглянути файл

@@ -111,20 +111,29 @@ void HostUI::action(FSTR_P const fstr, const bool eol) {
111 111
     if (eol) SERIAL_EOL();
112 112
   }
113 113
 
114
-  void HostUI::prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char/*='\0'*/) {
114
+  void HostUI::prompt_plus(const bool pgm, FSTR_P const ptype, const char * const str, const char extra_char/*='\0'*/) {
115 115
     prompt(ptype, false);
116 116
     PORT_REDIRECT(SerialMask::All);
117 117
     SERIAL_CHAR(' ');
118
-    SERIAL_ECHOF(fstr);
118
+    if (pgm)
119
+      SERIAL_ECHOPGM_P(str);
120
+    else
121
+      SERIAL_ECHO(str);
119 122
     if (extra_char != '\0') SERIAL_CHAR(extra_char);
120 123
     SERIAL_EOL();
121 124
   }
125
+
122 126
   void HostUI::prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char/*='\0'*/) {
123 127
     prompt_end();
124 128
     host_prompt_reason = reason;
125 129
     prompt_plus(F("begin"), fstr, extra_char);
126 130
   }
127
-  void HostUI::prompt_button(FSTR_P const fstr) { prompt_plus(F("button"), fstr); }
131
+  void HostUI::prompt_begin(const PromptReason reason, const char * const cstr, const char extra_char/*='\0'*/) {
132
+    prompt_end();
133
+    host_prompt_reason = reason;
134
+    prompt_plus(F("begin"), cstr, extra_char);
135
+  }
136
+
128 137
   void HostUI::prompt_end() { prompt(F("end")); }
129 138
   void HostUI::prompt_show() { prompt(F("show")); }
130 139
 
@@ -133,14 +142,26 @@ void HostUI::action(FSTR_P const fstr, const bool eol) {
133 142
     if (btn2) prompt_button(btn2);
134 143
     prompt_show();
135 144
   }
145
+
146
+  void HostUI::prompt_button(FSTR_P const fstr) { prompt_plus(F("button"), fstr); }
147
+  void HostUI::prompt_button(const char * const cstr) { prompt_plus(F("button"), cstr); }
148
+
136 149
   void HostUI::prompt_do(const PromptReason reason, FSTR_P const fstr, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) {
137 150
     prompt_begin(reason, fstr);
138 151
     _prompt_show(btn1, btn2);
139 152
   }
153
+  void HostUI::prompt_do(const PromptReason reason, const char * const cstr, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) {
154
+    prompt_begin(reason, cstr);
155
+    _prompt_show(btn1, btn2);
156
+  }
140 157
   void HostUI::prompt_do(const PromptReason reason, FSTR_P const fstr, const char extra_char, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) {
141 158
     prompt_begin(reason, fstr, extra_char);
142 159
     _prompt_show(btn1, btn2);
143 160
   }
161
+  void HostUI::prompt_do(const PromptReason reason, const char * const cstr, const char extra_char, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) {
162
+    prompt_begin(reason, cstr, extra_char);
163
+    _prompt_show(btn1, btn2);
164
+  }
144 165
 
145 166
   #if ENABLED(ADVANCED_PAUSE_FEATURE)
146 167
     void HostUI::filament_load_prompt() {

+ 16
- 2
Marlin/src/feature/host_actions.h Переглянути файл

@@ -79,7 +79,14 @@ class HostUI {
79 79
   #if ENABLED(HOST_PROMPT_SUPPORT)
80 80
     private:
81 81
     static void prompt(FSTR_P const ptype, const bool eol=true);
82
-    static void prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char='\0');
82
+    static void prompt_plus(const bool pgm, FSTR_P const ptype, const char * const str, const char extra_char='\0');
83
+    static void prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char='\0') {
84
+      prompt_plus(true, ptype, FTOP(fstr), extra_char);
85
+    }
86
+    static void prompt_plus(FSTR_P const ptype, const char * const cstr, const char extra_char='\0') {
87
+      prompt_plus(false, ptype, cstr, extra_char);
88
+    }
89
+
83 90
     static void prompt_show();
84 91
     static void _prompt_show(FSTR_P const btn1, FSTR_P const btn2);
85 92
 
@@ -93,10 +100,17 @@ class HostUI {
93 100
     static void notify(const char * const message);
94 101
 
95 102
     static void prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char='\0');
96
-    static void prompt_button(FSTR_P const fstr);
103
+    static void prompt_begin(const PromptReason reason, const char * const cstr, const char extra_char='\0');
97 104
     static void prompt_end();
105
+
106
+    static void prompt_button(FSTR_P const fstr);
107
+    static void prompt_button(const char * const cstr);
108
+
98 109
     static void prompt_do(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr);
110
+    static void prompt_do(const PromptReason reason, const char * const cstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr);
99 111
     static void prompt_do(const PromptReason reason, FSTR_P const pstr, const char extra_char, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr);
112
+    static void prompt_do(const PromptReason reason, const char * const cstr, const char extra_char, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr);
113
+
100 114
     static void prompt_open(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr) {
101 115
       if (host_prompt_reason == PROMPT_NOT_DEFINED) prompt_do(reason, pstr, btn1, btn2);
102 116
     }

+ 0
- 2
Marlin/src/gcode/calibrate/M665.cpp Переглянути файл

@@ -167,8 +167,6 @@
167 167
     if (parser.seenval('T')) draw_area_max.y = parser.value_linear_units();
168 168
     if (parser.seenval('B')) draw_area_min.y = parser.value_linear_units();
169 169
     if (parser.seenval('H')) polargraph_max_belt_len = parser.value_linear_units();
170
-    draw_area_size.x = draw_area_max.x - draw_area_min.x;
171
-    draw_area_size.y = draw_area_max.y - draw_area_min.y;
172 170
   }
173 171
 
174 172
   void GcodeSuite::M665_report(const bool forReplay/*=true*/) {

+ 6
- 1
Marlin/src/gcode/lcd/M0_M1.cpp Переглянути файл

@@ -85,7 +85,12 @@ void GcodeSuite::M0_M1() {
85 85
 
86 86
   #endif
87 87
 
88
-  TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? F("M1 Stop") : F("M0 Stop"), FPSTR(CONTINUE_STR)));
88
+  #if ENABLED(HOST_PROMPT_SUPPORT)
89
+    if (parser.string_arg)
90
+      hostui.prompt_do(PROMPT_USER_CONTINUE, parser.string_arg, FPSTR(CONTINUE_STR));
91
+    else
92
+      hostui.prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? F("M1 Stop") : F("M0 Stop"), FPSTR(CONTINUE_STR));
93
+  #endif
89 94
 
90 95
   TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(ms));
91 96
 

+ 1
- 1
Marlin/src/inc/Conditionals_post.h Переглянути файл

@@ -155,7 +155,7 @@
155 155
   #define W_BED_SIZE W_MAX_LENGTH
156 156
 #endif
157 157
 
158
-// Require 0,0 bed center for Delta and SCARA
158
+// Require 0,0 bed center for Delta, SCARA, and Polargraph
159 159
 #if IS_KINEMATIC
160 160
   #define BED_CENTER_AT_0_0
161 161
 #endif

+ 2
- 2
Marlin/src/inc/SanityCheck.h Переглянути файл

@@ -829,7 +829,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
829 829
 /**
830 830
  * Granular software endstops (Marlin >= 1.1.7)
831 831
  */
832
-#if ENABLED(MIN_SOFTWARE_ENDSTOPS) && DISABLED(MIN_SOFTWARE_ENDSTOP_Z)
832
+#if ENABLED(MIN_SOFTWARE_ENDSTOPS) && NONE(MIN_SOFTWARE_ENDSTOP_Z, POLARGRAPH)
833 833
   #if IS_KINEMATIC
834 834
     #error "MIN_SOFTWARE_ENDSTOPS on DELTA/SCARA also requires MIN_SOFTWARE_ENDSTOP_Z."
835 835
   #elif NONE(MIN_SOFTWARE_ENDSTOP_X, MIN_SOFTWARE_ENDSTOP_Y)
@@ -837,7 +837,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
837 837
   #endif
838 838
 #endif
839 839
 
840
-#if ENABLED(MAX_SOFTWARE_ENDSTOPS) && DISABLED(MAX_SOFTWARE_ENDSTOP_Z)
840
+#if ENABLED(MAX_SOFTWARE_ENDSTOPS) && NONE(MAX_SOFTWARE_ENDSTOP_Z, POLARGRAPH)
841 841
   #if IS_KINEMATIC
842 842
     #error "MAX_SOFTWARE_ENDSTOPS on DELTA/SCARA also requires MAX_SOFTWARE_ENDSTOP_Z."
843 843
   #elif NONE(MAX_SOFTWARE_ENDSTOP_X, MAX_SOFTWARE_ENDSTOP_Y)

+ 6
- 0
Marlin/src/lcd/language/language_en.h Переглянути файл

@@ -418,6 +418,12 @@ namespace Language_en {
418 418
   LSTR MSG_FILAMENT_DIAM_E                = _UxGT("Fil. Dia. *");
419 419
   LSTR MSG_FILAMENT_UNLOAD                = _UxGT("Unload mm");
420 420
   LSTR MSG_FILAMENT_LOAD                  = _UxGT("Load mm");
421
+  LSTR MSG_SEGMENTS_PER_SECOND            = _UxGT("Segments/Sec");
422
+  LSTR MSG_DRAW_MIN_X                     = _UxGT("Draw Min X");
423
+  LSTR MSG_DRAW_MAX_X                     = _UxGT("Draw Max X");
424
+  LSTR MSG_DRAW_MIN_Y                     = _UxGT("Draw Min Y");
425
+  LSTR MSG_DRAW_MAX_Y                     = _UxGT("Draw Max Y");
426
+  LSTR MSG_MAX_BELT_LEN                   = _UxGT("Max Belt Len");
421 427
   LSTR MSG_ADVANCE_K                      = _UxGT("Advance K");
422 428
   LSTR MSG_ADVANCE_K_E                    = _UxGT("Advance K *");
423 429
   LSTR MSG_CONTRAST                       = _UxGT("LCD Contrast");

+ 13
- 3
Marlin/src/lcd/menu/menu_advanced.cpp Переглянути файл

@@ -632,10 +632,20 @@ void menu_advanced_settings() {
632 632
 
633 633
   #if DISABLED(SLIM_LCD_MENUS)
634 634
 
635
+    #if ENABLED(POLARGRAPH)
636
+      // M665 - Polargraph Settings
637
+      if (!is_busy) {
638
+        EDIT_ITEM_FAST(float4, MSG_SEGMENTS_PER_SECOND, &segments_per_second, 100, 9999);               // M665 S
639
+        EDIT_ITEM_FAST(float51sign, MSG_DRAW_MIN_X, &draw_area_min.x, X_MIN_POS, draw_area_max.x - 10); // M665 L
640
+        EDIT_ITEM_FAST(float51sign, MSG_DRAW_MAX_X, &draw_area_max.x, draw_area_min.x + 10, X_MAX_POS); // M665 R
641
+        EDIT_ITEM_FAST(float51sign, MSG_DRAW_MIN_Y, &draw_area_min.y, Y_MIN_POS, draw_area_max.y - 10); // M665 T
642
+        EDIT_ITEM_FAST(float51sign, MSG_DRAW_MAX_Y, &draw_area_max.y, draw_area_min.y + 10, Y_MAX_POS); // M665 B
643
+        EDIT_ITEM_FAST(float51sign, MSG_MAX_BELT_LEN, &polargraph_max_belt_len, 500, 2000);             // M665 H
644
+      }
645
+    #endif
646
+
635 647
     #if HAS_M206_COMMAND
636
-      //
637
-      // Set Home Offsets
638
-      //
648
+      // M428 - Set Home Offsets
639 649
       ACTION_ITEM(MSG_SET_HOME_OFFSETS, []{ queue.inject(F("M428")); ui.return_to_status(); });
640 650
     #endif
641 651
 

+ 12
- 7
Marlin/src/module/motion.cpp Переглянути файл

@@ -341,7 +341,6 @@ void report_current_position_projected() {
341 341
       can_reach = (
342 342
            a < polargraph_max_belt_len + 1
343 343
         && b < polargraph_max_belt_len + 1
344
-        && (a + b) > _MIN(draw_area_size.x, draw_area_size.y)
345 344
       );
346 345
 
347 346
     #endif
@@ -562,7 +561,8 @@ void do_blocking_move_to(NUM_AXIS_ARGS(const float), const_feedRate_t fr_mm_s/*=
562 561
     const feedRate_t w_feedrate = fr_mm_s ?: homing_feedrate(W_AXIS)
563 562
   );
564 563
 
565
-  #if IS_KINEMATIC
564
+  #if IS_KINEMATIC && DISABLED(POLARGRAPH)
565
+    // kinematic machines are expected to home to a point 1.5x their range? never reachable.
566 566
     if (!position_is_reachable(x, y)) return;
567 567
     destination = current_position;          // sync destination at the start
568 568
   #endif
@@ -919,11 +919,16 @@ void restore_feedrate_and_scaling() {
919 919
         constexpr xy_pos_t offs{0};
920 920
       #endif
921 921
 
922
-      if (TERN1(IS_SCARA, axis_was_homed(X_AXIS) && axis_was_homed(Y_AXIS))) {
923
-        const float dist_2 = HYPOT2(target.x - offs.x, target.y - offs.y);
924
-        if (dist_2 > delta_max_radius_2)
925
-          target *= float(delta_max_radius / SQRT(dist_2)); // 200 / 300 = 0.66
926
-      }
922
+      #if ENABLED(POLARGRAPH)
923
+        LIMIT(target.x, draw_area_min.x, draw_area_max.x);
924
+        LIMIT(target.y, draw_area_min.y, draw_area_max.y);
925
+      #else
926
+        if (TERN1(IS_SCARA, axis_was_homed(X_AXIS) && axis_was_homed(Y_AXIS))) {
927
+          const float dist_2 = HYPOT2(target.x - offs.x, target.y - offs.y);
928
+          if (dist_2 > delta_max_radius_2)
929
+            target *= float(delta_max_radius / SQRT(dist_2)); // 200 / 300 = 0.66
930
+        }
931
+      #endif
927 932
 
928 933
     #else
929 934
 

+ 0
- 1
Marlin/src/module/planner.cpp Переглянути файл

@@ -2244,7 +2244,6 @@ bool Planner::_populate_block(
2244 2244
 
2245 2245
   TERN_(MIXING_EXTRUDER, mixer.populate_block(block->b_color));
2246 2246
 
2247
-
2248 2247
   #if HAS_FAN
2249 2248
     FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i];
2250 2249
   #endif

+ 4
- 9
Marlin/src/module/polargraph.cpp Переглянути файл

@@ -37,17 +37,12 @@
37 37
 #include "../lcd/marlinui.h"
38 38
 #include "../MarlinCore.h"
39 39
 
40
-float segments_per_second; // Initialized by settings.load()
41
-
42
-xy_pos_t draw_area_min = { X_MIN_POS, Y_MIN_POS },
43
-         draw_area_max = { X_MAX_POS, Y_MAX_POS };
44
-
45
-xy_float_t draw_area_size = { X_MAX_POS - X_MIN_POS, Y_MAX_POS - Y_MIN_POS };
46
-
47
-float polargraph_max_belt_len = HYPOT(draw_area_size.x, draw_area_size.y);
40
+// Initialized by settings.load()
41
+float segments_per_second, polargraph_max_belt_len;
42
+xy_pos_t draw_area_min, draw_area_max;
48 43
 
49 44
 void inverse_kinematics(const xyz_pos_t &raw) {
50
-  const float x1 = raw.x - (draw_area_min.x), x2 = (draw_area_max.x) - raw.x, y = raw.y - (draw_area_max.y);
45
+  const float x1 = raw.x - draw_area_min.x, x2 = draw_area_max.x - raw.x, y = raw.y - draw_area_max.y;
51 46
   delta.set(HYPOT(x1, y), HYPOT(x2, y), raw.z);
52 47
 }
53 48
 

+ 0
- 1
Marlin/src/module/polargraph.h Переглянути файл

@@ -30,7 +30,6 @@
30 30
 
31 31
 extern float segments_per_second;
32 32
 extern xy_pos_t draw_area_min, draw_area_max;
33
-extern xy_float_t draw_area_size;
34 33
 extern float polargraph_max_belt_len;
35 34
 
36 35
 void inverse_kinematics(const xyz_pos_t &raw);

+ 29
- 5
Marlin/src/module/settings.cpp Переглянути файл

@@ -257,7 +257,7 @@ typedef struct SettingsDataStruct {
257 257
   // HAS_BED_PROBE
258 258
   //
259 259
 
260
-  xyz_pos_t probe_offset;
260
+  xyz_pos_t probe_offset;                               // M851 X Y Z
261 261
 
262 262
   //
263 263
   // ABL_PLANAR
@@ -330,7 +330,11 @@ typedef struct SettingsDataStruct {
330 330
             delta_diagonal_rod;                         // M665 L
331 331
       abc_float_t delta_tower_angle_trim,               // M665 X Y Z
332 332
                   delta_diagonal_rod_trim;              // M665 A B C
333
+    #elif ENABLED(POLARGRAPH)
334
+      xy_pos_t draw_area_min, draw_area_max;            // M665 L R T B
335
+      float polargraph_max_belt_len;                    // M665 H
333 336
     #endif
337
+
334 338
   #endif
335 339
 
336 340
   //
@@ -468,7 +472,7 @@ typedef struct SettingsDataStruct {
468 472
   //
469 473
   // SKEW_CORRECTION
470 474
   //
471
-  skew_factor_t planner_skew_factor;                    // M852 I J K  planner.skew_factor
475
+  skew_factor_t planner_skew_factor;                    // M852 I J K
472 476
 
473 477
   //
474 478
   // ADVANCED_PAUSE_FEATURE
@@ -1001,6 +1005,11 @@ void MarlinSettings::postprocess() {
1001 1005
         EEPROM_WRITE(delta_diagonal_rod);        // 1 float
1002 1006
         EEPROM_WRITE(delta_tower_angle_trim);    // 3 floats
1003 1007
         EEPROM_WRITE(delta_diagonal_rod_trim);   // 3 floats
1008
+      #elif ENABLED(POLARGRAPH)
1009
+        _FIELD_TEST(draw_area_min);
1010
+        EEPROM_WRITE(draw_area_min);             // 2 floats
1011
+        EEPROM_WRITE(draw_area_max);             // 2 floats
1012
+        EEPROM_WRITE(polargraph_max_belt_len);   // 1 float
1004 1013
       #endif
1005 1014
     }
1006 1015
     #endif
@@ -1436,6 +1445,14 @@ void MarlinSettings::postprocess() {
1436 1445
     EEPROM_WRITE(planner.skew_factor);
1437 1446
 
1438 1447
     //
1448
+    // POLARGRAPH
1449
+    //
1450
+    #if ENABLED(POLARGRAPH)
1451
+      _FIELD_TEST(polargraph_max_belt_len);
1452
+      EEPROM_WRITE(polargraph_max_belt_len);
1453
+    #endif
1454
+
1455
+    //
1439 1456
     // Advanced Pause filament load & unload lengths
1440 1457
     //
1441 1458
     #if HAS_EXTRUDERS
@@ -1936,6 +1953,11 @@ void MarlinSettings::postprocess() {
1936 1953
           EEPROM_READ(delta_diagonal_rod);        // 1 float
1937 1954
           EEPROM_READ(delta_tower_angle_trim);    // 3 floats
1938 1955
           EEPROM_READ(delta_diagonal_rod_trim);   // 3 floats
1956
+        #elif ENABLED(POLARGRAPH)
1957
+          _FIELD_TEST(draw_area_min);
1958
+          EEPROM_READ(draw_area_min);             // 2 floats
1959
+          EEPROM_READ(draw_area_max);             // 2 floats
1960
+          EEPROM_READ(polargraph_max_belt_len);   // 1 float
1939 1961
         #endif
1940 1962
       }
1941 1963
       #endif
@@ -2996,6 +3018,10 @@ void MarlinSettings::reset() {
2996 3018
       delta_diagonal_rod = DELTA_DIAGONAL_ROD;
2997 3019
       delta_tower_angle_trim = dta;
2998 3020
       delta_diagonal_rod_trim = ddr;
3021
+    #elif ENABLED(POLARGRAPH)
3022
+      draw_area_min.set(X_MIN_POS, Y_MIN_POS);
3023
+      draw_area_max.set(X_MAX_POS, Y_MAX_POS);
3024
+      polargraph_max_belt_len = POLARGRAPH_MAX_BELT_LEN;
2999 3025
     #endif
3000 3026
   #endif
3001 3027
 
@@ -3492,9 +3518,7 @@ void MarlinSettings::reset() {
3492 3518
     //
3493 3519
     // LCD Preheat Settings
3494 3520
     //
3495
-    #if HAS_PREHEAT
3496
-      gcode.M145_report(forReplay);
3497
-    #endif
3521
+    TERN_(HAS_PREHEAT, gcode.M145_report(forReplay));
3498 3522
 
3499 3523
     //
3500 3524
     // PID

Завантаження…
Відмінити
Зберегти