|
@@ -500,13 +500,11 @@ static uint8_t target_extruder;
|
500
|
500
|
#endif
|
501
|
501
|
|
502
|
502
|
#if ENABLED(FILAMENT_WIDTH_SENSOR)
|
503
|
|
- //Variables for Filament Sensor input
|
504
|
|
- float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404
|
505
|
503
|
bool filament_sensor = false; //M405 turns on filament_sensor control, M406 turns it off
|
506
|
|
- float filament_width_meas = DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter
|
507
|
|
- int8_t measurement_delay[MAX_MEASUREMENT_DELAY + 1]; //ring buffer to delay measurement store extruder factor after subtracting 100
|
508
|
|
- int filwidth_delay_index1 = 0; //index into ring buffer
|
509
|
|
- int filwidth_delay_index2 = -1; //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized
|
|
504
|
+ float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA, // Nominal filament width. Change with M404
|
|
505
|
+ filament_width_meas = DEFAULT_MEASURED_FILAMENT_DIA; // Measured filament diameter
|
|
506
|
+ int8_t measurement_delay[MAX_MEASUREMENT_DELAY + 1]; // Ring buffer to delayed measurement. Store extruder factor after subtracting 100
|
|
507
|
+ int filwidth_delay_index[2] = { 0, -1 }; // Indexes into ring buffer
|
510
|
508
|
int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting
|
511
|
509
|
#endif
|
512
|
510
|
|
|
@@ -6137,13 +6135,13 @@ inline void gcode_M400() { stepper.synchronize(); }
|
6137
|
6135
|
if (code_seen('D')) meas_delay_cm = code_value_int();
|
6138
|
6136
|
NOMORE(meas_delay_cm, MAX_MEASUREMENT_DELAY);
|
6139
|
6137
|
|
6140
|
|
- if (filwidth_delay_index2 == -1) { // Initialize the ring buffer if not done since startup
|
|
6138
|
+ if (filwidth_delay_index[1] == -1) { // Initialize the ring buffer if not done since startup
|
6141
|
6139
|
int temp_ratio = thermalManager.widthFil_to_size_ratio();
|
6142
|
6140
|
|
6143
|
6141
|
for (uint8_t i = 0; i < COUNT(measurement_delay); ++i)
|
6144
|
6142
|
measurement_delay[i] = temp_ratio - 100; // Subtract 100 to scale within a signed byte
|
6145
|
6143
|
|
6146
|
|
- filwidth_delay_index1 = filwidth_delay_index2 = 0;
|
|
6144
|
+ filwidth_delay_index[0] = filwidth_delay_index[1] = 0;
|
6147
|
6145
|
}
|
6148
|
6146
|
|
6149
|
6147
|
filament_sensor = true;
|