Browse Source

M154 Position Auto-Report (#18427)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Luu Lac 3 years ago
parent
commit
7f774cab90
No account linked to committer's email address

+ 5
- 0
Marlin/Configuration_adv.h View File

@@ -3417,6 +3417,11 @@
3417 3417
 #define AUTO_REPORT_TEMPERATURES
3418 3418
 
3419 3419
 /**
3420
+ * Auto-report position with M154 S<seconds>
3421
+ */
3422
+//#define AUTO_REPORT_POSITION
3423
+
3424
+/**
3420 3425
  * Include capabilities in M115 output
3421 3426
  */
3422 3427
 #define EXTENDED_CAPABILITIES_REPORT

+ 1
- 0
Marlin/src/MarlinCore.cpp View File

@@ -796,6 +796,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
796 796
     if (!gcode.autoreport_paused) {
797 797
       TERN_(AUTO_REPORT_TEMPERATURES, thermalManager.auto_reporter.tick());
798 798
       TERN_(AUTO_REPORT_SD_STATUS, card.auto_reporter.tick());
799
+      TERN_(AUTO_REPORT_POSITION, position_auto_reporter.tick());
799 800
     }
800 801
   #endif
801 802
 

+ 4
- 0
Marlin/src/gcode/gcode.cpp View File

@@ -565,6 +565,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
565 565
         case 193: M193(); break;                                  // M193: Wait for cooler temperature to reach target
566 566
       #endif
567 567
 
568
+      #if ENABLED(AUTO_REPORT_POSITION)
569
+        case 154: M154(); break;                                  // M155: Set position auto-report interval
570
+      #endif
571
+
568 572
       #if BOTH(AUTO_REPORT_TEMPERATURES, HAS_TEMP_SENSOR)
569 573
         case 155: M155(); break;                                  // M155: Set temperature auto-report interval
570 574
       #endif

+ 5
- 0
Marlin/src/gcode/gcode.h View File

@@ -159,6 +159,7 @@
159 159
  * M145 - Set heatup values for materials on the LCD. H<hotend> B<bed> F<fan speed> for S<material> (0=PLA, 1=ABS)
160 160
  * M149 - Set temperature units. (Requires TEMPERATURE_UNITS_SUPPORT)
161 161
  * M150 - Set Status LED Color as R<red> U<green> B<blue> W<white> P<bright>. Values 0-255. (Requires BLINKM, RGB_LED, RGBW_LED, NEOPIXEL_LED, PCA9533, or PCA9632).
162
+ * M154 - Auto-report position with interval of S<seconds>. (Requires AUTO_REPORT_POSITION)
162 163
  * M155 - Auto-report temperatures with interval of S<seconds>. (Requires AUTO_REPORT_TEMPERATURES)
163 164
  * M163 - Set a single proportion for a mixing extruder. (Requires MIXING_EXTRUDER)
164 165
  * M164 - Commit the mix and save to a virtual tool (current, or as specified by 'S'). (Requires MIXING_EXTRUDER)
@@ -721,6 +722,10 @@ private:
721 722
     static void M150();
722 723
   #endif
723 724
 
725
+  #if ENABLED(AUTO_REPORT_POSITION)
726
+    static void M154();
727
+  #endif
728
+
724 729
   #if BOTH(AUTO_REPORT_TEMPERATURES, HAS_TEMP_SENSOR)
725 730
     static void M155();
726 731
   #endif

+ 3
- 0
Marlin/src/gcode/host/M115.cpp View File

@@ -82,6 +82,9 @@ void GcodeSuite::M115() {
82 82
     // Volumetric Extrusion (M200)
83 83
     cap_line(PSTR("VOLUMETRIC"), DISABLED(NO_VOLUMETRICS));
84 84
 
85
+    // AUTOREPORT_POS (M154)
86
+    cap_line(PSTR("AUTOREPORT_POS"), ENABLED(AUTO_REPORT_POSITION));
87
+
85 88
     // AUTOREPORT_TEMP (M155)
86 89
     cap_line(PSTR("AUTOREPORT_TEMP"), ENABLED(AUTO_REPORT_TEMPERATURES));
87 90
 

+ 40
- 0
Marlin/src/gcode/host/M154.cpp View File

@@ -0,0 +1,40 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 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 <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#include "../../inc/MarlinConfigPre.h"
24
+
25
+#if ENABLED(AUTO_REPORT_POSITION)
26
+
27
+#include "../gcode.h"
28
+#include "../../module/motion.h"
29
+
30
+/**
31
+ * M154: Set position auto-report interval. M154 S<seconds>
32
+ */
33
+void GcodeSuite::M154() {
34
+
35
+  if (parser.seenval('S'))
36
+    position_auto_reporter.set_interval(parser.value_byte());
37
+
38
+}
39
+
40
+#endif // AUTO_REPORT_POSITION

+ 1
- 1
Marlin/src/inc/Conditionals_post.h View File

@@ -2231,7 +2231,7 @@
2231 2231
 #if !HAS_TEMP_SENSOR
2232 2232
   #undef AUTO_REPORT_TEMPERATURES
2233 2233
 #endif
2234
-#if EITHER(AUTO_REPORT_TEMPERATURES, AUTO_REPORT_SD_STATUS)
2234
+#if ANY(AUTO_REPORT_TEMPERATURES, AUTO_REPORT_SD_STATUS, AUTO_REPORT_POSITION)
2235 2235
   #define HAS_AUTO_REPORTING 1
2236 2236
 #endif
2237 2237
 

+ 5
- 0
Marlin/src/module/motion.cpp View File

@@ -230,6 +230,11 @@ void report_current_position_projected() {
230 230
   stepper.report_a_position(planner.position);
231 231
 }
232 232
 
233
+#if ENABLED(AUTO_REPORT_POSITION)
234
+  //struct PositionReport { void report() { report_current_position_projected(); } };
235
+  AutoReporter<PositionReport> position_auto_reporter;
236
+#endif
237
+
233 238
 #if EITHER(FULL_REPORT_TO_HOST_FEATURE, REALTIME_REPORTING_COMMANDS)
234 239
 
235 240
   M_StateEnum M_State_grbl = M_INIT;

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

@@ -211,6 +211,12 @@ void report_real_position();
211 211
 void report_current_position();
212 212
 void report_current_position_projected();
213 213
 
214
+#if ENABLED(AUTO_REPORT_POSITION)
215
+  #include "../libs/autoreport.h"
216
+  struct PositionReport { static void report() { report_current_position_projected(); } };
217
+  extern AutoReporter<PositionReport> position_auto_reporter;
218
+#endif
219
+
214 220
 #if EITHER(FULL_REPORT_TO_HOST_FEATURE, REALTIME_REPORTING_COMMANDS)
215 221
   #define HAS_GRBL_STATE 1
216 222
   /**

+ 1
- 1
buildroot/tests/mega2560 View File

@@ -56,7 +56,7 @@ opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO NUM_SERVOS 1 \
56 56
         FIL_RUNOUT3_STATE HIGH
57 57
 opt_enable VIKI2 BOOT_MARLIN_LOGO_ANIMATED SDSUPPORT AUTO_REPORT_SD_STATUS \
58 58
            Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE \
59
-           EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL \
59
+           EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL AUTO_REPORT_POSITION \
60 60
            NO_VOLUMETRICS EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES AUTOTEMP G38_PROBE_TARGET JOYSTICK \
61 61
            DIRECT_STEPPING DETECT_BROKEN_ENDSTOP \
62 62
            FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE Z_SAFE_HOMING FIL_RUNOUT3_PULLUP

+ 1
- 0
ini/features.ini View File

@@ -182,6 +182,7 @@ CNC_COORDINATE_SYSTEMS                 = src_filter=+<src/gcode/geometry/G53-G59
182 182
 HAS_M206_COMMAND                       = src_filter=+<src/gcode/geometry/M206_M428.cpp>
183 183
 EXPECTED_PRINTER_CHECK                 = src_filter=+<src/gcode/host/M16.cpp>
184 184
 HOST_KEEPALIVE_FEATURE                 = src_filter=+<src/gcode/host/M113.cpp>
185
+AUTO_REPORT_POSITION                   = src_filter=+<src/gcode/host/M154.cpp>
185 186
 REPETIER_GCODE_M360                    = src_filter=+<src/gcode/host/M360.cpp>
186 187
 HAS_GCODE_M876                         = src_filter=+<src/gcode/host/M876.cpp>
187 188
 HAS_RESUME_CONTINUE                    = src_filter=+<src/gcode/lcd/M0_M1.cpp>

+ 1
- 0
platformio.ini View File

@@ -198,6 +198,7 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
198 198
   -<src/gcode/geometry/M206_M428.cpp>
199 199
   -<src/gcode/host/M16.cpp>
200 200
   -<src/gcode/host/M113.cpp>
201
+  -<src/gcode/host/M154.cpp>
201 202
   -<src/gcode/host/M360.cpp>
202 203
   -<src/gcode/host/M876.cpp>
203 204
   -<src/gcode/lcd/M0_M1.cpp>

Loading…
Cancel
Save