瀏覽代碼

Merge pull request #3272 from thinkyhead/rc_filament_sensor_scope

Minor cleanup to filament sensor code
Scott Lahteine 9 年之前
父節點
當前提交
9e520ae319
共有 3 個文件被更改,包括 4 次插入9 次删除
  1. 1
    1
      Marlin/Marlin.h
  2. 2
    2
      Marlin/Marlin_main.cpp
  3. 1
    6
      Marlin/planner.cpp

+ 1
- 1
Marlin/Marlin.h 查看文件

@@ -338,7 +338,7 @@ extern bool axis_homed[3]; // axis[n].is_homed
338 338
   extern float filament_width_nominal;  //holds the theoretical filament diameter i.e., 3.00 or 1.75
339 339
   extern bool filament_sensor;  //indicates that filament sensor readings should control extrusion
340 340
   extern float filament_width_meas; //holds the filament diameter as accurately measured
341
-  extern signed char measurement_delay[];  //ring buffer to delay measurement
341
+  extern int8_t measurement_delay[];  //ring buffer to delay measurement
342 342
   extern int delay_index1, delay_index2;  //ring buffer index. used by planner, temperature, and main code
343 343
   extern float delay_dist; //delay distance counter
344 344
   extern int meas_delay_cm; //delay distance

+ 2
- 2
Marlin/Marlin_main.cpp 查看文件

@@ -410,7 +410,7 @@ static uint8_t target_extruder;
410 410
   float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA;  //Set nominal filament width, can be changed with M404
411 411
   bool filament_sensor = false;  //M405 turns on filament_sensor control, M406 turns it off
412 412
   float filament_width_meas = DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter
413
-  signed char measurement_delay[MAX_MEASUREMENT_DELAY + 1]; //ring buffer to delay measurement  store extruder factor after subtracting 100
413
+  int8_t measurement_delay[MAX_MEASUREMENT_DELAY + 1]; //ring buffer to delay measurement  store extruder factor after subtracting 100
414 414
   int delay_index1 = 0;  //index into ring buffer
415 415
   int delay_index2 = -1;  //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized
416 416
   float delay_dist = 0; //delay distance counter
@@ -5464,7 +5464,7 @@ inline void gcode_M400() { st_synchronize(); }
5464 5464
     if (delay_index2 == -1) { //initialize the ring buffer if it has not been done since startup
5465 5465
       int temp_ratio = widthFil_to_size_ratio();
5466 5466
 
5467
-      for (delay_index1 = 0; delay_index1 < MAX_MEASUREMENT_DELAY + 1; ++delay_index1)
5467
+      for (delay_index1 = 0; delay_index1 < COUNT(measurement_delay); ++delay_index1)
5468 5468
         measurement_delay[delay_index1] = temp_ratio - 100;  //subtract 100 to scale within a signed byte
5469 5469
 
5470 5470
       delay_index1 = delay_index2 = 0;

+ 1
- 6
Marlin/planner.cpp 查看文件

@@ -147,10 +147,6 @@ uint8_t g_uc_extruder_last_move[EXTRUDERS] = { 0 };
147 147
   static long axis_segment_time[2][3] = { {MAX_FREQ_TIME + 1, 0, 0}, {MAX_FREQ_TIME + 1, 0, 0} };
148 148
 #endif
149 149
 
150
-#if ENABLED(FILAMENT_SENSOR)
151
-  static char meas_sample; //temporary variable to hold filament measurement sample
152
-#endif
153
-
154 150
 #if ENABLED(DUAL_X_CARRIAGE)
155 151
   extern bool extruder_duplication_enabled;
156 152
 #endif
@@ -857,7 +853,6 @@ float junction_deviation = 0.1;
857 853
 
858 854
   #if ENABLED(FILAMENT_SENSOR)
859 855
     //FMM update ring buffer used for delay with filament measurements
860
-
861 856
     if (extruder == FILAMENT_SENSOR_EXTRUDER_NUM && delay_index2 > -1) {  //only for extruder with filament sensor and if ring buffer is initialized
862 857
 
863 858
       const int MMD = MAX_MEASUREMENT_DELAY + 1, MMD10 = MMD * 10;
@@ -870,7 +865,7 @@ float junction_deviation = 0.1;
870 865
       delay_index1 = constrain(delay_index1, 0, MAX_MEASUREMENT_DELAY); // (already constrained above)
871 866
 
872 867
       if (delay_index1 != delay_index2) { // moved index
873
-        meas_sample = widthFil_to_size_ratio() - 100;  // Subtract 100 to reduce magnitude - to store in a signed char
868
+        int8_t meas_sample = widthFil_to_size_ratio() - 100;  // Subtract 100 to reduce magnitude - to store in a signed char
874 869
         while (delay_index1 != delay_index2) {
875 870
           // Increment and loop around buffer
876 871
           if (++delay_index2 >= MMD) delay_index2 -= MMD;

Loading…
取消
儲存