Merge pull request #2832 from leptun/MK3_AUTO_REPORT_TEMPERATURES

Mk3 auto report temperatures
This commit is contained in:
DRracer 2020-09-23 08:51:26 +02:00 committed by GitHub
commit 95e2e2f69c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 146 additions and 86 deletions

View File

@ -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<seconds>
*/
#define AUTO_REPORT_TEMPERATURES

View File

@ -389,6 +389,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======================================
//===========================================================================
@ -398,6 +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_M105(uint8_t extruder);
static void temp_compensation_start();
static void temp_compensation_apply();
@ -1723,6 +1729,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_M105(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) {
@ -2526,6 +2544,96 @@ void force_high_power_mode(bool start_high_power_section) {
}
#endif //TMC2130
void gcode_M105(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
@ -3408,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
@ -3504,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<millimeters>- set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).
@ -6287,96 +6397,41 @@ 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_M105(extruder);
return;
break;
}
#ifdef AUTO_REPORT_TEMPERATURES
/*!
### M155 - Automatically send temperatures <a href="https://reprap.org/wiki/G-code#M155:_Automatically_send_temperatures">M155: Automatically send temperatures</a>
#### Usage
M155 [ S ]
#### Parameters
- `S` - Set temperature autoreporting interval in seconds. 0 to disable. Maximum: 255
*/
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 <a href="https://reprap.org/wiki/G-code#M109:_Set_Extruder_Temperature_and_Wait">M109: Set Extruder Temperature and Wait</a>
#### Usage