Browse Source

Make EEPROM reproducible in GCode

With these changes the output of `M503 S0` is all you need to restore
the EEPROM. Building on this it is straightforward to save and restore
the EEPROM state using the SD card or external GCode file.

- Added `M145` to set “heatup states” for the LCD menu
- Added `M420` to toggle Mesh Bed Leveling
- Added `M421` to set a single Mesh coordinate
- Extended `Config_PrintSettings` with added M codes
- Cleaned up some comments here and there
Scott Lahteine 9 years ago
parent
commit
0fca084ea6

+ 1
- 1
Marlin/Configuration_adv.h View File

@@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st
355 355
 //#define HEATERS_PARALLEL
356 356
 
357 357
 //===========================================================================
358
-//=============================Buffers           ============================
358
+//================================= Buffers =================================
359 359
 //===========================================================================
360 360
 
361 361
 // @section hidden

+ 140
- 13
Marlin/Marlin_main.cpp View File

@@ -151,6 +151,7 @@
151 151
  * M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil)
152 152
  * M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil)
153 153
  * M140 - Set bed target temp
154
+ * M145 - Set the heatup state H<hotend> B<bed> F<fan speed> for S<material> (0=PLA, 1=ABS)
154 155
  * M150 - Set BlinkM Color Output R: Red<0-255> U(!): Green<0-255> B: Blue<0-255> over i2c, G for green does not work.
155 156
  * M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating
156 157
  *        Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling
@@ -186,6 +187,8 @@
186 187
  * M406 - Turn off Filament Sensor extrusion control
187 188
  * M407 - Display measured filament diameter
188 189
  * M410 - Quickstop. Abort all the planned moves
190
+ * M420 - Enable/Disable Mesh Leveling (with current values) S1=enable S0=disable
191
+ * M421 - Set a single Z coordinate in the Mesh Leveling grid. X<index> Y<index> Z<offset in mm>
189 192
  * M500 - Store parameters in EEPROM
190 193
  * M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily).
191 194
  * M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
@@ -3385,6 +3388,62 @@ inline void gcode_M140() {
3385 3388
   if (code_seen('S')) setTargetBed(code_value());
3386 3389
 }
3387 3390
 
3391
+#ifdef ULTIPANEL
3392
+
3393
+  /**
3394
+   * M145: Set the heatup state for a material in the LCD menu
3395
+   *   S<material> (0=PLA, 1=ABS)
3396
+   *   H<hotend temp>
3397
+   *   B<bed temp>
3398
+   *   F<fan speed>
3399
+   */
3400
+  inline void gcode_M145() {
3401
+    uint8_t material = code_seen('S') ? code_value_short() : 0;
3402
+    if (material < 0 || material > 1) {
3403
+      SERIAL_ERROR_START;
3404
+      SERIAL_ERRORLNPGM(MSG_ERR_MATERIAL_INDEX);
3405
+    }
3406
+    else {
3407
+      int v;
3408
+      switch (material) {
3409
+        case 0:
3410
+          if (code_seen('H')) {
3411
+            v = code_value_short();
3412
+            plaPreheatHotendTemp = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15);
3413
+          }
3414
+          if (code_seen('F')) {
3415
+            v = code_value_short();
3416
+            plaPreheatFanSpeed = constrain(v, 0, 255);
3417
+          }
3418
+          #if TEMP_SENSOR_BED != 0
3419
+            if (code_seen('B')) {
3420
+              v = code_value_short();
3421
+              plaPreheatHPBTemp = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15);
3422
+            }
3423
+          #endif
3424
+          break;
3425
+        case 1:
3426
+          if (code_seen('H')) {
3427
+            v = code_value_short();
3428
+            absPreheatHotendTemp = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15);
3429
+          }
3430
+          if (code_seen('F')) {
3431
+            v = code_value_short();
3432
+            absPreheatFanSpeed = constrain(v, 0, 255);
3433
+          }
3434
+          #if TEMP_SENSOR_BED != 0
3435
+            if (code_seen('B')) {
3436
+              v = code_value_short();
3437
+              absPreheatHPBTemp = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15);
3438
+            }
3439
+          #endif
3440
+          break;
3441
+      }
3442
+    }
3443
+  }
3444
+
3445
+#endif
3446
+
3388 3447
 #if HAS_POWER_SWITCH
3389 3448
 
3390 3449
   /**
@@ -3492,7 +3551,8 @@ inline void gcode_M85() {
3492 3551
 }
3493 3552
 
3494 3553
 /**
3495
- * M92: Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
3554
+ * M92: Set axis steps-per-unit for one or more axes, X, Y, Z, and E.
3555
+ *      (Follows the same syntax as G92)
3496 3556
  */
