From 5bdb0b567d4b15370d38d5ed519d4e0b4b25fb26 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 26 Apr 2017 02:43:11 -0500 Subject: [PATCH 1/3] Cosmetic patches --- Marlin/Marlin_main.cpp | 16 ++++++++-------- Marlin/printcounter.cpp | 3 ++- Marlin/printcounter.h | 4 ++-- Marlin/temperature.cpp | 6 +++--- Marlin/ultralcd.cpp | 2 +- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 4b0eb703b..1d9b92bef 100755 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -616,12 +616,12 @@ static uint8_t target_extruder; float cartes[XYZ] = { 0 }; #if ENABLED(FILAMENT_WIDTH_SENSOR) - bool filament_sensor = false; //M405 turns on filament_sensor control, M406 turns it off - float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA, // Nominal filament width. Change with M404 + bool filament_sensor = false; // M405 turns on filament sensor control. M406 turns it off. + float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA, // Nominal filament width. Change with M404. filament_width_meas = DEFAULT_MEASURED_FILAMENT_DIA; // Measured filament diameter - int8_t measurement_delay[MAX_MEASUREMENT_DELAY + 1]; // Ring buffer to delayed measurement. Store extruder factor after subtracting 100 - int filwidth_delay_index[2] = { 0, -1 }; // Indexes into ring buffer - int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting + int8_t measurement_delay[MAX_MEASUREMENT_DELAY + 1]; // Ring buffer to delayed measurement. Store extruder factor after subtracting 100 + int filwidth_delay_index[2] = { 0, -1 }; // Indexes into ring buffer + int meas_delay_cm = MEASUREMENT_DELAY_CM; // Distance delay setting #endif #if ENABLED(FILAMENT_RUNOUT_SENSOR) @@ -8220,10 +8220,10 @@ inline void gcode_M400() { stepper.synchronize(); } NOMORE(meas_delay_cm, MAX_MEASUREMENT_DELAY); if (filwidth_delay_index[1] == -1) { // Initialize the ring buffer if not done since startup - int temp_ratio = thermalManager.widthFil_to_size_ratio(); + const int temp_ratio = thermalManager.widthFil_to_size_ratio() - 100; // -100 to scale within a signed byte for (uint8_t i = 0; i < COUNT(measurement_delay); ++i) - measurement_delay[i] = temp_ratio - 100; // Subtract 100 to scale within a signed byte + measurement_delay[i] = temp_ratio; filwidth_delay_index[0] = filwidth_delay_index[1] = 0; } @@ -10279,7 +10279,7 @@ void process_next_command() { case 407: // M407: Display measured filament diameter gcode_M407(); break; - #endif // ENABLED(FILAMENT_WIDTH_SENSOR) + #endif // FILAMENT_WIDTH_SENSOR #if PLANNER_LEVELING case 420: // M420: Enable/Disable Bed Leveling diff --git a/Marlin/printcounter.cpp b/Marlin/printcounter.cpp index 469a7332d..09f31f783 100644 --- a/Marlin/printcounter.cpp +++ b/Marlin/printcounter.cpp @@ -188,7 +188,8 @@ bool PrintCounter::start() { } return true; } - else return false; + + return false; } // @Override diff --git a/Marlin/printcounter.h b/Marlin/printcounter.h index ffa580800..0eeded9d5 100644 --- a/Marlin/printcounter.h +++ b/Marlin/printcounter.h @@ -32,12 +32,12 @@ // Print debug messages with M111 S2 //#define DEBUG_PRINTCOUNTER -struct printStatistics { // 13 bytes +struct printStatistics { // 16 bytes (20 with real doubles) //const uint8_t magic; // Magic header, it will always be 0x16 uint16_t totalPrints; // Number of prints uint16_t finishedPrints; // Number of complete prints uint32_t printTime; // Accumulated printing time - uint32_t longestPrint; // Longest successfull print job + uint32_t longestPrint; // Longest successful print job double filamentUsed; // Accumulated filament consumed in mm }; diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index eb61f6602..245739da1 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -774,7 +774,7 @@ void Temperature::manage_heater() { NOLESS(vm, 0.01); volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vm; } - #endif //FILAMENT_WIDTH_SENSOR + #endif // FILAMENT_WIDTH_SENSOR #if DISABLED(PIDTEMPBED) if (PENDING(ms, next_bed_check_ms)) return; @@ -961,8 +961,8 @@ void Temperature::updateTemperaturesFromRawValues() { */ void Temperature::init() { - #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1)) - //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector + #if MB(RUMBA) && (TEMP_SENSOR_0 == -1 || TEMP_SENSOR_1 == -1 || TEMP_SENSOR_2 == -1 || TEMP_SENSOR_BED == -1) + // Disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector MCUCR = _BV(JTD); MCUCR = _BV(JTD); #endif diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 3031d56f8..122b8b3bd 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -2725,7 +2725,7 @@ void kill_screen(const char* lcd_msg) { START_SCREEN(); // 12345678901234567890 STATIC_ITEM(MSG_INFO_PRINT_COUNT ": ", false, false, itostr3left(stats.totalPrints)); // Print Count: 999 - STATIC_ITEM(MSG_INFO_COMPLETED_PRINTS": ", false, false, itostr3left(stats.finishedPrints)); // Completed : 666 + STATIC_ITEM(MSG_INFO_COMPLETED_PRINTS": ", false, false, itostr3left(stats.finishedPrints)); // Completed : 666 duration_t elapsed = stats.printTime; elapsed.toString(buffer); From 096b927102b694d6f962d43a68b0dcf02a1f67a0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 26 Apr 2017 02:52:51 -0500 Subject: [PATCH 2/3] Minor optimization of FILAMENT_WIDTH_SENSOR --- Marlin/temperature.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 245739da1..03b39de03 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -766,13 +766,12 @@ void Temperature::manage_heater() { if (filament_sensor) { meas_shift_index = filwidth_delay_index[0] - meas_delay_cm; if (meas_shift_index < 0) meas_shift_index += MAX_MEASUREMENT_DELAY + 1; //loop around buffer if needed + meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY); // Get the delayed info and add 100 to reconstitute to a percent of // the nominal filament diameter then square it to get an area - meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY); - float vm = pow((measurement_delay[meas_shift_index] + 100.0) * 0.01, 2); - NOLESS(vm, 0.01); - volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vm; + const float vmroot = measurement_delay[meas_shift_index] * 0.01 + 1.0; + volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vmroot <= 0.1 ? 0.01 : sq(vmroot); } #endif // FILAMENT_WIDTH_SENSOR From adb8e6859216b01f2cab1261ac0a24f7de95acf9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 26 Apr 2017 05:36:37 -0500 Subject: [PATCH 3/3] Fix stuck "Print Aborted" LCD message Fixes #6393 --- Marlin/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 122b8b3bd..608dab5c6 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -705,7 +705,7 @@ void kill_screen(const char* lcd_msg) { thermalManager.autotempShutdown(); #endif wait_for_heatup = false; - lcd_setstatuspgm(PSTR(MSG_PRINT_ABORTED), true); + LCD_MESSAGEPGM(MSG_PRINT_ABORTED); } #endif // SDSUPPORT