Skip to content

Commit e3998dc

Browse files
shitcreekthinkyhead
andcommitted
M154 Position Auto-Report (#18427)
Co-authored-by: Scott Lahteine <[email protected]>
1 parent b6e1838 commit e3998dc

File tree

12 files changed

+73
-2
lines changed

12 files changed

+73
-2
lines changed

Marlin/Configuration_adv.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3416,6 +3416,11 @@
34163416
*/
34173417
#define AUTO_REPORT_TEMPERATURES
34183418

3419+
/**
3420+
* Auto-report position with M154 S<seconds>
3421+
*/
3422+
//#define AUTO_REPORT_POSITION
3423+
34193424
/**
34203425
* Include capabilities in M115 output
34213426
*/

Marlin/src/MarlinCore.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
796796
if (!gcode.autoreport_paused) {
797797
TERN_(AUTO_REPORT_TEMPERATURES, thermalManager.auto_reporter.tick());
798798
TERN_(AUTO_REPORT_SD_STATUS, card.auto_reporter.tick());
799+
TERN_(AUTO_REPORT_POSITION, position_auto_reporter.tick());
799800
}
800801
#endif
801802

Marlin/src/gcode/gcode.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
565565
case 193: M193(); break; // M193: Wait for cooler temperature to reach target
566566
#endif
567567

568+
#if ENABLED(AUTO_REPORT_POSITION)
569+
case 154: M154(); break; // M155: Set position auto-report interval
570+
#endif
571+
568572
#if BOTH(AUTO_REPORT_TEMPERATURES, HAS_TEMP_SENSOR)
569573
case 155: M155(); break; // M155: Set temperature auto-report interval
570574
#endif

Marlin/src/gcode/gcode.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
* M145 - Set heatup values for materials on the LCD. H<hotend> B<bed> F<fan speed> for S<material> (0=PLA, 1=ABS)
160160
* M149 - Set temperature units. (Requires TEMPERATURE_UNITS_SUPPORT)
161161
* 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)
162163
* M155 - Auto-report temperatures with interval of S<seconds>. (Requires AUTO_REPORT_TEMPERATURES)
163164
* M163 - Set a single proportion for a mixing extruder. (Requires MIXING_EXTRUDER)
164165
* M164 - Commit the mix and save to a virtual tool (current, or as specified by 'S'). (Requires MIXING_EXTRUDER)
@@ -721,6 +722,10 @@ class GcodeSuite {
721722
static void M150();
722723
#endif
723724

725+
#if ENABLED(AUTO_REPORT_POSITION)
726+
static void M154();
727+
#endif
728+
724729
#if BOTH(AUTO_REPORT_TEMPERATURES, HAS_TEMP_SENSOR)
725730
static void M155();
726731
#endif

Marlin/src/gcode/host/M115.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ void GcodeSuite::M115() {
8282
// Volumetric Extrusion (M200)
8383
cap_line(PSTR("VOLUMETRIC"), DISABLED(NO_VOLUMETRICS));
8484

85+
// AUTOREPORT_POS (M154)
86+
cap_line(PSTR("AUTOREPORT_POS"), ENABLED(AUTO_REPORT_POSITION));
87+
8588
// AUTOREPORT_TEMP (M155)
8689
cap_line(PSTR("AUTOREPORT_TEMP"), ENABLED(AUTO_REPORT_TEMPERATURES));
8790

Marlin/src/gcode/host/M154.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Marlin/src/inc/Conditionals_post.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2231,7 +2231,7 @@
22312231
#if !HAS_TEMP_SENSOR
22322232
#undef AUTO_REPORT_TEMPERATURES
22332233
#endif
2234-
#if EITHER(AUTO_REPORT_TEMPERATURES, AUTO_REPORT_SD_STATUS)
2234+
#if ANY(AUTO_REPORT_TEMPERATURES, AUTO_REPORT_SD_STATUS, AUTO_REPORT_POSITION)
22352235
#define HAS_AUTO_REPORTING 1
22362236
#endif
22372237

Marlin/src/module/motion.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,11 @@ void report_current_position_projected() {
230230
stepper.report_a_position(planner.position);
231231
}
232232

233+
#if ENABLED(AUTO_REPORT_POSITION)
234+
//struct PositionReport { void report() { report_current_position_projected(); } };
235+
AutoReporter<PositionReport> position_auto_reporter;
236+
#endif
237+
233238
#if EITHER(FULL_REPORT_TO_HOST_FEATURE, REALTIME_REPORTING_COMMANDS)
234239

235240
M_StateEnum M_State_grbl = M_INIT;

Marlin/src/module/motion.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ void report_real_position();
211211
void report_current_position();
212212
void report_current_position_projected();
213213

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+
214220
#if EITHER(FULL_REPORT_TO_HOST_FEATURE, REALTIME_REPORTING_COMMANDS)
215221
#define HAS_GRBL_STATE 1
216222
/**

buildroot/tests/mega2560

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO NUM_SERVOS 1 \
5656
FIL_RUNOUT3_STATE HIGH
5757
opt_enable VIKI2 BOOT_MARLIN_LOGO_ANIMATED SDSUPPORT AUTO_REPORT_SD_STATUS \
5858
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 \
6060
NO_VOLUMETRICS EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES AUTOTEMP G38_PROBE_TARGET JOYSTICK \
6161
DIRECT_STEPPING DETECT_BROKEN_ENDSTOP \
6262
FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE Z_SAFE_HOMING FIL_RUNOUT3_PULLUP

0 commit comments

Comments
 (0)