From a064ce47221523fc6e44669622ba4ce80f260c98 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Sun, 10 Jan 2021 15:15:44 +0100 Subject: [PATCH 1/5] Add gcode `M123` Tachometer value --- Firmware/Marlin.h | 2 ++ Firmware/Marlin_main.cpp | 16 +++++++++++++++- Firmware/temperature.cpp | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 19635c178..07ed8594c 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -289,6 +289,7 @@ extern float min_pos[3]; extern float max_pos[3]; extern bool axis_known_position[3]; extern int fanSpeed; +extern uint8_t newFanSpeed; extern int8_t lcd_change_fil_state; extern float default_retraction; @@ -480,6 +481,7 @@ void force_high_power_mode(bool start_high_power_section); bool gcode_M45(bool onlyZ, int8_t verbosity_level); void gcode_M114(); +void gcode_M123(); void gcode_M701(); #define UVLO !(PINE & (1<<4)) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 9da891d87..2a0df6bfd 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -270,6 +270,7 @@ float extruder_offset[NUM_EXTRUDER_OFFSETS][EXTRUDERS] = { uint8_t active_extruder = 0; int fanSpeed=0; +uint8_t newFanSpeed = 0; #ifdef FWRETRACT bool retracted[EXTRUDERS]={false @@ -3166,6 +3167,11 @@ void gcode_M114() SERIAL_PROTOCOLLN(""); } +void gcode_M123() +{ + printf_P(_N("E0:%d RPM PRN1:%d RPM E0@:%u PRN1@:%d\n"), 60*fan_speed[active_extruder], 60*fan_speed[1], newFanSpeed, fanSpeed); +} + //! extracted code to compute z_shift for M600 in case of filament change operation //! requested from fsensors. //! The function ensures, that the printhead lifts to at least 25mm above the heat bed @@ -3606,6 +3612,7 @@ extern uint8_t st_backlash_y; //!@n M115 - Capabilities string //!@n M117 - display message //!@n M119 - Output Endstop status to serial port +//!@n M123 - Tachometer value //!@n M126 - Solenoid Air Valve Open (BariCUDA support by jmil) //!@n M127 - Solenoid Air Valve Closed (BariCUDA vent to atmospheric pressure by jmil) //!@n M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil) @@ -6965,7 +6972,14 @@ Sigma_Exit: #endif break; //!@todo update for all axes, use for loop - + + /*! + ### M123 - Tachometer value M123: Tachometer value + */ + case 123: + gcode_M123(); + break; + #ifdef BLINKM /*! diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 3b38c25cc..29e5427c4 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -522,7 +522,7 @@ void setExtruderAutoFanState(uint8_t state) //the fan to either On or Off during certain tests/errors. fanState = state; - uint8_t newFanSpeed = 0; + newFanSpeed = 0; if (fanState & 0x01) { #ifdef EXTRUDER_ALTFAN_DETECT From 9264454d3a8bae032937885d1833b5f1cae0ca29 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Tue, 19 Jan 2021 09:01:46 +0100 Subject: [PATCH 2/5] Gcode `M123` only if FANCHECK and TACHOs are defined Gcode `M155` added parameter "C" to activate auto-report for temperatures, fans and positions Updated doxygen @todo Update RepRap Wiki @todo improve code --- Firmware/Configuration_adv.h | 27 ++++++- Firmware/Marlin.h | 2 + Firmware/Marlin_main.cpp | 148 ++++++++++++++++++++++++++++------- 3 files changed, 148 insertions(+), 29 deletions(-) diff --git a/Firmware/Configuration_adv.h b/Firmware/Configuration_adv.h index 65ed20751..9f2ee64a4 100644 --- a/Firmware/Configuration_adv.h +++ b/Firmware/Configuration_adv.h @@ -63,12 +63,35 @@ #define FAN_KICKSTART_TIME 800 /** - * Auto-report temperatures with M155 S + * Auto-report all at once with M155 S C[bitmask] with single timer + * + * bit 0 = Auto-report temperatures + * bit 1 = Auto-report fans + * bit 2 = Auto-report position + * bit 3 = free + * bit 4 = free + * bit 5 = free + * bit 6 = free + * bit 7 = free +*/ +#define AUTO_REPORT_ALL + +#ifndef AUTO_REPORT_ALL +/** + * Auto-report temperatures with M155 S [C1] */ #define AUTO_REPORT_TEMPERATURES +/** + * Auto-report fans with M155 S C2 + */ +#define AUTO_REPORT_FANS - +/** + * Auto-report position with M155 S C4 + */ +#define AUTO_REPORT_POSITION +#endif //NOT AUTO_REPORT_ALL //=========================================================================== //=============================Mechanical Settings=========================== diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 07ed8594c..307b8c91b 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -481,7 +481,9 @@ void force_high_power_mode(bool start_high_power_section); bool gcode_M45(bool onlyZ, int8_t verbosity_level); void gcode_M114(); +#if (defined(FANCHECK) && (((defined(TACH_0) && (TACH_0 >-1)) || (defined(TACH_1) && (TACH_1 > -1))))) void gcode_M123(); +#endif //FANCHECK and TACH_0 and TACH_1 void gcode_M701(); #define UVLO !(PINE & (1<<4)) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 2a0df6bfd..6cd2f43fb 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -390,11 +390,23 @@ static int saved_fanSpeed = 0; //!< Print fan speed static int saved_feedmultiply_mm = 100; -#ifdef AUTO_REPORT_TEMPERATURES -static LongTimer auto_report_temp_timer; -static uint8_t auto_report_temp_period = 0; +#if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_TEMPERATURES) || defined(AUTO_REPORT_FANS) || defined(AUTO_REPORT_POSITION) +static LongTimer auto_report_timer; //Also used for AUTO_REPORT_TEMPERATURES +static uint8_t auto_report_period = 0; //Also used for AUTO_REPORT_TEMPERATURES +#endif //AUTO_REPORT_ALL or AUTO_REPORT_TEMPERATURES or AUTO_REPORT_FANS or AUTO_REPORT_POSITION + +#if defined(AUTO_REPORT_TEMPERATURES) || defined(AUTO_REPORT_ALL) +static bool auto_report_temp_active = false; #endif //AUTO_REPORT_TEMPERATURES +#if defined(AUTO_REPORT_FANS) || defined(AUTO_REPORT_ALL) +static bool auto_report_fans_active = false; +#endif //AUTO_REPORT_FANS + +#if defined(AUTO_REPORT_POSITION) || defined(AUTO_REPORT_ALL) +static bool auto_report_position_active = false; +#endif //AUTO_REPORT_POSITION + //=========================================================================== //=============================Routines====================================== //=========================================================================== @@ -1731,16 +1743,29 @@ void host_keepalive() { if (farm_mode) return; long ms = _millis(); -#ifdef AUTO_REPORT_TEMPERATURES - if (auto_report_temp_timer.running()) +#if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_TEMPERATURES) || defined(AUTO_REPORT_FANS) || defined(AUTO_REPORT_POSITION) + if (auto_report_timer.running()) { - if (auto_report_temp_timer.expired(auto_report_temp_period * 1000ul)) + if (auto_report_timer.expired(auto_report_period * 1000ul)) { - gcode_M105(active_extruder); - auto_report_temp_timer.start(); + if(auto_report_temp_active){ + gcode_M105(active_extruder); + } +#if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_FANS) && (defined(FANCHECK) && (((defined(TACH_0) && (TACH_0 >-1)) || (defined(TACH_1) && (TACH_1 > -1))))) + if(auto_report_fans_active){ + gcode_M123(); + } +#endif //AUTO_REPORT_ALL or AUTO_REPORT_FANS and (FANCHECK and TACH_0 or TACH_1) +#if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_POSITION) + if(auto_report_position_active){ + gcode_M114(); + } +#endif //AUTO_REPORT_POSITION or AUTO_REPORT_FANS or AUTO_REPORT_POSITION + auto_report_timer.start(); } } -#endif //AUTO_REPORT_TEMPERATURES +#endif //AUTO_REPORT_ALL + if (host_keepalive_interval && busy_state != NOT_BUSY) { if ((ms - prev_busy_signal_ms) < (long)(1000L * host_keepalive_interval)) return; @@ -3167,10 +3192,12 @@ void gcode_M114() SERIAL_PROTOCOLLN(""); } +#if (defined(FANCHECK) && (((defined(TACH_0) && (TACH_0 >-1)) || (defined(TACH_1) && (TACH_1 > -1))))) void gcode_M123() { printf_P(_N("E0:%d RPM PRN1:%d RPM E0@:%u PRN1@:%d\n"), 60*fan_speed[active_extruder], 60*fan_speed[1], newFanSpeed, fanSpeed); } +#endif //FANCHECK and TACH_0 or TACH_1 //! extracted code to compute z_shift for M600 in case of filament change operation //! requested from fsensors. @@ -3521,7 +3548,14 @@ static void cap_line(const char* name, bool ena = false) { static void extended_capabilities_report() { - cap_line(PSTR("AUTOREPORT_TEMP"), ENABLED(AUTO_REPORT_TEMPERATURES)); + // AUTOREPORT_TEMP (M155) + cap_line(PSTR("AUTOREPORT_TEMP"), (ENABLED(AUTO_REPORT_TEMPERATURES)) || ENABLED(AUTO_REPORT_ALL)); +#if (defined(FANCHECK) && (((defined(TACH_0) && (TACH_0 >-1)) || (defined(TACH_1) && (TACH_1 > -1))))) + // AUTOREPORT_FANS (M123) + cap_line(PSTR("AUTOREPORT_FANS"), (ENABLED(AUTO_REPORT_FANS) || ENABLED(AUTO_REPORT_ALL))); +#endif //FANCHECK and TACH_0 or TACH_1 + // AUTOREPORT_POSITION (M114) + cap_line(PSTR("AUTOREPORT_POSITION"), (ENABLED(AUTO_REPORT_POSITION) || ENABLED(AUTO_REPORT_ALL))); //@todo } #endif //EXTENDED_CAPABILITIES_REPORT @@ -3619,7 +3653,7 @@ extern uint8_t st_backlash_y; //!@n M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil) //!@n M140 - Set bed target temp //!@n 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. -//!@n M155 - Automatically send temperatures +//!@n M155 - Automatically send temperatures, fan speeds, position //!@n M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating //! Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling //!@n M200 D- set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters). @@ -6413,31 +6447,75 @@ Sigma_Exit: break; } -#ifdef AUTO_REPORT_TEMPERATURES +#if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_TEMPERATURES) || defined(AUTO_REPORT_FANS) || defined(AUTO_REPORT_POSITION) /*! - ### M155 - Automatically send temperatures M155: Automatically send temperatures + ### M155 - Automatically send status M155: Automatically send temperatures #### Usage - M155 [ S ] + M155 [ S ] [ C ] #### Parameters - - `S` - Set temperature autoreporting interval in seconds. 0 to disable. Maximum: 255 - - */ + - `S` - Set autoreporting interval in seconds. 0 to disable. Maximum: 255 + - `C` - Activate auto-report function. Default is temperature. + + bit 0 = Auto-report temperatures + bit 1 = Auto-report fans + bit 2 = Auto-report position + bit 3 = free + bit 4 = free + bit 5 = free + bit 6 = free + bit 7 = free + */ + //!@todo update RepRap Gcode wiki + //!@todo Should be temperature always? Octoprint doesn't switch to M105 if M155 timer is set + + union { + struct + { + uint8_t ar_temp_active : 1; //Temperature flag + uint8_t ar_fans_active : 1; //Fans flag + uint8_t ar_pos_active : 1; //Position flag + uint8_t ar_4_active : 1; //Unused + uint8_t ar_5_active : 1; //Unused + uint8_t ar_6_active : 1; //Unused + uint8_t ar_7_active : 1; //Unused + } __attribute__((packed)) bits; + uint8_t byte; + } arFunctionsActive; case 155: { - if (code_seen('S')) - { - auto_report_temp_period = code_value_uint8(); - if (auto_report_temp_period != 0) - auto_report_temp_timer.start(); - else - auto_report_temp_timer.stop(); + if (code_seen('S')) + { + auto_report_period = code_value_uint8(); + if (auto_report_period != 0){ + auto_report_timer.start(); } - } + else{ + auto_report_timer.stop(); + } + } + if (code_seen('C')) + { + arFunctionsActive.byte = code_value(); + //arFunctionsActive.bits.ar_temp_active = 1; //auto-report temperatures always on + } + else{ + arFunctionsActive.byte = 1; + } +#if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_TEMPERATURES) + auto_report_temp_active = arFunctionsActive.bits.ar_temp_active; +#endif //AUTO_REPORT_ALL or AUTO_REPORT_TEMPERATURES +#if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_FANS) + auto_report_fans_active = arFunctionsActive.bits.ar_fans_active; +#endif //AUTO_REPORT_ALL or AUTO_REPORT_FANS +#if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_POSITION) + auto_report_position_active = arFunctionsActive.bits.ar_pos_active; + #endif //AUTO_REPORT_ALL or AUTO_REPORT_POSITION + } break; -#endif //AUTO_REPORT_TEMPERATURES +#endif //AUTO_REPORT_ALL or AUTO_REPORT_TEMPERATURES or AUTO_REPORT_FANS or AUTO_REPORT_POSITION /*! ### M109 - Wait for extruder temperature M109: Set Extruder Temperature and Wait @@ -6973,13 +7051,29 @@ Sigma_Exit: break; //!@todo update for all axes, use for loop +#if (defined(FANCHECK) && (((defined(TACH_0) && (TACH_0 >-1)) || (defined(TACH_1) && (TACH_1 > -1))))) /*! ### M123 - Tachometer value M123: Tachometer value + This command is used to report fan speeds and fan pwm values. + #### Usage + + M123 + + - E0: - Hotend fan speed in RPM + - PRN1: - Part cooling fans speed in RPM + - E0@: - Hotend fan PWM value + - PRN1@: -Part cooling fan PWM value + + _Example:_ + + E0:3240 RPM PRN1:4560 RPM E0@:255 PRN1@:255 + */ + //!@todo Update RepRap Gcode wiki case 123: gcode_M123(); break; - +#endif //FANCHECK and TACH_0 and TACH_1 #ifdef BLINKM /*! From 31951fe8c9a74cb348a076dd280618391c353a46 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Wed, 20 Jan 2021 11:46:25 +0100 Subject: [PATCH 3/5] Code refactoring Motivation: - save some RAM joining the autoreport flags into 1 byte - encapsulate the magic of setting bit masks/features into a class with a stable public interface --- Firmware/Marlin_main.cpp | 143 +++++++++++++++++++++++---------------- Firmware/Timer.h | 4 +- 2 files changed, 86 insertions(+), 61 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 6cd2f43fb..f96139654 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -390,22 +390,79 @@ static int saved_fanSpeed = 0; //!< Print fan speed static int saved_feedmultiply_mm = 100; -#if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_TEMPERATURES) || defined(AUTO_REPORT_FANS) || defined(AUTO_REPORT_POSITION) -static LongTimer auto_report_timer; //Also used for AUTO_REPORT_TEMPERATURES -static uint8_t auto_report_period = 0; //Also used for AUTO_REPORT_TEMPERATURES -#endif //AUTO_REPORT_ALL or AUTO_REPORT_TEMPERATURES or AUTO_REPORT_FANS or AUTO_REPORT_POSITION +class AutoReportFeatures { + union { + struct { + uint8_t temp : 1; //Temperature flag + uint8_t fans : 1; //Fans flag + uint8_t pos: 1; //Position flag + uint8_t ar4 : 1; //Unused + uint8_t ar5 : 1; //Unused + uint8_t ar6 : 1; //Unused + uint8_t ar7 : 1; //Unused + } __attribute__((packed)) bits; + uint8_t byte; + } arFunctionsActive; + uint8_t auto_report_period; //Also used for AUTO_REPORT_TEMPERATURES +public: + LongTimer auto_report_timer; //Also used for AUTO_REPORT_TEMPERATURES + AutoReportFeatures():auto_report_period(0){ +#if defined(AUTO_REPORT_ALL) + arFunctionsActive.byte = 0xff; +#else + arFunctionsActive.byte = 0; +# if defined(AUTO_REPORT_TEMPERATURES) + arFunctionsActive.bits.temp = 1; +# endif +# if defined(AUTO_REPORT_FANS) + arFunctionsActive.bits.fans = 1; +# endif +# if defined(AUTO_REPORT_POSITION) + arFunctionsActive.bits.pos = 1; +# endif +#endif + } + + inline bool Temp()const { return arFunctionsActive.bits.temp != 0; } + inline void SetTemp(uint8_t v){ arFunctionsActive.bits.temp = v; } -#if defined(AUTO_REPORT_TEMPERATURES) || defined(AUTO_REPORT_ALL) -static bool auto_report_temp_active = false; -#endif //AUTO_REPORT_TEMPERATURES + inline bool Fans()const { return arFunctionsActive.bits.fans != 0; } + inline void SetFans(uint8_t v){ arFunctionsActive.bits.fans = v; } -#if defined(AUTO_REPORT_FANS) || defined(AUTO_REPORT_ALL) -static bool auto_report_fans_active = false; -#endif //AUTO_REPORT_FANS + inline bool Pos()const { return arFunctionsActive.bits.pos != 0; } + inline void SetPos(uint8_t v){ arFunctionsActive.bits.pos = v; } + + inline void SetMask(uint8_t mask){ arFunctionsActive.byte = mask; } + + /// sets the autoreporting timer's period + /// setting it to zero stops the timer + void SetPeriod(uint8_t p){ + auto_report_period = p; + if (auto_report_period != 0){ + auto_report_timer.start(); + } else{ + auto_report_timer.stop(); + } + } + + inline void TimerStart() { auto_report_timer.start(); } + inline bool TimerRunning()const { return auto_report_timer.running(); } + inline bool TimerExpired() { return auto_report_timer.expired(auto_report_period * 1000ul); } +}; -#if defined(AUTO_REPORT_POSITION) || defined(AUTO_REPORT_ALL) -static bool auto_report_position_active = false; -#endif //AUTO_REPORT_POSITION +AutoReportFeatures autoReportFeatures; + +//#if defined(AUTO_REPORT_TEMPERATURES) || defined(AUTO_REPORT_ALL) +//static bool auto_report_temp_active = false; +//#endif //AUTO_REPORT_TEMPERATURES + +//#if defined(AUTO_REPORT_FANS) || defined(AUTO_REPORT_ALL) +//static bool auto_report_fans_active = false; +//#endif //AUTO_REPORT_FANS + +//#if defined(AUTO_REPORT_POSITION) || defined(AUTO_REPORT_ALL) +//static bool auto_report_position_active = false; +//#endif //AUTO_REPORT_POSITION //=========================================================================== //=============================Routines====================================== @@ -1744,24 +1801,24 @@ void host_keepalive() { long ms = _millis(); #if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_TEMPERATURES) || defined(AUTO_REPORT_FANS) || defined(AUTO_REPORT_POSITION) - if (auto_report_timer.running()) + if ( autoReportFeatures.TimerRunning()) { - if (auto_report_timer.expired(auto_report_period * 1000ul)) + if (autoReportFeatures.TimerExpired()) { - if(auto_report_temp_active){ + if(autoReportFeatures.Temp()){ gcode_M105(active_extruder); } #if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_FANS) && (defined(FANCHECK) && (((defined(TACH_0) && (TACH_0 >-1)) || (defined(TACH_1) && (TACH_1 > -1))))) - if(auto_report_fans_active){ + if(autoReportFeatures.Fans()){ gcode_M123(); } #endif //AUTO_REPORT_ALL or AUTO_REPORT_FANS and (FANCHECK and TACH_0 or TACH_1) #if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_POSITION) - if(auto_report_position_active){ + if(autoReportFeatures.Pos()){ gcode_M114(); } #endif //AUTO_REPORT_POSITION or AUTO_REPORT_FANS or AUTO_REPORT_POSITION - auto_report_timer.start(); + autoReportFeatures.TimerStart(); } } #endif //AUTO_REPORT_ALL @@ -6457,7 +6514,7 @@ Sigma_Exit: #### Parameters - `S` - Set autoreporting interval in seconds. 0 to disable. Maximum: 255 - - `C` - Activate auto-report function. Default is temperature. + - `C` - Activate auto-report function (bit mask). Default is temperature. bit 0 = Auto-report temperatures bit 1 = Auto-report fans @@ -6470,49 +6527,17 @@ Sigma_Exit: */ //!@todo update RepRap Gcode wiki //!@todo Should be temperature always? Octoprint doesn't switch to M105 if M155 timer is set - - union { - struct - { - uint8_t ar_temp_active : 1; //Temperature flag - uint8_t ar_fans_active : 1; //Fans flag - uint8_t ar_pos_active : 1; //Position flag - uint8_t ar_4_active : 1; //Unused - uint8_t ar_5_active : 1; //Unused - uint8_t ar_6_active : 1; //Unused - uint8_t ar_7_active : 1; //Unused - } __attribute__((packed)) bits; - uint8_t byte; - } arFunctionsActive; case 155: { - if (code_seen('S')) - { - auto_report_period = code_value_uint8(); - if (auto_report_period != 0){ - auto_report_timer.start(); + if (code_seen('S')){ + autoReportFeatures.SetPeriod( code_value_uint8() ); } - else{ - auto_report_timer.stop(); + if (code_seen('C')){ + autoReportFeatures.SetMask(code_value()); + //arFunctionsActive.bits.ar_temp_active = 1; //auto-report temperatures always on + } else{ + autoReportFeatures.SetMask(1); } - } - if (code_seen('C')) - { - arFunctionsActive.byte = code_value(); - //arFunctionsActive.bits.ar_temp_active = 1; //auto-report temperatures always on - } - else{ - arFunctionsActive.byte = 1; - } -#if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_TEMPERATURES) - auto_report_temp_active = arFunctionsActive.bits.ar_temp_active; -#endif //AUTO_REPORT_ALL or AUTO_REPORT_TEMPERATURES -#if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_FANS) - auto_report_fans_active = arFunctionsActive.bits.ar_fans_active; -#endif //AUTO_REPORT_ALL or AUTO_REPORT_FANS -#if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_POSITION) - auto_report_position_active = arFunctionsActive.bits.ar_pos_active; - #endif //AUTO_REPORT_ALL or AUTO_REPORT_POSITION } break; #endif //AUTO_REPORT_ALL or AUTO_REPORT_TEMPERATURES or AUTO_REPORT_FANS or AUTO_REPORT_POSITION diff --git a/Firmware/Timer.h b/Firmware/Timer.h index e2e84eff9..599371b4e 100644 --- a/Firmware/Timer.h +++ b/Firmware/Timer.h @@ -20,10 +20,10 @@ public: Timer(); void start(); void stop(){m_isRunning = false;} - bool running(){return m_isRunning;} + bool running()const {return m_isRunning;} bool expired(T msPeriod); protected: - T started(){return m_started;} + T started()const {return m_started;} private: bool m_isRunning; T m_started; From ede3f3405183d284f618bc045b0d35573d9761e3 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Fri, 22 Jan 2021 10:40:29 +0100 Subject: [PATCH 4/5] Documentation --- Firmware/Marlin_main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f96139654..25cd5ebca 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -6534,9 +6534,8 @@ Sigma_Exit: } if (code_seen('C')){ autoReportFeatures.SetMask(code_value()); - //arFunctionsActive.bits.ar_temp_active = 1; //auto-report temperatures always on } else{ - autoReportFeatures.SetMask(1); + autoReportFeatures.SetMask(1); //Backwards compability to host systems like Octoprint to send only temp if paramerter `C`isn't used } } break; From 008c6a2590312a986934cfcb04af8e7dde312945 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Fri, 22 Jan 2021 12:26:29 +0100 Subject: [PATCH 5/5] Remove defines --- Firmware/Configuration_adv.h | 19 +---------- Firmware/Marlin_main.cpp | 62 +++++++++++------------------------- 2 files changed, 20 insertions(+), 61 deletions(-) diff --git a/Firmware/Configuration_adv.h b/Firmware/Configuration_adv.h index 9f2ee64a4..7a9a4929a 100644 --- a/Firmware/Configuration_adv.h +++ b/Firmware/Configuration_adv.h @@ -74,24 +74,7 @@ * bit 6 = free * bit 7 = free */ -#define AUTO_REPORT_ALL - -#ifndef AUTO_REPORT_ALL -/** - * Auto-report temperatures with M155 S [C1] - */ -#define AUTO_REPORT_TEMPERATURES - -/** - * Auto-report fans with M155 S C2 - */ -#define AUTO_REPORT_FANS - -/** - * Auto-report position with M155 S C4 - */ -#define AUTO_REPORT_POSITION -#endif //NOT AUTO_REPORT_ALL +#define AUTO_REPORT //=========================================================================== //=============================Mechanical Settings=========================== diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 25cd5ebca..164804389 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -403,24 +403,15 @@ class AutoReportFeatures { } __attribute__((packed)) bits; uint8_t byte; } arFunctionsActive; - uint8_t auto_report_period; //Also used for AUTO_REPORT_TEMPERATURES + uint8_t auto_report_period; public: - LongTimer auto_report_timer; //Also used for AUTO_REPORT_TEMPERATURES + LongTimer auto_report_timer; AutoReportFeatures():auto_report_period(0){ -#if defined(AUTO_REPORT_ALL) +#if defined(AUTO_REPORT) arFunctionsActive.byte = 0xff; #else arFunctionsActive.byte = 0; -# if defined(AUTO_REPORT_TEMPERATURES) - arFunctionsActive.bits.temp = 1; -# endif -# if defined(AUTO_REPORT_FANS) - arFunctionsActive.bits.fans = 1; -# endif -# if defined(AUTO_REPORT_POSITION) - arFunctionsActive.bits.pos = 1; -# endif -#endif +#endif //AUTO_REPORT } inline bool Temp()const { return arFunctionsActive.bits.temp != 0; } @@ -452,18 +443,6 @@ public: AutoReportFeatures autoReportFeatures; -//#if defined(AUTO_REPORT_TEMPERATURES) || defined(AUTO_REPORT_ALL) -//static bool auto_report_temp_active = false; -//#endif //AUTO_REPORT_TEMPERATURES - -//#if defined(AUTO_REPORT_FANS) || defined(AUTO_REPORT_ALL) -//static bool auto_report_fans_active = false; -//#endif //AUTO_REPORT_FANS - -//#if defined(AUTO_REPORT_POSITION) || defined(AUTO_REPORT_ALL) -//static bool auto_report_position_active = false; -//#endif //AUTO_REPORT_POSITION - //=========================================================================== //=============================Routines====================================== //=========================================================================== @@ -1800,28 +1779,25 @@ void host_keepalive() { if (farm_mode) return; long ms = _millis(); -#if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_TEMPERATURES) || defined(AUTO_REPORT_FANS) || defined(AUTO_REPORT_POSITION) - if ( autoReportFeatures.TimerRunning()) +#if defined(AUTO_REPORT) { if (autoReportFeatures.TimerExpired()) { if(autoReportFeatures.Temp()){ gcode_M105(active_extruder); } -#if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_FANS) && (defined(FANCHECK) && (((defined(TACH_0) && (TACH_0 >-1)) || (defined(TACH_1) && (TACH_1 > -1))))) - if(autoReportFeatures.Fans()){ - gcode_M123(); - } -#endif //AUTO_REPORT_ALL or AUTO_REPORT_FANS and (FANCHECK and TACH_0 or TACH_1) -#if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_POSITION) if(autoReportFeatures.Pos()){ gcode_M114(); } -#endif //AUTO_REPORT_POSITION or AUTO_REPORT_FANS or AUTO_REPORT_POSITION - autoReportFeatures.TimerStart(); + #if defined(AUTO_REPORT) && (defined(FANCHECK) && (((defined(TACH_0) && (TACH_0 >-1)) || (defined(TACH_1) && (TACH_1 > -1))))) + if(autoReportFeatures.Fans()){ + gcode_M123(); + } +#endif //AUTO_REPORT and (FANCHECK and TACH_0 or TACH_1) + autoReportFeatures.TimerStart(); } } -#endif //AUTO_REPORT_ALL +#endif //AUTO_REPORT if (host_keepalive_interval && busy_state != NOT_BUSY) { @@ -3606,14 +3582,14 @@ static void cap_line(const char* name, bool ena = false) { static void extended_capabilities_report() { // AUTOREPORT_TEMP (M155) - cap_line(PSTR("AUTOREPORT_TEMP"), (ENABLED(AUTO_REPORT_TEMPERATURES)) || ENABLED(AUTO_REPORT_ALL)); + cap_line(PSTR("AUTOREPORT_TEMP"), ENABLED(AUTO_REPORT)); #if (defined(FANCHECK) && (((defined(TACH_0) && (TACH_0 >-1)) || (defined(TACH_1) && (TACH_1 > -1))))) // AUTOREPORT_FANS (M123) - cap_line(PSTR("AUTOREPORT_FANS"), (ENABLED(AUTO_REPORT_FANS) || ENABLED(AUTO_REPORT_ALL))); + cap_line(PSTR("AUTOREPORT_FANS"), ENABLED(AUTO_REPORT)); #endif //FANCHECK and TACH_0 or TACH_1 // AUTOREPORT_POSITION (M114) - cap_line(PSTR("AUTOREPORT_POSITION"), (ENABLED(AUTO_REPORT_POSITION) || ENABLED(AUTO_REPORT_ALL))); - //@todo + cap_line(PSTR("AUTOREPORT_POSITION"), ENABLED(AUTO_REPORT)); + //@todo Update RepRap cap } #endif //EXTENDED_CAPABILITIES_REPORT @@ -6504,7 +6480,7 @@ Sigma_Exit: break; } -#if defined(AUTO_REPORT_ALL) || defined(AUTO_REPORT_TEMPERATURES) || defined(AUTO_REPORT_FANS) || defined(AUTO_REPORT_POSITION) +#if defined(AUTO_REPORT) /*! ### M155 - Automatically send status M155: Automatically send temperatures #### Usage @@ -6535,11 +6511,11 @@ Sigma_Exit: if (code_seen('C')){ autoReportFeatures.SetMask(code_value()); } else{ - autoReportFeatures.SetMask(1); //Backwards compability to host systems like Octoprint to send only temp if paramerter `C`isn't used + autoReportFeatures.SetMask(1); //Backwards compability to host systems like Octoprint to send only temp if paramerter `C`isn't used. } } break; -#endif //AUTO_REPORT_ALL or AUTO_REPORT_TEMPERATURES or AUTO_REPORT_FANS or AUTO_REPORT_POSITION +#endif //AUTO_REPORT /*! ### M109 - Wait for extruder temperature M109: Set Extruder Temperature and Wait