From 37933c8a857b5633beb9fbed69c0e7609cc23465 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Mon, 16 Jul 2012 20:00:16 +0200 Subject: [PATCH] Fix temperature printing. Remove the assumption there's always an extruder temperature sensor and make reading on single sensors (e.g. M105 P2) more usable. Apparently works very well, but *sigh* yet another 100 bytes of binary size. --- gcode_process.c | 2 +- temp.c | 38 +++++++++++++++++++++----------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/gcode_process.c b/gcode_process.c index 76d6cab..d1c8c62 100644 --- a/gcode_process.c +++ b/gcode_process.c @@ -500,7 +500,7 @@ void process_gcode_command() { queue_wait(); #endif if ( ! next_target.seen_P) - next_target.P = HEATER_EXTRUDER; + next_target.P = TEMP_SENSOR_none; temp_print(next_target.P); break; diff --git a/temp.c b/temp.c index 8e3abd8..d91d7f6 100644 --- a/temp.c +++ b/temp.c @@ -358,26 +358,30 @@ uint8_t temp_all_zero() { // extruder doesn't have sersendf_P #ifndef EXTRUDER +static void single_temp_print(temp_sensor_t index) { + uint8_t c = (temp_sensors_runtime[index].last_read_temp & 3) * 25; + sersendf_P(PSTR("%u.%u"), temp_sensors_runtime[index].last_read_temp >> 2, c); +} + /// send temperatures to host /// \param index sensor value to send void temp_print(temp_sensor_t index) { - uint8_t c = 0; - - if (index >= NUM_TEMP_SENSORS) - return; - - c = (temp_sensors_runtime[index].last_read_temp & 3) * 25; - - #if REPRAP_HOST_COMPATIBILITY >= 20110509 - sersendf_P(PSTR("T:%u.%u"), temp_sensors_runtime[index].last_read_temp >> 2, c); - #else - sersendf_P(PSTR("\nT:%u.%u"), temp_sensors_runtime[index].last_read_temp >> 2, c); - #endif - #ifdef HEATER_BED - c = (temp_sensors_runtime[HEATER_BED].last_read_temp & 3) * 25; - - sersendf_P(PSTR(" B:%u.%u"), temp_sensors_runtime[HEATER_BED].last_read_temp >> 2 , c); - #endif + if (index == TEMP_SENSOR_none) { // standard behaviour + #ifdef HEATER_EXTRUDER + sersendf_P(PSTR("T:")); + single_temp_print(HEATER_EXTRUDER); + #endif + #ifdef HEATER_BED + sersendf_P(PSTR(" B:")); + single_temp_print(HEATER_BED); + #endif + } + else { + if (index >= NUM_TEMP_SENSORS) + return; + sersendf_P(PSTR("T[%su]:"), index); + single_temp_print(index); + } } #endif