From d8fbd46cd28910f17e5c7c3947394a61c2c7ff50 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Thu, 23 Jul 2020 17:28:25 +0300 Subject: [PATCH 1/4] M155 --- Firmware/Configuration_adv.h | 5 + Firmware/Marlin_main.cpp | 214 +++++++++++++++++++++-------------- 2 files changed, 133 insertions(+), 86 deletions(-) diff --git a/Firmware/Configuration_adv.h b/Firmware/Configuration_adv.h index 5386c281..18e7a11b 100644 --- a/Firmware/Configuration_adv.h +++ b/Firmware/Configuration_adv.h @@ -62,6 +62,11 @@ // before setting a PWM value. (Does not work with software PWM for fan on Sanguinololu) #define FAN_KICKSTART_TIME 800 +/** + * Auto-report temperatures with M155 S + */ +#define AUTO_REPORT_TEMPERATURES + diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 8dbc0d84..53b04eee 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -393,6 +393,11 @@ 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; +#endif //AUTO_REPORT_TEMPERATURES + //=========================================================================== //=============================Routines====================================== //=========================================================================== @@ -402,6 +407,7 @@ static bool setTargetedHotend(int code, uint8_t &extruder); static void print_time_remaining_init(); static void wait_for_heater(long codenum, uint8_t extruder); static void gcode_G28(bool home_x_axis, bool home_y_axis, bool home_z_axis); +static void gcode_M115(uint8_t extruder); static void temp_compensation_start(); static void temp_compensation_apply(); @@ -1720,6 +1726,18 @@ void host_keepalive() { #endif //HOST_KEEPALIVE_FEATURE if (farm_mode) return; long ms = _millis(); + +#ifdef AUTO_REPORT_TEMPERATURES + if (auto_report_temp_timer.running()) + { + if (auto_report_temp_timer.expired(auto_report_temp_period * 1000ul)) + { + gcode_M115(active_extruder); + auto_report_temp_timer.start(); + } + } +#endif //AUTO_REPORT_TEMPERATURES + if (host_keepalive_interval && busy_state != NOT_BUSY) { if ((ms - prev_busy_signal_ms) < (long)(1000L * host_keepalive_interval)) return; switch (busy_state) { @@ -2523,6 +2541,96 @@ void force_high_power_mode(bool start_high_power_section) { } #endif //TMC2130 +void gcode_M115(uint8_t extruder) +{ +#if defined(TEMP_0_PIN) && TEMP_0_PIN > -1 + SERIAL_PROTOCOLPGM("T:"); + SERIAL_PROTOCOL_F(degHotend(extruder),1); + SERIAL_PROTOCOLPGM(" /"); + SERIAL_PROTOCOL_F(degTargetHotend(extruder),1); +#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 + SERIAL_PROTOCOLPGM(" B:"); + SERIAL_PROTOCOL_F(degBed(),1); + SERIAL_PROTOCOLPGM(" /"); + SERIAL_PROTOCOL_F(degTargetBed(),1); +#endif //TEMP_BED_PIN + for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) { + SERIAL_PROTOCOLPGM(" T"); + SERIAL_PROTOCOL(cur_extruder); + SERIAL_PROTOCOL(':'); + SERIAL_PROTOCOL_F(degHotend(cur_extruder),1); + SERIAL_PROTOCOLPGM(" /"); + SERIAL_PROTOCOL_F(degTargetHotend(cur_extruder),1); + } +#else + SERIAL_ERROR_START; + SERIAL_ERRORLNRPGM(_i("No thermistors - no temperature"));////MSG_ERR_NO_THERMISTORS +#endif + + SERIAL_PROTOCOLPGM(" @:"); +#ifdef EXTRUDER_WATTS + SERIAL_PROTOCOL((EXTRUDER_WATTS * getHeaterPower(tmp_extruder))/127); + SERIAL_PROTOCOLPGM("W"); +#else + SERIAL_PROTOCOL(getHeaterPower(extruder)); +#endif + + SERIAL_PROTOCOLPGM(" B@:"); +#ifdef BED_WATTS + SERIAL_PROTOCOL((BED_WATTS * getHeaterPower(-1))/127); + SERIAL_PROTOCOLPGM("W"); +#else + SERIAL_PROTOCOL(getHeaterPower(-1)); +#endif + +#ifdef PINDA_THERMISTOR + SERIAL_PROTOCOLPGM(" P:"); + SERIAL_PROTOCOL_F(current_temperature_pinda,1); +#endif //PINDA_THERMISTOR + +#ifdef AMBIENT_THERMISTOR + SERIAL_PROTOCOLPGM(" A:"); + SERIAL_PROTOCOL_F(current_temperature_ambient,1); +#endif //AMBIENT_THERMISTOR + + +#ifdef SHOW_TEMP_ADC_VALUES + { + float raw = 0.0; +#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 + SERIAL_PROTOCOLPGM(" ADC B:"); + SERIAL_PROTOCOL_F(degBed(),1); + SERIAL_PROTOCOLPGM("C->"); + raw = rawBedTemp(); + SERIAL_PROTOCOL_F(raw/OVERSAMPLENR,5); + SERIAL_PROTOCOLPGM(" Rb->"); + SERIAL_PROTOCOL_F(100 * (1 + (PtA * (raw/OVERSAMPLENR)) + (PtB * sq((raw/OVERSAMPLENR)))), 5); + SERIAL_PROTOCOLPGM(" Rxb->"); + SERIAL_PROTOCOL_F(raw, 5); +#endif + for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) { + SERIAL_PROTOCOLPGM(" T"); + SERIAL_PROTOCOL(cur_extruder); + SERIAL_PROTOCOLPGM(":"); + SERIAL_PROTOCOL_F(degHotend(cur_extruder),1); + SERIAL_PROTOCOLPGM("C->"); + raw = rawHotendTemp(cur_extruder); + SERIAL_PROTOCOL_F(raw/OVERSAMPLENR,5); + SERIAL_PROTOCOLPGM(" Rt"); + SERIAL_PROTOCOL(cur_extruder); + SERIAL_PROTOCOLPGM("->"); + SERIAL_PROTOCOL_F(100 * (1 + (PtA * (raw/OVERSAMPLENR)) + (PtB * sq((raw/OVERSAMPLENR)))), 5); + SERIAL_PROTOCOLPGM(" Rx"); + SERIAL_PROTOCOL(cur_extruder); + SERIAL_PROTOCOLPGM("->"); + SERIAL_PROTOCOL_F(raw, 5); + } + } +#endif + SERIAL_PROTOCOLLN(""); + KEEPALIVE_STATE(NOT_BUSY); +} + #ifdef TMC2130 static void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, long home_y_value, bool home_z_axis, long home_z_value, bool calib, bool without_mbl) #else @@ -6280,96 +6388,30 @@ Sigma_Exit: uint8_t extruder; if(setTargetedHotend(105, extruder)){ break; - } - #if defined(TEMP_0_PIN) && TEMP_0_PIN > -1 - SERIAL_PROTOCOLPGM("ok T:"); - SERIAL_PROTOCOL_F(degHotend(extruder),1); - SERIAL_PROTOCOLPGM(" /"); - SERIAL_PROTOCOL_F(degTargetHotend(extruder),1); - #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 - SERIAL_PROTOCOLPGM(" B:"); - SERIAL_PROTOCOL_F(degBed(),1); - SERIAL_PROTOCOLPGM(" /"); - SERIAL_PROTOCOL_F(degTargetBed(),1); - #endif //TEMP_BED_PIN - for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) { - SERIAL_PROTOCOLPGM(" T"); - SERIAL_PROTOCOL(cur_extruder); - SERIAL_PROTOCOL(':'); - SERIAL_PROTOCOL_F(degHotend(cur_extruder),1); - SERIAL_PROTOCOLPGM(" /"); - SERIAL_PROTOCOL_F(degTargetHotend(cur_extruder),1); - } - #else - SERIAL_ERROR_START; - SERIAL_ERRORLNRPGM(_i("No thermistors - no temperature"));////MSG_ERR_NO_THERMISTORS - #endif - - SERIAL_PROTOCOLPGM(" @:"); - #ifdef EXTRUDER_WATTS - SERIAL_PROTOCOL((EXTRUDER_WATTS * getHeaterPower(tmp_extruder))/127); - SERIAL_PROTOCOLPGM("W"); - #else - SERIAL_PROTOCOL(getHeaterPower(extruder)); - #endif - - SERIAL_PROTOCOLPGM(" B@:"); - #ifdef BED_WATTS - SERIAL_PROTOCOL((BED_WATTS * getHeaterPower(-1))/127); - SERIAL_PROTOCOLPGM("W"); - #else - SERIAL_PROTOCOL(getHeaterPower(-1)); - #endif - -#ifdef PINDA_THERMISTOR - SERIAL_PROTOCOLPGM(" P:"); - SERIAL_PROTOCOL_F(current_temperature_pinda,1); -#endif //PINDA_THERMISTOR - -#ifdef AMBIENT_THERMISTOR - SERIAL_PROTOCOLPGM(" A:"); - SERIAL_PROTOCOL_F(current_temperature_ambient,1); -#endif //AMBIENT_THERMISTOR - - - #ifdef SHOW_TEMP_ADC_VALUES - {float raw = 0.0; - - #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 - SERIAL_PROTOCOLPGM(" ADC B:"); - SERIAL_PROTOCOL_F(degBed(),1); - SERIAL_PROTOCOLPGM("C->"); - raw = rawBedTemp(); - SERIAL_PROTOCOL_F(raw/OVERSAMPLENR,5); - SERIAL_PROTOCOLPGM(" Rb->"); - SERIAL_PROTOCOL_F(100 * (1 + (PtA * (raw/OVERSAMPLENR)) + (PtB * sq((raw/OVERSAMPLENR)))), 5); - SERIAL_PROTOCOLPGM(" Rxb->"); - SERIAL_PROTOCOL_F(raw, 5); - #endif - for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) { - SERIAL_PROTOCOLPGM(" T"); - SERIAL_PROTOCOL(cur_extruder); - SERIAL_PROTOCOLPGM(":"); - SERIAL_PROTOCOL_F(degHotend(cur_extruder),1); - SERIAL_PROTOCOLPGM("C->"); - raw = rawHotendTemp(cur_extruder); - SERIAL_PROTOCOL_F(raw/OVERSAMPLENR,5); - SERIAL_PROTOCOLPGM(" Rt"); - SERIAL_PROTOCOL(cur_extruder); - SERIAL_PROTOCOLPGM("->"); - SERIAL_PROTOCOL_F(100 * (1 + (PtA * (raw/OVERSAMPLENR)) + (PtB * sq((raw/OVERSAMPLENR)))), 5); - SERIAL_PROTOCOLPGM(" Rx"); - SERIAL_PROTOCOL(cur_extruder); - SERIAL_PROTOCOLPGM("->"); - SERIAL_PROTOCOL_F(raw, 5); - }} - #endif - SERIAL_PROTOCOLLN(""); - KEEPALIVE_STATE(NOT_BUSY); + } + + SERIAL_PROTOCOLPGM("ok "); + gcode_M115(extruder); + return; break; } +#ifdef AUTO_REPORT_TEMPERATURES + 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(); + } + } + break; +#endif //AUTO_REPORT_TEMPERATURES + /*! ### M109 - Wait for extruder temperature M109: Set Extruder Temperature and Wait #### Usage From e2ef5af40e6e7f73ddb750f672282d13d085d416 Mon Sep 17 00:00:00 2001 From: Voinea Dragos Date: Tue, 15 Sep 2020 14:21:09 +0300 Subject: [PATCH 2/4] Add capability line --- Firmware/Marlin_main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f304c18b..812cc383 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3516,6 +3516,7 @@ static void cap_line(const char* name, bool ena = false) { static void extended_capabilities_report() { + cap_line(PSTR("AUTOREPORT_TEMP"), ENABLED(AUTO_REPORT_TEMPERATURES)); //@todo } #endif //EXTENDED_CAPABILITIES_REPORT From c0fced2f3cb7457fae78e1920d2ab373c5f16f4f Mon Sep 17 00:00:00 2001 From: Voinea Dragos Date: Tue, 15 Sep 2020 14:21:21 +0300 Subject: [PATCH 3/4] Fix typo --- Firmware/Marlin_main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 812cc383..f030f689 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -403,7 +403,7 @@ static bool setTargetedHotend(int code, uint8_t &extruder); static void print_time_remaining_init(); static void wait_for_heater(long codenum, uint8_t extruder); static void gcode_G28(bool home_x_axis, bool home_y_axis, bool home_z_axis); -static void gcode_M115(uint8_t extruder); +static void gcode_M105(uint8_t extruder); static void temp_compensation_start(); static void temp_compensation_apply(); @@ -1735,7 +1735,7 @@ void host_keepalive() { { if (auto_report_temp_timer.expired(auto_report_temp_period * 1000ul)) { - gcode_M115(active_extruder); + gcode_M105(active_extruder); auto_report_temp_timer.start(); } } @@ -2544,7 +2544,7 @@ void force_high_power_mode(bool start_high_power_section) { } #endif //TMC2130 -void gcode_M115(uint8_t extruder) +void gcode_M105(uint8_t extruder) { #if defined(TEMP_0_PIN) && TEMP_0_PIN > -1 SERIAL_PROTOCOLPGM("T:"); @@ -6399,7 +6399,7 @@ Sigma_Exit: } SERIAL_PROTOCOLPGM("ok "); - gcode_M115(extruder); + gcode_M105(extruder); return; break; From d9fa44c142db83014c6186483b3d76578f1f10b1 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Wed, 23 Sep 2020 09:14:35 +0300 Subject: [PATCH 4/4] Document M155 command --- Firmware/Marlin_main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f030f689..dd6dd78b 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3613,6 +3613,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 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). @@ -6406,6 +6407,17 @@ Sigma_Exit: } #ifdef AUTO_REPORT_TEMPERATURES + /*! + ### M155 - Automatically send temperatures M155: Automatically send temperatures + #### Usage + + M155 [ S ] + + #### Parameters + + - `S` - Set temperature autoreporting interval in seconds. 0 to disable. Maximum: 255 + + */ case 155: { if (code_seen('S'))