|
@@ -302,12 +302,12 @@ bool cancel_heatup = false ;
|
302
|
302
|
|
303
|
303
|
#ifdef FILAMENT_SENSOR
|
304
|
304
|
//Variables for Filament Sensor input
|
305
|
|
- volatile float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404
|
306
|
|
- volatile bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off
|
|
305
|
+ float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404
|
|
306
|
+ bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off
|
307
|
307
|
float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter
|
308
|
308
|
signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100
|
309
|
|
- int delay_index1=0;
|
310
|
|
- int delay_index2=0; //index into ring buffer
|
|
309
|
+ int delay_index1=0; //index into ring buffer
|
|
310
|
+ int delay_index2=-1; //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized
|
311
|
311
|
float delay_dist=0; //delay distance counter
|
312
|
312
|
int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting
|
313
|
313
|
#endif
|
|
@@ -504,6 +504,7 @@ void servo_init()
|
504
|
504
|
#endif
|
505
|
505
|
}
|
506
|
506
|
|
|
507
|
+
|
507
|
508
|
void setup()
|
508
|
509
|
{
|
509
|
510
|
setup_killpin();
|
|
@@ -553,6 +554,7 @@ void setup()
|
553
|
554
|
st_init(); // Initialize stepper, this enables interrupts!
|
554
|
555
|
setup_photpin();
|
555
|
556
|
servo_init();
|
|
557
|
+
|
556
|
558
|
|
557
|
559
|
lcd_init();
|
558
|
560
|
_delay_ms(1000); // wait 1sec to display the splash screen
|
|
@@ -2333,12 +2335,8 @@ void process_commands()
|
2333
|
2335
|
}
|
2334
|
2336
|
} else {
|
2335
|
2337
|
//reserved for setting filament diameter via UFID or filament measuring device
|
2336
|
|
- if(active_extruder == FILAMENT_SENSOR_EXTRUDER_NUM){
|
2337
|
|
- radius = analog2widthFil() * 0.5;
|
2338
|
|
- area = M_PI * pow(radius, 2);
|
2339
|
|
- }else{
|
2340
|
|
- area = 1.0;
|
2341
|
|
- }
|
|
2338
|
+ break;
|
|
2339
|
+
|
2342
|
2340
|
|
2343
|
2341
|
}
|
2344
|
2342
|
tmp_extruder = active_extruder;
|
|
@@ -2816,15 +2814,19 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
|
2816
|
2814
|
if(meas_delay_cm> MAX_MEASUREMENT_DELAY)
|
2817
|
2815
|
meas_delay_cm = MAX_MEASUREMENT_DELAY;
|
2818
|
2816
|
|
|
2817
|
+ if(delay_index2 == -1) //initialize the ring buffer if it has not been done since startup
|
|
2818
|
+ {
|
|
2819
|
+ int temp_ratio = widthFil_to_size_ratio();
|
|
2820
|
+
|
|
2821
|
+ for (delay_index1=0; delay_index1<(MAX_MEASUREMENT_DELAY+1); ++delay_index1 ){
|
|
2822
|
+ measurement_delay[delay_index1]=temp_ratio-100; //subtract 100 to scale within a signed byte
|
|
2823
|
+ }
|
|
2824
|
+ delay_index1=0;
|
|
2825
|
+ delay_index2=0;
|
|
2826
|
+ }
|
|
2827
|
+
|
2819
|
2828
|
filament_sensor = true ;
|
2820
|
|
- int temp_ratio = widthFil_to_size_ratio();
|
2821
|
2829
|
|
2822
|
|
- for (delay_index1=0; delay_index1<(MAX_MEASUREMENT_DELAY+1); ++delay_index1 ){
|
2823
|
|
- measurement_delay[delay_index1]=temp_ratio-100; //subtract 100 to scale within a signed byte
|
2824
|
|
- }
|
2825
|
|
- delay_index1=0;
|
2826
|
|
- delay_index2=0;
|
2827
|
|
-
|
2828
|
2830
|
//SERIAL_PROTOCOLPGM("Filament dia (measured mm):");
|
2829
|
2831
|
//SERIAL_PROTOCOL(filament_width_meas);
|
2830
|
2832
|
//SERIAL_PROTOCOLPGM("Extrusion ratio(%):");
|
|
@@ -2841,7 +2843,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
|
2841
|
2843
|
case 407: //M407 Display measured filament diameter
|
2842
|
2844
|
{
|
2843
|
2845
|
|
2844
|
|
- filament_width_meas = code_value();
|
|
2846
|
+
|
2845
|
2847
|
|
2846
|
2848
|
SERIAL_PROTOCOLPGM("Filament dia (measured mm):");
|
2847
|
2849
|
SERIAL_PROTOCOLLN(filament_width_meas);
|