3497 3557
 inline void gcode_M92() {
3498 3558
   for(int8_t i=0; i < NUM_AXIS; i++) {
@@ -3814,20 +3874,35 @@ inline void gcode_M206() {
3814 3874
 #ifdef FWRETRACT
3815 3875
 
3816 3876
   /**
3817
-   * M207: Set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop]
3877
+   * M207: Set firmware retraction values
3878
+   *
3879
+   *   S[+mm]    retract_length
3880
+   *   W[+mm]    retract_length_swap (multi-extruder)
3881
+   *   F[mm/min] retract_feedrate
3882
+   *   Z[mm]     retract_zlift
3818 3883
    */
3819 3884
   inline void gcode_M207() {
3820 3885
     if (code_seen('S')) retract_length = code_value();
3821 3886
     if (code_seen('F')) retract_feedrate = code_value() / 60;
3822 3887
     if (code_seen('Z')) retract_zlift = code_value();
3888
+    #if EXTRUDERS > 1
3889
+      if (code_seen('W')) retract_length_swap = code_value();
3890
+    #endif
3823 3891
   }
3824 3892
 
3825 3893
   /**
3826
-   * M208: Set retract recover length S[positive mm surplus to the M207 S*] F[feedrate mm/min]
3894
+   * M208: Set firmware un-retraction values
3895
+   *
3896
+   *   S[+mm]    retract_recover_length (in addition to M207 S*)
3897
+   *   W[+mm]    retract_recover_length_swap (multi-extruder)
3898
+   *   F[mm/min] retract_recover_feedrate
3827 3899
    */
3828 3900
   inline void gcode_M208() {
3829 3901
     if (code_seen('S')) retract_recover_length = code_value();
3830 3902
     if (code_seen('F')) retract_recover_feedrate = code_value() / 60;
3903
+    #if EXTRUDERS > 1
3904
+      if (code_seen('W')) retract_recover_length_swap = code_value();
3905
+    #endif
3831 3906
   }
3832 3907
 
3833 3908
   /**
@@ -4380,6 +4455,42 @@ inline void gcode_M400() { st_synchronize(); }
4380 4455
  */
4381 4456
 inline void gcode_M410() { quickStop(); }
4382 4457
 
4458
+
4459
+#ifdef MESH_BED_LEVELING
4460
+
4461
+  /**
4462
+   * M420: Enable/Disable Mesh Bed Leveling
4463
+   */
4464
+  inline void gcode_M420() { if (code_seen('S') && code_has_value()) mbl.active = !!code_value_short(); }
4465
+
4466
+  /**
4467
+   * M421: Set a single Mesh Bed Leveling Z coordinate
4468
+   */
4469
+  inline void gcode_M421() {
4470
+    int x, y;
4471
+    float z;
4472
+    bool err = false, hasX, hasY, hasZ;
4473
+    if ((hasX = code_seen('X'))) x = code_value_short();
4474
+    if ((hasY = code_seen('Y'))) y = code_value_short();
4475
+    if ((hasZ = code_seen('Z'))) z = code_value();
4476
+
4477
+    if (!hasX || !hasY || !hasZ) {
4478
+      SERIAL_ERROR_START;
4479
+      SERIAL_ERRORLNPGM(MSG_ERR_XYZ_REQUIRED_FOR_M421);
4480
+      err = true;
4481
+    }
4482
+
4483
+    if (x >= MESH_NUM_X_POINTS || y >= MESH_NUM_Y_POINTS) {
4484
+      SERIAL_ERROR_START;
4485
+      SERIAL_ERRORLNPGM(MSG_ERR_MESH_INDEX_OOB);
4486
+      err = true;
4487
+    }
4488
+
4489
+    if (!err) mbl.z_values[y][x] = z;
4490
+  }
4491
+
4492
+#endif
4493
+
4383 4494
 /**
4384 4495
  * M500: Store settings in EEPROM
4385 4496
  */
@@ -4934,11 +5045,11 @@ void process_commands() {
4934 5045
         gcode_M104();
4935 5046
         break;
4936 5047
 
4937
-      case 111: //  M111: Set debug level
5048
+      case 111: // M111: Set debug level
4938 5049
         gcode_M111();
4939 5050
         break;
4940 5051
 
4941
-      case 112: //  M112: Emergency Stop
5052
+      case 112: // M112: Emergency Stop
4942 5053
         gcode_M112();
4943 5054
         break;
4944 5055
 
@@ -5017,28 +5128,35 @@ void process_commands() {
5017 5128
       case 85: // M85
5018 5129
         gcode_M85();
5019 5130
         break;
5020
-      case 92: // M92
5131
+      case 92: // M92: Set the steps-per-unit for one or more axes
5021 5132
         gcode_M92();
5022 5133
         break;
5023
-      case 115: // M115
5134
+      case 115: // M115: Report capabilities
5024 5135
         gcode_M115();
5025 5136
         break;
5026
-      case 117: // M117 display message
5137
+      case 117: // M117: Set LCD message text
5027 5138
         gcode_M117();
5028 5139
         break;
5029
-      case 114: // M114
5140
+      case 114: // M114: Report current position
5030 5141
         gcode_M114();
5031 5142
         break;
5032
-      case 120: // M120
5143
+      case 120: // M120: Enable endstops
5033 5144
         gcode_M120();
5034 5145
         break;
5035
-      case 121: // M121
5146
+      case 121: // M121: Disable endstops
5036 5147
         gcode_M121();
5037 5148
         break;
5038
-      case 119: // M119
5149
+      case 119: // M119: Report endstop states
5039 5150
         gcode_M119();
5040 5151
         break;
5041
-        //TODO: update for all axis, use for loop
5152
+
5153
+      #ifdef ULTIPANEL
5154
+
5155
+        case 145: // M145: Set material heatup parameters
5156
+          gcode_M145();
5157
+          break;
5158
+
5159
+      #endif
5042 5160
 
5043 5161
       #ifdef BLINKM
5044 5162
 
@@ -5213,6 +5331,15 @@ void process_commands() {
5213 5331
         gcode_M410();
5214 5332
         break;
5215 5333
 
5334
+      #ifdef MESH_BED_LEVELING
5335
+        case 420: // M420 Enable/Disable Mesh Bed Leveling
5336
+          gcode_M420();
5337
+          break;
5338
+        case 421: // M421 Set a Mesh Bed Leveling Z coordinate
5339
+          gcode_M421();
5340
+          break;
5341
+      #endif
5342
+
5216 5343
       case 500: // M500 Store settings in EEPROM
5217 5344
         gcode_M500();
5218 5345
         break;

+ 208
- 126
Marlin/configuration_store.cpp View File

@@ -20,72 +20,72 @@
20 20
  * V19 EEPROM Layout:
21 21
  *
22 22
  *  ver
23
- *  axis_steps_per_unit (x4)
24
- *  max_feedrate (x4)
25
- *  max_acceleration_units_per_sq_second (x4)
26
- *  acceleration
27
- *  retract_acceleration
28
- *  travel_acceleration
29
- *  minimumfeedrate
30
- *  mintravelfeedrate
31
- *  minsegmenttime
32
- *  max_xy_jerk
33
- *  max_z_jerk
34
- *  max_e_jerk
35
- *  home_offset (x3)
23
+ *  M92 XYZE  axis_steps_per_unit (x4)
24
+ *  M203 XYZE max_feedrate (x4)
25
+ *  M201 XYZE max_acceleration_units_per_sq_second (x4)
26
+ *  M204 P    acceleration
27
+ *  M204 R    retract_acceleration
28
+ *  M204 T    travel_acceleration
29
+ *  M205 S    minimumfeedrate
30
+ *  M205 T    mintravelfeedrate
31
+ *  M205 B    minsegmenttime
32
+ *  M205 X    max_xy_jerk
33
+ *  M205 Z    max_z_jerk
34
+ *  M205 E    max_e_jerk
35
+ *  M206 XYZ  home_offset (x3)
36 36
  *
37 37
  * Mesh bed leveling:
38
- *  active
39
- *  mesh_num_x
40
- *  mesh_num_y
41
- *  z_values[][]
42
- *  zprobe_zoffset
38
+ *  M420 S    active
39
+ *            mesh_num_x (set in firmware)
40
+ *            mesh_num_y (set in firmware)
41
+ *  M421 XYZ  z_values[][]
42
+ *  M851      zprobe_zoffset
43 43
  *
44 44
  * DELTA:
45
- *  endstop_adj (x3)
46
- *  delta_radius
47
- *  delta_diagonal_rod
48
- *  delta_segments_per_second
45
+ *  M666 XYZ  endstop_adj (x3)
46
+ *  M665 R    delta_radius
47
+ *  M665 L    delta_diagonal_rod
48
+ *  M665 S    delta_segments_per_second
49 49
  *
50 50
  * ULTIPANEL:
51
- *  plaPreheatHotendTemp
52
- *  plaPreheatHPBTemp
53
- *  plaPreheatFanSpeed
54
- *  absPreheatHotendTemp
55
- *  absPreheatHPBTemp
56
- *  absPreheatFanSpeed
51
+ *  M145 S0 H plaPreheatHotendTemp
52
+ *  M145 S0 B plaPreheatHPBTemp
53
+ *  M145 S0 F plaPreheatFanSpeed
54
+ *  M145 S1 H absPreheatHotendTemp
55
+ *  M145 S1 B absPreheatHPBTemp
56
+ *  M145 S1 F absPreheatFanSpeed
57 57
  *
58 58
  * PIDTEMP:
59
- *  Kp[0], Ki[0], Kd[0], Kc[0]
60
- *  Kp[1], Ki[1], Kd[1], Kc[1]
61
- *  Kp[2], Ki[2], Kd[2], Kc[2]
62
- *  Kp[3], Ki[3], Kd[3], Kc[3]
59
+ *  M301 E0 PIDC  Kp[0], Ki[0], Kd[0], Kc[0]
60
+ *  M301 E1 PIDC  Kp[1], Ki[1], Kd[1], Kc[1]
61
+ *  M301 E2 PIDC  Kp[2], Ki[2], Kd[2], Kc[2]
62
+ *  M301 E3 PIDC  Kp[3], Ki[3], Kd[3], Kc[3]
63 63
  *
64 64
  * PIDTEMPBED:
65
- *  bedKp, bedKi, bedKd
65
+ *  M304 PID  bedKp, bedKi, bedKd
66 66
  *
67 67
  * DOGLCD:
68
- *  lcd_contrast
68
+ *  M250 C    lcd_contrast
69 69
  *
70 70
  * SCARA:
71
- *  axis_scaling (x3)
71
+ *  M365 XYZ  axis_scaling (x3)
72 72
  *
73 73
  * FWRETRACT:
74
- *  autoretract_enabled
75
- *  retract_length
76
- *  retract_length_swap
77
- *  retract_feedrate
78
- *  retract_zlift
79
- *  retract_recover_length
80
- *  retract_recover_length_swap
81
- *  retract_recover_feedrate
74
+ *  M209 S    autoretract_enabled
75
+ *  M207 S    retract_length
76
+ *  M207 W    retract_length_swap
77
+ *  M207 F    retract_feedrate
78
+ *  M207 Z    retract_zlift
79
+ *  M208 S    retract_recover_length
80
+ *  M208 W    retract_recover_length_swap
81
+ *  M208 F    retract_recover_feedrate
82 82
  *
83
- *  volumetric_enabled
83
+ *  M200 D    volumetric_enabled (D>0 makes this enabled)
84 84
  *
85
- *  filament_size (x4)
85
+ *  M200 T D  filament_size (x4) (T0..3)
86 86
  *
87
- * Z_DUAL_ENDSTOPS
88
- *  z_endstop_adj
87
+ * Z_DUAL_ENDSTOPS:
88
+ *  M666 Z    z_endstop_adj
89 89
  *
90 90
  */
91 91
 #include "Marlin.h"
@@ -122,7 +122,9 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
122 122
 #define EEPROM_WRITE_VAR(pos, value) _EEPROM_writeData(pos, (uint8_t*)&value, sizeof(value))
123 123
 #define EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value))
124 124
 
125
-//======================================================================================
125
+/**
126
+ * Store Configuration Settings - M500
127
+ */
126 128
 
127 129
 #define DUMMY_PID_VALUE 3000.0f
128 130
 
@@ -235,7 +237,7 @@ void Config_StoreSettings()  {
235 237
   EEPROM_WRITE_VAR(i, bedKi);
236 238
   EEPROM_WRITE_VAR(i, bedKd);
237 239
 
238
-  #ifndef DOGLCD
240
+  #ifndef HAS_LCD_CONTRAST
239 241
     int lcd_contrast = 32;
240 242
   #endif
241 243
   EEPROM_WRITE_VAR(i, lcd_contrast);
@@ -286,6 +288,10 @@ void Config_StoreSettings()  {
286 288
   SERIAL_ECHOLNPGM(" bytes)");
287 289
 }
288 290
 
291
+/**
292
+ * Retrieve Configuration Settings - M501
293
+ */
294
+
289 295
 void Config_RetrieveSettings() {
290 296
 
291 297
   int i = EEPROM_OFFSET;
@@ -412,7 +418,7 @@ void Config_RetrieveSettings() {
412 418
       for (int q=2; q--;) EEPROM_READ_VAR(i, dummy); // bedKi, bedKd
413 419
     }
414 420
 
415
-    #ifndef DOGLCD
421
+    #ifndef HAS_LCD_CONTRAST
416 422
       int lcd_contrast;
417 423
     #endif
418 424
     EEPROM_READ_VAR(i, lcd_contrast);
@@ -467,6 +473,10 @@ void Config_RetrieveSettings() {
467 473
 
468 474
 #endif // EEPROM_SETTINGS
469 475
 
476
+/**
477
+ * Reset Configuration Settings - M502
478
+ */
479
+
470 480
 void Config_ResetDefault() {
471 481
   float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT;
472 482
   float tmp2[] = DEFAULT_MAX_FEEDRATE;
@@ -522,7 +532,7 @@ void Config_ResetDefault() {
522 532
     absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
523 533
   #endif
524 534
 
525
-  #ifdef DOGLCD
535
+  #ifdef HAS_LCD_CONTRAST
526 536
     lcd_contrast = DEFAULT_LCD_CONTRAST;
527 537
   #endif
528 538
 
@@ -584,14 +594,20 @@ void Config_ResetDefault() {
584 594
 
585 595
 #ifndef DISABLE_M503
586 596
 
597
+/**
598
+ * Print Configuration Settings - M503
599
+ */
600
+
601
+#define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START; }while(0)
602
+
587 603
 void Config_PrintSettings(bool forReplay) {
588 604
   // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
589 605
 
590
-  SERIAL_ECHO_START;
606
+  CONFIG_ECHO_START;
591 607
 
592 608
   if (!forReplay) {
593 609
     SERIAL_ECHOLNPGM("Steps per unit:");
594
-    SERIAL_ECHO_START;
610
+    CONFIG_ECHO_START;
595 611
   }
596 612
   SERIAL_ECHOPAIR("  M92 X", axis_steps_per_unit[X_AXIS]);
597 613
   SERIAL_ECHOPAIR(" Y", axis_steps_per_unit[Y_AXIS]);
@@ -599,23 +615,23 @@ void Config_PrintSettings(bool forReplay) {
599 615
   SERIAL_ECHOPAIR(" E", axis_steps_per_unit[E_AXIS]);
600 616
   SERIAL_EOL;
601 617
 
602
-  SERIAL_ECHO_START;
618
+  CONFIG_ECHO_START;
603 619
 
604 620
   #ifdef SCARA
605 621
     if (!forReplay) {
606 622
       SERIAL_ECHOLNPGM("Scaling factors:");
607
-      SERIAL_ECHO_START;
623
+      CONFIG_ECHO_START;
608 624
     }
609 625
     SERIAL_ECHOPAIR("  M365 X", axis_scaling[X_AXIS]);
610 626
     SERIAL_ECHOPAIR(" Y", axis_scaling[Y_AXIS]);
611 627
     SERIAL_ECHOPAIR(" Z", axis_scaling[Z_AXIS]);
612 628
     SERIAL_EOL;
613
-    SERIAL_ECHO_START;
629
+    CONFIG_ECHO_START;
614 630
   #endif // SCARA
615 631
 
616 632
   if (!forReplay) {
617 633
     SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
618
-    SERIAL_ECHO_START;
634
+    CONFIG_ECHO_START;
619 635
   }
620 636
   SERIAL_ECHOPAIR("  M203 X", max_feedrate[X_AXIS]);
621 637
   SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]);
@@ -623,160 +639,224 @@ void Config_PrintSettings(bool forReplay) {
623 639
   SERIAL_ECHOPAIR(" E", max_feedrate[E_AXIS]);
624 640
   SERIAL_EOL;
625 641
 
626
-  SERIAL_ECHO_START;
642
+  CONFIG_ECHO_START;
627 643
   if (!forReplay) {
628 644
     SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
629
-    SERIAL_ECHO_START;
645
+    CONFIG_ECHO_START;
630 646
   }
631
-  SERIAL_ECHOPAIR("  M201 X", max_acceleration_units_per_sq_second[X_AXIS] );
632
-  SERIAL_ECHOPAIR(" Y", max_acceleration_units_per_sq_second[Y_AXIS] );
633
-  SERIAL_ECHOPAIR(" Z", max_acceleration_units_per_sq_second[Z_AXIS] );
647
+  SERIAL_ECHOPAIR("  M201 X", max_acceleration_units_per_sq_second[X_AXIS]);
648
+  SERIAL_ECHOPAIR(" Y", max_acceleration_units_per_sq_second[Y_AXIS]);
649
+  SERIAL_ECHOPAIR(" Z", max_acceleration_units_per_sq_second[Z_AXIS]);
634 650
   SERIAL_ECHOPAIR(" E", max_acceleration_units_per_sq_second[E_AXIS]);
635 651
   SERIAL_EOL;
636
-  SERIAL_ECHO_START;
652
+  CONFIG_ECHO_START;
637 653
   if (!forReplay) {
638 654
     SERIAL_ECHOLNPGM("Accelerations: P=printing, R=retract and T=travel");
639
-    SERIAL_ECHO_START;
655
+    CONFIG_ECHO_START;
640 656
   }
641
-  SERIAL_ECHOPAIR("  M204 P", acceleration );
657
+  SERIAL_ECHOPAIR("  M204 P", acceleration);
642 658
   SERIAL_ECHOPAIR(" R", retract_acceleration);
643 659
   SERIAL_ECHOPAIR(" T", travel_acceleration);
644 660
   SERIAL_EOL;
645 661
 
646
-  SERIAL_ECHO_START;
662
+  CONFIG_ECHO_START;
647 663
   if (!forReplay) {
648 664
     SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s),  Z=maximum Z jerk (mm/s),  E=maximum E jerk (mm/s)");
649
-    SERIAL_ECHO_START;
665
+    CONFIG_ECHO_START;
650 666
   }
651
-  SERIAL_ECHOPAIR("  M205 S", minimumfeedrate );
652
-  SERIAL_ECHOPAIR(" T", mintravelfeedrate );
653
-  SERIAL_ECHOPAIR(" B", minsegmenttime );
654
-  SERIAL_ECHOPAIR(" X", max_xy_jerk );
667
+  SERIAL_ECHOPAIR("  M205 S", minimumfeedrate);
668
+  SERIAL_ECHOPAIR(" T", mintravelfeedrate);
669
+  SERIAL_ECHOPAIR(" B", minsegmenttime);
670
+  SERIAL_ECHOPAIR(" X", max_xy_jerk);
655 671
   SERIAL_ECHOPAIR(" Z", max_z_jerk);
656 672
   SERIAL_ECHOPAIR(" E", max_e_jerk);
657 673
   SERIAL_EOL;
658 674
 
659
-  SERIAL_ECHO_START;
675
+  CONFIG_ECHO_START;
660 676
   if (!forReplay) {
661 677
     SERIAL_ECHOLNPGM("Home offset (mm):");
662
-    SERIAL_ECHO_START;
678
+    CONFIG_ECHO_START;
663 679
   }
664
-  SERIAL_ECHOPAIR("  M206 X", home_offset[X_AXIS] );
665
-  SERIAL_ECHOPAIR(" Y", home_offset[Y_AXIS] );
666
-  SERIAL_ECHOPAIR(" Z", home_offset[Z_AXIS] );
680
+  SERIAL_ECHOPAIR("  M206 X", home_offset[X_AXIS]);
681
+  SERIAL_ECHOPAIR(" Y", home_offset[Y_AXIS]);
682
+  SERIAL_ECHOPAIR(" Z", home_offset[Z_AXIS]);
667 683
   SERIAL_EOL;
668 684
 
685
+  #ifdef MESH_BED_LEVELING
686
+    if (!forReplay) {
687
+      SERIAL_ECHOLNPGM("Mesh bed leveling:");
688
+      CONFIG_ECHO_START;
689
+    }
690
+    SERIAL_ECHOPAIR("  M420 S", (int32_t)mbl.active);
691
+    SERIAL_ECHOPAIR(" X", MESH_NUM_X_POINTS);
692
+    SERIAL_ECHOPAIR(" Y", MESH_NUM_Y_POINTS);
693
+    SERIAL_EOL;
694
+    for (int y=0; y<MESH_NUM_Y_POINTS; y++) {
695
+      for (int x=0; x<MESH_NUM_X_POINTS; x++) {
696
+        CONFIG_ECHO_START;
697
+        SERIAL_ECHOPAIR("  M421 X", x);
698
+        SERIAL_ECHOPAIR(" Y", y);
699
+        SERIAL_ECHOPAIR(" Z", mbl.z_values[y][x]);
700
+        SERIAL_EOL;
701
+      }
702
+    }
703
+  #endif
704
+
669 705
   #ifdef DELTA
670
-    SERIAL_ECHO_START;
706
+    CONFIG_ECHO_START;
671 707
     if (!forReplay) {
672 708
       SERIAL_ECHOLNPGM("Endstop adjustment (mm):");
673
-      SERIAL_ECHO_START;
709
+      CONFIG_ECHO_START;
674 710
     }
675
-    SERIAL_ECHOPAIR("  M666 X", endstop_adj[X_AXIS] );
676
-    SERIAL_ECHOPAIR(" Y", endstop_adj[Y_AXIS] );
677
-    SERIAL_ECHOPAIR(" Z", endstop_adj[Z_AXIS] );
711
+    SERIAL_ECHOPAIR("  M666 X", endstop_adj[X_AXIS]);
712
+    SERIAL_ECHOPAIR(" Y", endstop_adj[Y_AXIS]);
713
+    SERIAL_ECHOPAIR(" Z", endstop_adj[Z_AXIS]);
678 714
     SERIAL_EOL;
679
-    SERIAL_ECHO_START;
715
+    CONFIG_ECHO_START;
680 716
     SERIAL_ECHOLNPGM("Delta settings: L=delta_diagonal_rod, R=delta_radius, S=delta_segments_per_second");
681
-    SERIAL_ECHO_START;
682
-    SERIAL_ECHOPAIR("  M665 L", delta_diagonal_rod );
683
-    SERIAL_ECHOPAIR(" R", delta_radius );
684
-    SERIAL_ECHOPAIR(" S", delta_segments_per_second );
717
+    CONFIG_ECHO_START;
718
+    SERIAL_ECHOPAIR("  M665 L", delta_diagonal_rod);
719
+    SERIAL_ECHOPAIR(" R", delta_radius);
720
+    SERIAL_ECHOPAIR(" S", delta_segments_per_second);
685 721
     SERIAL_EOL;
686 722
   #elif defined(Z_DUAL_ENDSTOPS)
687
-    SERIAL_ECHO_START;
723
+    CONFIG_ECHO_START;
688 724
     if (!forReplay) {
689 725
       SERIAL_ECHOLNPGM("Z2 Endstop adjustment (mm):");
690
-      SERIAL_ECHO_START;
726
+      CONFIG_ECHO_START;
691 727
     }
692
-    SERIAL_ECHOPAIR("  M666 Z", z_endstop_adj );
728
+    SERIAL_ECHOPAIR("  M666 Z", z_endstop_adj);
693 729
     SERIAL_EOL;  
694 730
   #endif // DELTA
695 731
 
732
+  #ifdef ULTIPANEL
733
+    CONFIG_ECHO_START;
734
+    if (!forReplay) {
735
+      SERIAL_ECHOLNPGM("Material heatup parameters:");
736
+      CONFIG_ECHO_START;
737
+    }
738
+    SERIAL_ECHOPAIR("  M145 M0 H", (unsigned long)plaPreheatHotendTemp);
739
+    SERIAL_ECHOPAIR(" B", (unsigned long)plaPreheatHPBTemp);
740
+    SERIAL_ECHOPAIR(" F", (unsigned long)plaPreheatFanSpeed);
741
+    SERIAL_EOL;
742
+    CONFIG_ECHO_START;
743
+    SERIAL_ECHOPAIR("  M145 M1 H", (unsigned long)absPreheatHotendTemp);
744
+    SERIAL_ECHOPAIR(" B", (unsigned long)absPreheatHPBTemp);
745
+    SERIAL_ECHOPAIR(" F", (unsigned long)absPreheatFanSpeed);
746
+    SERIAL_EOL;
747
+  #endif // ULTIPANEL
748
+
696 749
   #if defined(PIDTEMP) || defined(PIDTEMPBED)
697
-    SERIAL_ECHO_START;
750
+
751
+    CONFIG_ECHO_START;
698 752
     if (!forReplay) {
699 753
       SERIAL_ECHOLNPGM("PID settings:");
700
-      SERIAL_ECHO_START;
701 754
     }
702
-    #if defined(PIDTEMP) && defined(PIDTEMPBED)
703
-      SERIAL_EOL;
704
-    #endif
705 755
     #ifdef PIDTEMP
706
-      SERIAL_ECHOPAIR("  M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echos values for E0
707
-      SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
708
-      SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
709
-      SERIAL_EOL;
710
-    #endif
756
+      #if EXTRUDERS > 1
757
+        if (forReplay) {
758
+          for (uint8_t i = 0; i < EXTRUDERS; i++) {
759
+            CONFIG_ECHO_START;
760
+            SERIAL_ECHOPAIR("  M301 E", (unsigned long)i);
761
+            SERIAL_ECHOPAIR(" P", PID_PARAM(Kp, i));
762
+            SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, i)));
763
+            SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, i)));
764
+            #ifdef PID_ADD_EXTRUSION_RATE
765
+              SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, i));
766
+            #endif      
767
+            SERIAL_EOL;
768
+          }
769
+        }
770
+        else
771
+      #endif // EXTRUDERS > 1
772
+      // !forReplay || EXTRUDERS == 1
773
+      {
774
+        CONFIG_ECHO_START;
775
+        SERIAL_ECHOPAIR("  M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echo values for E0
776
+        SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
777
+        SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
778
+        #ifdef PID_ADD_EXTRUSION_RATE
779
+          SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, 0));
780
+        #endif      
781
+        SERIAL_EOL;
782
+      }
783
+    #endif // PIDTEMP
784
+
711 785
     #ifdef PIDTEMPBED
712
-      SERIAL_ECHOPAIR("  M304 P", bedKp); // for compatibility with hosts, only echos values for E0
786
+      CONFIG_ECHO_START;
787
+      SERIAL_ECHOPAIR("  M304 P", bedKp);
713 788
       SERIAL_ECHOPAIR(" I", unscalePID_i(bedKi));
714 789
       SERIAL_ECHOPAIR(" D", unscalePID_d(bedKd));
715 790
       SERIAL_EOL;
716 791
     #endif
792
+
793
+  #endif // PIDTEMP || PIDTEMPBED
794
+
795
+  #ifdef HAS_LCD_CONTRAST
796
+    CONFIG_ECHO_START;
797
+    if (!forReplay) {
798
+      SERIAL_ECHOLNPGM("LCD Contrast:");
799
+      CONFIG_ECHO_START;
800
+    }
801
+    SERIAL_ECHOPAIR("  M250 C", (unsigned long)lcd_contrast);
802
+    SERIAL_EOL;
717 803
   #endif
718 804
 
719 805
   #ifdef FWRETRACT
720 806
 
721
-    SERIAL_ECHO_START;
807
+    CONFIG_ECHO_START;
722 808
     if (!forReplay) {
723 809
       SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
724
-      SERIAL_ECHO_START;
810
+      CONFIG_ECHO_START;
725 811
     }
726 812
     SERIAL_ECHOPAIR("  M207 S", retract_length);
813
+    #if EXTRUDERS > 1
814
+      SERIAL_ECHOPAIR(" W", retract_length_swap);
815
+    #endif
727 816
     SERIAL_ECHOPAIR(" F", retract_feedrate*60);
728 817
     SERIAL_ECHOPAIR(" Z", retract_zlift);
729 818
     SERIAL_EOL;
730
-    SERIAL_ECHO_START;
819
+    CONFIG_ECHO_START;
731 820
     if (!forReplay) {
732 821
       SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
733
-      SERIAL_ECHO_START;
822
+      CONFIG_ECHO_START;
734 823
     }
735 824
     SERIAL_ECHOPAIR("  M208 S", retract_recover_length);
825
+    #if EXTRUDERS > 1
826
+      SERIAL_ECHOPAIR(" W", retract_recover_length_swap);
827
+    #endif
736 828
     SERIAL_ECHOPAIR(" F", retract_recover_feedrate*60);
737 829
     SERIAL_EOL;
738
-    SERIAL_ECHO_START;
830
+    CONFIG_ECHO_START;
739 831
     if (!forReplay) {
740 832
       SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
741
-      SERIAL_ECHO_START;
833
+      CONFIG_ECHO_START;
742 834
     }
743 835
     SERIAL_ECHOPAIR("  M209 S", (unsigned long)(autoretract_enabled ? 1 : 0));
744 836
     SERIAL_EOL;
745 837
 
746
-    #if EXTRUDERS > 1
747
-      if (!forReplay) {
748
-        SERIAL_ECHO_START;
749
-        SERIAL_ECHOLNPGM("Multi-extruder settings:");
750
-        SERIAL_ECHO_START;
751
-        SERIAL_ECHOPAIR("   Swap retract length (mm):    ", retract_length_swap);
752
-        SERIAL_EOL;
753
-        SERIAL_ECHO_START;
754
-        SERIAL_ECHOPAIR("   Swap rec. addl. length (mm): ", retract_recover_length_swap);
755
-        SERIAL_EOL;
756
-      }
757
-    #endif // EXTRUDERS > 1
758
-
759 838
   #endif // FWRETRACT
760 839
 
761
-  SERIAL_ECHO_START;
762 840
   if (volumetric_enabled) {
763 841
     if (!forReplay) {
842
+      CONFIG_ECHO_START;
764 843
       SERIAL_ECHOLNPGM("Filament settings:");
765
-      SERIAL_ECHO_START;
766 844
     }
845
+
846
+    CONFIG_ECHO_START;
767 847
     SERIAL_ECHOPAIR("  M200 D", filament_size[0]);
768 848
     SERIAL_EOL;
769 849
 
770 850
     #if EXTRUDERS > 1
771
-      SERIAL_ECHO_START;
851
+      CONFIG_ECHO_START;
772 852
       SERIAL_ECHOPAIR("  M200 T1 D", filament_size[1]);
773 853
       SERIAL_EOL;
774 854
       #if EXTRUDERS > 2
775
-        SERIAL_ECHO_START;
855
+        CONFIG_ECHO_START;
776 856
         SERIAL_ECHOPAIR("  M200 T2 D", filament_size[2]);
777 857
         SERIAL_EOL;
778 858
         #if EXTRUDERS > 3
779
-          SERIAL_ECHO_START;
859
+          CONFIG_ECHO_START;
780 860
           SERIAL_ECHOPAIR("  M200 T3 D", filament_size[3]);
781 861
           SERIAL_EOL;
782 862
         #endif
@@ -785,21 +865,23 @@ void Config_PrintSettings(bool forReplay) {
785 865
 
786 866
   } else {
787 867
     if (!forReplay) {
868
+      CONFIG_ECHO_START;
788 869
       SERIAL_ECHOLNPGM("Filament settings: Disabled");
789 870
     }
790 871
   }
791 872
 
792 873
   #ifdef ENABLE_AUTO_BED_LEVELING
793
-    SERIAL_ECHO_START;
794 874
     #ifdef CUSTOM_M_CODES
795 875
       if (!forReplay) {
876
+        CONFIG_ECHO_START;
796 877
         SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
797
-        SERIAL_ECHO_START;
798 878
       }
879
+      CONFIG_ECHO_START;
799 880
       SERIAL_ECHOPAIR("  M", (unsigned long)CUSTOM_M_CODE_SET_Z_PROBE_OFFSET);
800 881
       SERIAL_ECHOPAIR(" Z", -zprobe_zoffset);
801 882
     #else
802 883
       if (!forReplay) {
884
+        CONFIG_ECHO_START;
803 885
         SERIAL_ECHOPAIR("Z-Probe Offset (mm):", -zprobe_zoffset);
804 886
       }
805 887
     #endif

+ 1
- 1
Marlin/configurator/config/Configuration_adv.h View File

@@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st
355 355
 //#define HEATERS_PARALLEL
356 356
 
357 357
 //===========================================================================
358
-//=============================Buffers           ============================
358
+//================================= Buffers =================================
359 359
 //===========================================================================
360 360
 
361 361
 // @section hidden

+ 4
- 1
Marlin/configurator/config/language.h View File

@@ -70,7 +70,7 @@
70 70
   #endif
71 71
 #else
72 72
   #ifndef MACHINE_NAME
73
-    #define MACHINE_NAME "Mendel"
73
+    #define MACHINE_NAME "3D Printer"
74 74
   #endif
75 75
 #endif
76 76
 
@@ -158,6 +158,9 @@
158 158
 #define MSG_Z_MAX                           "z_max: "
159 159
 #define MSG_Z2_MAX                          "z2_max: "
160 160
 #define MSG_Z_PROBE                         "z_probe: "
161
+#define MSG_ERR_MATERIAL_INDEX              "M145 S<index> out of range (0-1)"
162
+#define MSG_ERR_XYZ_REQUIRED_FOR_M421       "M421 requires XYZ parameters"
163
+#define MSG_ERR_MESH_INDEX_OOB              "Mesh XY index is out of bounds"
161 164
 #define MSG_M119_REPORT                     "Reporting endstop status"
162 165
 #define MSG_ENDSTOP_HIT                     "TRIGGERED"
163 166
 #define MSG_ENDSTOP_OPEN                    "open"

+ 1
- 1
Marlin/example_configurations/Felix/Configuration_adv.h View File

@@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st
355 355
 //#define HEATERS_PARALLEL
356 356
 
357 357
 //===========================================================================
358
-//=============================Buffers           ============================
358
+//================================= Buffers =================================
359 359
 //===========================================================================
360 360
 
361 361
 // @section hidden

+ 1
- 1
Marlin/example_configurations/Hephestos/Configuration_adv.h View File

@@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st
355 355
 //#define HEATERS_PARALLEL
356 356
 
357 357
 //===========================================================================
358
-//=============================Buffers           ============================
358
+//================================= Buffers =================================
359 359
 //===========================================================================
360 360
 
361 361
 // @section hidden

+ 1
- 1
Marlin/example_configurations/K8200/Configuration_adv.h View File

@@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st
355 355
 //#define HEATERS_PARALLEL
356 356
 
357 357
 //===========================================================================
358
-//=============================Buffers           ============================
358
+//================================= Buffers =================================
359 359
 //===========================================================================
360 360
 
361 361
 // @section hidden

+ 1
- 1
Marlin/example_configurations/SCARA/Configuration_adv.h View File

@@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st
355 355
 //#define HEATERS_PARALLEL
356 356
 
357 357
 //===========================================================================
358
-//=============================Buffers           ============================
358
+//================================= Buffers =================================
359 359
 //===========================================================================
360 360
 
361 361
 // @section hidden

+ 1
- 1
Marlin/example_configurations/WITBOX/Configuration_adv.h View File

@@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st
355 355
 //#define HEATERS_PARALLEL
356 356
 
357 357
 //===========================================================================
358
-//=============================Buffers           ============================
358
+//================================= Buffers =================================
359 359
 //===========================================================================
360 360
 
361 361
 // @section hidden

+ 1
- 1
Marlin/example_configurations/delta/generic/Configuration_adv.h View File

@@ -356,7 +356,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st
356 356
 //#define HEATERS_PARALLEL
357 357
 
358 358
 //===========================================================================
359
-//=============================Buffers           ============================
359
+//================================= Buffers =================================
360 360
 //===========================================================================
361 361
 
362 362
 // @section hidden

+ 1
- 1
Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h View File

@@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st
355 355
 //#define HEATERS_PARALLEL
356 356
 
357 357
 //===========================================================================
358
-//=============================Buffers           ============================
358
+//================================= Buffers =================================
359 359
 //===========================================================================
360 360
 
361 361
 // @section hidden

+ 1
- 1
Marlin/example_configurations/makibox/Configuration_adv.h View File

@@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st
355 355
 //#define HEATERS_PARALLEL
356 356
 
357 357
 //===========================================================================
358
-//=============================Buffers           ============================
358
+//================================= Buffers =================================
359 359
 //===========================================================================
360 360
 
361 361
 // @section hidden

+ 1
- 1
Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h View File

@@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st
355 355
 //#define HEATERS_PARALLEL
356 356
 
357 357
 //===========================================================================
358
-//=============================Buffers           ============================
358
+//================================= Buffers =================================
359 359
 //===========================================================================
360 360
 
361 361
 // @section hidden

+ 3
- 0
Marlin/language.h View File

@@ -158,6 +158,9 @@
158 158
 #define MSG_Z_MAX                           "z_max: "
159 159
 #define MSG_Z2_MAX                          "z2_max: "
160 160
 #define MSG_Z_PROBE                         "z_probe: "
161
+#define MSG_ERR_MATERIAL_INDEX              "M145 S<index> out of range (0-1)"
162
+#define MSG_ERR_XYZ_REQUIRED_FOR_M421       "M421 requires XYZ parameters"
163
+#define MSG_ERR_MESH_INDEX_OOB              "Mesh XY index is out of bounds"
161 164
 #define MSG_M119_REPORT                     "Reporting endstop status"
162 165
 #define MSG_ENDSTOP_HIT                     "TRIGGERED"
163 166
 #define MSG_ENDSTOP_OPEN                    "open"

+ 68
- 69
Marlin/planner.cpp View File

@@ -1,54 +1,51 @@
1
-/*
2
-  planner.c - buffers movement commands and manages the acceleration profile plan
3
- Part of Grbl
4
- 
5
- Copyright (c) 2009-2011 Simen Svale Skogsrud
6
- 
7
- Grbl is free software: you can redistribute it and/or modify
8
- it under the terms of the GNU General Public License as published by
9
- the Free Software Foundation, either version 3 of the License, or
10
- (at your option) any later version.
11
- 
12
- Grbl is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
- GNU General Public License for more details.
16
- 
17
- You should have received a copy of the GNU General Public License
18
- along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
19
- */
20
-
21
-/* The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. */
22
-
23
-/*  
24
- Reasoning behind the mathematics in this module (in the key of 'Mathematica'):
25
- 
26
- s == speed, a == acceleration, t == time, d == distance
27
- 
28
- Basic definitions:
29
- 
30
- Speed[s_, a_, t_] := s + (a*t) 
31
- Travel[s_, a_, t_] := Integrate[Speed[s, a, t], t]
32
- 
33
- Distance to reach a specific speed with a constant acceleration:
34
- 
35
- Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, d, t]
36
- d -> (m^2 - s^2)/(2 a) --> estimate_acceleration_distance()
37
- 
38
- Speed after a given distance of travel with constant acceleration:
39
- 
40
- Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t]
41
- m -> Sqrt[2 a d + s^2]    
42
- 
43
- DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2]
44
- 
45
- When to start braking (di) to reach a specified destionation speed (s2) after accelerating
46
- from initial speed s1 without ever stopping at a plateau:
47
- 
48
- Solve[{DestinationSpeed[s1, a, di] == DestinationSpeed[s2, a, d - di]}, di]
49
- di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance()
50
- 
51
- IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a)
1
+/**
2
+ * planner.cpp - Buffer movement commands and manage the acceleration profile plan
3
+ * Part of Grbl
4
+ * 
5
+ * Copyright (c) 2009-2011 Simen Svale Skogsrud
6
+ *
7
+ * Grbl is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * Grbl is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
19
+ *
20
+ *
21
+ * The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis.
22
+ *
23
+ *
24
+ * Reasoning behind the mathematics in this module (in the key of 'Mathematica'):
25
+ *
26
+ * s == speed, a == acceleration, t == time, d == distance
27
+ *
28
+ * Basic definitions:
29
+ *   Speed[s_, a_, t_] := s + (a*t)
30
+ *   Travel[s_, a_, t_] := Integrate[Speed[s, a, t], t]
31
+ *
32
+ * Distance to reach a specific speed with a constant acceleration:
33
+ *   Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, d, t]
34
+ *   d -> (m^2 - s^2)/(2 a) --> estimate_acceleration_distance()
35
+ *
36
+ * Speed after a given distance of travel with constant acceleration:
37
+ *   Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t]
38
+ *   m -> Sqrt[2 a d + s^2]
39
+ *
40
+ * DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2]
41
+ *
42
+ * When to start braking (di) to reach a specified destination speed (s2) after accelerating
43
+ * from initial speed s1 without ever stopping at a plateau:
44
+ *   Solve[{DestinationSpeed[s1, a, di] == DestinationSpeed[s2, a, d - di]}, di]
45
+ *   di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance()
46
+ *
47
+ * IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a)
48
+ *
52 49
  */
53 50
 
54 51
 #include "Marlin.h"
@@ -71,17 +68,17 @@ float max_feedrate[NUM_AXIS]; // Max speeds in mm per minute
71 68
 float axis_steps_per_unit[NUM_AXIS];
72 69
 unsigned long max_acceleration_units_per_sq_second[NUM_AXIS]; // Use M201 to override by software
73 70
 float minimumfeedrate;
74
-float acceleration;         // Normal acceleration mm/s^2  THIS IS THE DEFAULT ACCELERATION for all printing moves. M204 SXXXX
75
-float retract_acceleration; //  mm/s^2   filament pull-pack and push-forward  while standing still in the other axis M204 TXXXX
76
-float travel_acceleration;  // Travel acceleration mm/s^2  THIS IS THE DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX
77
-float max_xy_jerk; //speed than can be stopped at once, if i understand correctly.
71
+float acceleration;         // Normal acceleration mm/s^2  DEFAULT ACCELERATION for all printing moves. M204 SXXXX
72
+float retract_acceleration; // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axes M204 TXXXX
73
+float travel_acceleration;  // Travel acceleration mm/s^2  DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX
74
+float max_xy_jerk;          // The largest speed change requiring no acceleration
78 75
 float max_z_jerk;
79 76
 float max_e_jerk;
80 77
 float mintravelfeedrate;
81 78
 unsigned long axis_steps_per_sqr_second[NUM_AXIS];
82 79
 
83 80
 #ifdef ENABLE_AUTO_BED_LEVELING
84
-  // this holds the required transform to compensate for bed level
81
+  // Transform required to compensate for bed level
85 82
   matrix_3x3 plan_bed_level_matrix = {
86 83
     1.0, 0.0, 0.0,
87 84
     0.0, 1.0, 0.0,
@@ -89,11 +86,6 @@ unsigned long axis_steps_per_sqr_second[NUM_AXIS];
89 86
   };
90 87
 #endif // ENABLE_AUTO_BED_LEVELING
91 88
 
92
-// The current position of the tool in absolute steps
93
-long position[NUM_AXIS];   //rescaled from extern when axis_steps_per_unit are changed by gcode
94
-static float previous_speed[NUM_AXIS]; // Speed of previous path line segment
95
-static float previous_nominal_speed; // Nominal speed of previous path line segment
96
-
97 89
 #ifdef AUTOTEMP
98 90
   float autotemp_max = 250;
99 91
   float autotemp_min = 210;
@@ -101,18 +93,25 @@ static float previous_nominal_speed; // Nominal speed of previous path line segm
101 93
   bool autotemp_enabled = false;
102 94
 #endif
103 95
 
104
-unsigned char g_uc_extruder_last_move[4] = {0,0,0,0};
105
-
106 96
 //===========================================================================
107
-//=================semi-private variables, used in inline  functions    =====
97
+//============ semi-private variables, used in inline functions =============
108 98
 //===========================================================================
99
+
109 100
 block_t block_buffer[BLOCK_BUFFER_SIZE];            // A ring buffer for motion instfructions
110 101
 volatile unsigned char block_buffer_head;           // Index of the next block to be pushed
111 102
 volatile unsigned char block_buffer_tail;           // Index of the block to process now
112 103
 
113 104
 //===========================================================================
114
-//=============================private variables ============================
105
+//============================ private variables ============================
115 106
 //===========================================================================
107
+
108
+// The current position of the tool in absolute steps
109
+long position[NUM_AXIS];               // Rescaled from extern when axis_steps_per_unit are changed by gcode
110
+static float previous_speed[NUM_AXIS]; // Speed of previous path line segment
111
+static float previous_nominal_speed;   // Nominal speed of previous path line segment
112
+
113
+unsigned char g_uc_extruder_last_move[4] = {0,0,0,0};
114
+
116 115
 #ifdef XY_FREQUENCY_LIMIT
117 116
   // Used for the frequency limit
118 117
   #define MAX_FREQ_TIME (1000000.0/XY_FREQUENCY_LIMIT)
@@ -126,15 +125,15 @@ volatile unsigned char block_buffer_tail;           // Index of the block to pro
126 125
   static char meas_sample; //temporary variable to hold filament measurement sample
127 126
 #endif
128 127
 
128
+//===========================================================================
129
+//================================ functions ================================
130
+//===========================================================================
131
+
129 132
 // Get the next / previous index of the next block in the ring buffer
130 133
 // NOTE: Using & here (not %) because BLOCK_BUFFER_SIZE is always a power of 2
131 134
 FORCE_INLINE int8_t next_block_index(int8_t block_index) { return BLOCK_MOD(block_index + 1); }
132 135
 FORCE_INLINE int8_t prev_block_index(int8_t block_index) { return BLOCK_MOD(block_index - 1); }
133 136
 
134
-//===========================================================================
135
-//================================ Functions ================================
136
-//===========================================================================
137
-
138 137
 // Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the 
139 138
 // given acceleration:
140 139
 FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) {

+ 9
- 5
Marlin/planner.h View File

@@ -115,15 +115,19 @@ FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block
115 115
 
116 116
 void plan_set_e_position(const float &e);
117 117
 
118
+//===========================================================================
119
+//============================= public variables ============================
120
+//===========================================================================
121
+
118 122
 extern millis_t minsegmenttime;
119
-extern float max_feedrate[NUM_AXIS]; // set the max speeds
123
+extern float max_feedrate[NUM_AXIS]; // Max speeds in mm per minute
120 124
 extern float axis_steps_per_unit[NUM_AXIS];
121 125
 extern unsigned long max_acceleration_units_per_sq_second[NUM_AXIS]; // Use M201 to override by software
122 126
 extern float minimumfeedrate;
123
-extern float acceleration;         // Normal acceleration mm/s^2  THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
124
-extern float retract_acceleration; //  mm/s^2   filament pull-pack and push-forward  while standing still in the other axis M204 TXXXX
125
-extern float travel_acceleration;  // Travel acceleration mm/s^2  THIS IS THE DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX
126
-extern float max_xy_jerk; //speed than can be stopped at once, if i understand correctly.
127
+extern float acceleration;         // Normal acceleration mm/s^2  DEFAULT ACCELERATION for all printing moves. M204 SXXXX
128
+extern float retract_acceleration; // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axes M204 TXXXX
129
+extern float travel_acceleration;  // Travel acceleration mm/s^2  DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX
130
+extern float max_xy_jerk;          // The largest speed change requiring no acceleration
127 131
 extern float max_z_jerk;
128 132
 extern float max_e_jerk;
129 133
 extern float mintravelfeedrate;

+ 3
- 2
Marlin/temperature.cpp View File

@@ -89,8 +89,9 @@ unsigned char soft_pwm_bed;
89 89
 #endif
90 90
 
91 91
 //===========================================================================
92
-//=============================private variables============================
92
+//============================ private variables ============================
93 93
 //===========================================================================
94
+
94 95
 static volatile bool temp_meas_ready = false;
95 96
 
96 97
 #ifdef PIDTEMP
@@ -187,7 +188,7 @@ static void updateTemperaturesFromRawValues();
187 188
 #endif
188 189
 
189 190
 //===========================================================================
190
-//=============================   functions      ============================
191
+//================================ functions ================================
191 192
 //===========================================================================
192 193
 
193 194
 void PID_autotune(float temp, int extruder, int ncycles)

+ 4
- 4
Marlin/ultralcd.cpp View File

@@ -868,10 +868,10 @@ static void lcd_control_temperature_preheat_pla_settings_menu() {
868 868
   MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu);
869 869
   MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &plaPreheatFanSpeed, 0, 255);
870 870
   #if TEMP_SENSOR_0 != 0
871
-    MENU_ITEM_EDIT(int3, MSG_NOZZLE, &plaPreheatHotendTemp, 0, HEATER_0_MAXTEMP - 15);
871
+    MENU_ITEM_EDIT(int3, MSG_NOZZLE, &plaPreheatHotendTemp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15);
872 872
   #endif
873 873
   #if TEMP_SENSOR_BED != 0
874
-    MENU_ITEM_EDIT(int3, MSG_BED, &plaPreheatHPBTemp, 0, BED_MAXTEMP - 15);
874
+    MENU_ITEM_EDIT(int3, MSG_BED, &plaPreheatHPBTemp, BED_MINTEMP, BED_MAXTEMP - 15);
875 875
   #endif
876 876
   #ifdef EEPROM_SETTINGS
877 877
     MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
@@ -884,10 +884,10 @@ static void lcd_control_temperature_preheat_abs_settings_menu() {
884 884
   MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu);
885 885
   MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &absPreheatFanSpeed, 0, 255);
886 886
   #if TEMP_SENSOR_0 != 0
887
-    MENU_ITEM_EDIT(int3, MSG_NOZZLE, &absPreheatHotendTemp, 0, HEATER_0_MAXTEMP - 15);
887
+    MENU_ITEM_EDIT(int3, MSG_NOZZLE, &absPreheatHotendTemp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15);
888 888
   #endif
889 889
   #if TEMP_SENSOR_BED != 0
890
-    MENU_ITEM_EDIT(int3, MSG_BED, &absPreheatHPBTemp, 0, BED_MAXTEMP - 15);
890
+    MENU_ITEM_EDIT(int3, MSG_BED, &absPreheatHPBTemp, BED_MINTEMP, BED_MAXTEMP - 15);
891 891
   #endif
892 892
   #ifdef EEPROM_SETTINGS
893 893
     MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);

+ 3
- 3
Marlin/watchdog.cpp View File

@@ -7,11 +7,11 @@
7 7
 #include "ultralcd.h"
8 8
 
9 9
 //===========================================================================
10
-//=============================private variables  ============================
10
+//============================ private variables ============================
11 11
 //===========================================================================
12 12
 
13 13
 //===========================================================================
14
-//=============================functinos         ============================
14
+//================================ functions ================================
15 15
 //===========================================================================
16 16
 
17 17
 
@@ -36,7 +36,7 @@ void watchdog_reset()
36 36
 }
37 37
 
38 38
 //===========================================================================
39
-//=============================ISR               ============================
39
+//=================================== ISR ===================================
40 40
 //===========================================================================
41 41
 
42 42
 //Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled.

Loading…
Cancel
Save