diff --git a/Marlin/src/feature/filwidth.cpp b/Marlin/src/feature/filwidth.cpp index e43a9ccd7d..eca024f7d4 100644 --- a/Marlin/src/feature/filwidth.cpp +++ b/Marlin/src/feature/filwidth.cpp @@ -29,8 +29,8 @@ bool filament_sensor = false; // M405/M406 turns filament sensor control ON/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 -uint8_t meas_delay_cm = MEASUREMENT_DELAY_CM, // Distance delay setting - measurement_delay[MAX_MEASUREMENT_DELAY + 1]; // Ring buffer to delayed measurement. Store extruder factor after subtracting 100 -int8_t filwidth_delay_index[2] = { 0, -1 }; // Indexes into ring buffer +uint8_t 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 + filwidth_delay_index[2] = { 0, -1 }; // Indexes into ring buffer #endif // FILAMENT_WIDTH_SENSOR diff --git a/Marlin/src/feature/filwidth.h b/Marlin/src/feature/filwidth.h index 4368059390..1f0dfc6f04 100644 --- a/Marlin/src/feature/filwidth.h +++ b/Marlin/src/feature/filwidth.h @@ -25,11 +25,11 @@ #include "../inc/MarlinConfig.h" -extern bool filament_sensor; // M405/M406 turns filament sensor control ON/OFF. -extern float filament_width_nominal, // Nominal filament width. Change with M404. - filament_width_meas; // Measured filament diameter -extern uint8_t meas_delay_cm, // Distance delay setting - measurement_delay[MAX_MEASUREMENT_DELAY + 1]; // Ring buffer to delayed measurement. Store extruder factor after subtracting 100 -extern int8_t filwidth_delay_index[2]; // Indexes into ring buffer +extern bool filament_sensor; // M405/M406 turns filament sensor control ON/OFF. +extern float filament_width_nominal, // Nominal filament width. Change with M404. + filament_width_meas; // Measured filament diameter +extern uint8_t meas_delay_cm; // Distance delay setting +extern int8_t measurement_delay[MAX_MEASUREMENT_DELAY + 1], // Ring buffer to delayed measurement. Store extruder factor after subtracting 100 + filwidth_delay_index[2]; // Indexes into ring buffer #endif // __FILWIDTH_H__ diff --git a/Marlin/src/gcode/feature/filwidth/M404-M407.cpp b/Marlin/src/gcode/feature/filwidth/M404-M407.cpp index 66e47397ca..a096feef17 100644 --- a/Marlin/src/gcode/feature/filwidth/M404-M407.cpp +++ b/Marlin/src/gcode/feature/filwidth/M404-M407.cpp @@ -56,7 +56,7 @@ void GcodeSuite::M405() { } if (filwidth_delay_index[1] == -1) { // Initialize the ring buffer if not done since startup - const uint8_t temp_ratio = thermalManager.widthFil_to_size_ratio(); + const int8_t temp_ratio = thermalManager.widthFil_to_size_ratio(); for (uint8_t i = 0; i < COUNT(measurement_delay); ++i) measurement_delay[i] = temp_ratio; diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 1155d1d58c..85c0f2010a 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1092,7 +1092,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const // If the index has changed (must have gone forward)... if (filwidth_delay_index[0] != filwidth_delay_index[1]) { filwidth_e_count = 0; // Reset the E movement counter - const uint8_t meas_sample = thermalManager.widthFil_to_size_ratio(); + const int8_t meas_sample = thermalManager.widthFil_to_size_ratio(); do { filwidth_delay_index[1] = (filwidth_delay_index[1] + 1) % MMD_CM; // The next unused slot measurement_delay[filwidth_delay_index[1]] = meas_sample; // Store the measurement