|
@@ -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
|
|
|
@@ -555,6 +553,26 @@ static bool send_ok[BUFSIZE];
|
555
|
553
|
#define KEEPALIVE_STATE(n) ;
|
556
|
554
|
#endif // HOST_KEEPALIVE_FEATURE
|
557
|
555
|
|
|
556
|
+#define DEFINE_PGM_READ_ANY(type, reader) \
|
|
557
|
+ static inline type pgm_read_any(const type *p) \
|
|
558
|
+ { return pgm_read_##reader##_near(p); }
|
|
559
|
+
|
|
560
|
+DEFINE_PGM_READ_ANY(float, float);
|
|
561
|
+DEFINE_PGM_READ_ANY(signed char, byte);
|
|
562
|
+
|
|
563
|
+#define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \
|
|
564
|
+ static const PROGMEM type array##_P[XYZ] = \
|
|
565
|
+ { X_##CONFIG, Y_##CONFIG, Z_##CONFIG }; \
|
|
566
|
+ static inline type array(int axis) \
|
|
567
|
+ { return pgm_read_any(&array##_P[axis]); }
|
|
568
|
+
|
|
569
|
+XYZ_CONSTS_FROM_CONFIG(float, base_min_pos, MIN_POS);
|
|
570
|
+XYZ_CONSTS_FROM_CONFIG(float, base_max_pos, MAX_POS);
|
|
571
|
+XYZ_CONSTS_FROM_CONFIG(float, base_home_pos, HOME_POS);
|
|
572
|
+XYZ_CONSTS_FROM_CONFIG(float, max_length, MAX_LENGTH);
|
|
573
|
+XYZ_CONSTS_FROM_CONFIG(float, home_bump_mm, HOME_BUMP_MM);
|
|
574
|
+XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
|
|
575
|
+
|
558
|
576
|
/**
|
559
|
577
|
* ***************************************************************************
|
560
|
578
|
* ******************************** FUNCTIONS ********************************
|
|
@@ -1406,26 +1424,6 @@ bool get_target_extruder_from_command(int code) {
|
1406
|
1424
|
return false;
|
1407
|
1425
|
}
|
1408
|
1426
|
|
1409
|
|
-#define DEFINE_PGM_READ_ANY(type, reader) \
|
1410
|
|
- static inline type pgm_read_any(const type *p) \
|
1411
|
|
- { return pgm_read_##reader##_near(p); }
|
1412
|
|
-
|
1413
|
|
-DEFINE_PGM_READ_ANY(float, float);
|
1414
|
|
-DEFINE_PGM_READ_ANY(signed char, byte);
|
1415
|
|
-
|
1416
|
|
-#define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \
|
1417
|
|
- static const PROGMEM type array##_P[XYZ] = \
|
1418
|
|
- { X_##CONFIG, Y_##CONFIG, Z_##CONFIG }; \
|
1419
|
|
- static inline type array(int axis) \
|
1420
|
|
- { return pgm_read_any(&array##_P[axis]); }
|
1421
|
|
-
|
1422
|
|
-XYZ_CONSTS_FROM_CONFIG(float, base_min_pos, MIN_POS);
|
1423
|
|
-XYZ_CONSTS_FROM_CONFIG(float, base_max_pos, MAX_POS);
|
1424
|
|
-XYZ_CONSTS_FROM_CONFIG(float, base_home_pos, HOME_POS);
|
1425
|
|
-XYZ_CONSTS_FROM_CONFIG(float, max_length, MAX_LENGTH);
|
1426
|
|
-XYZ_CONSTS_FROM_CONFIG(float, home_bump_mm, HOME_BUMP_MM);
|
1427
|
|
-XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
|
1428
|
|
-
|
1429
|
1427
|
#if ENABLED(DUAL_X_CARRIAGE) || ENABLED(DUAL_NOZZLE_DUPLICATION_MODE)
|
1430
|
1428
|
bool extruder_duplication_enabled = false; // Used in Dual X mode 2
|
1431
|
1429
|
#endif
|
|
@@ -4816,7 +4814,8 @@ inline void gcode_M109() {
|
4816
|
4814
|
|
4817
|
4815
|
} while (wait_for_heatup && TEMP_CONDITIONS);
|
4818
|
4816
|
|
4819
|
|
- LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
|
|
4817
|
+ if (wait_for_heatup) LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
|
|
4818
|
+
|
4820
|
4819
|
KEEPALIVE_STATE(IN_HANDLER);
|
4821
|
4820
|
}
|
4822
|
4821
|
|
|
@@ -4934,7 +4933,7 @@ inline void gcode_M109() {
|
4934
|
4933
|
|
4935
|
4934
|
} while (wait_for_heatup && TEMP_BED_CONDITIONS);
|
4936
|
4935
|
|
4937
|
|
- LCD_MESSAGEPGM(MSG_BED_DONE);
|
|
4936
|
+ if (wait_for_heatup) LCD_MESSAGEPGM(MSG_BED_DONE);
|
4938
|
4937
|
KEEPALIVE_STATE(IN_HANDLER);
|
4939
|
4938
|
}
|
4940
|
4939
|
|
|
@@ -6136,13 +6135,13 @@ inline void gcode_M400() { stepper.synchronize(); }
|
6136
|
6135
|
if (code_seen('D')) meas_delay_cm = code_value_int();
|
6137
|
6136
|
NOMORE(meas_delay_cm, MAX_MEASUREMENT_DELAY);
|
6138
|
6137
|
|
6139
|
|
- 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
|
6140
|
6139
|
int temp_ratio = thermalManager.widthFil_to_size_ratio();
|
6141
|
6140
|
|
6142
|
6141
|
for (uint8_t i = 0; i < COUNT(measurement_delay); ++i)
|
6143
|
6142
|
measurement_delay[i] = temp_ratio - 100; // Subtract 100 to scale within a signed byte
|
6144
|
6143
|
|
6145
|
|
- filwidth_delay_index1 = filwidth_delay_index2 = 0;
|
|
6144
|
+ filwidth_delay_index[0] = filwidth_delay_index[1] = 0;
|
6146
|
6145
|
}
|
6147
|
6146
|
|
6148
|
6147
|
filament_sensor = true;
|