Browse Source

Merge pull request #6453 from thinkyhead/rc_cleanup_wednesday

Minor cleanups, work-in-progress
Scott Lahteine 8 years ago
parent
commit
817ecb9ff4
5 changed files with 20 additions and 20 deletions
  1. 8
    8
      Marlin/Marlin_main.cpp
  2. 2
    1
      Marlin/printcounter.cpp
  3. 2
    2
      Marlin/printcounter.h
  4. 6
    7
      Marlin/temperature.cpp
  5. 2
    2
      Marlin/ultralcd.cpp

+ 8
- 8
Marlin/Marlin_main.cpp View File

@@ -616,12 +616,12 @@ static uint8_t target_extruder;
616 616
 float cartes[XYZ] = { 0 };
617 617
 
618 618
 #if ENABLED(FILAMENT_WIDTH_SENSOR)
619
-  bool filament_sensor = false;  //M405 turns on filament_sensor control, M406 turns it off
620
-  float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA,  // Nominal filament width. Change with M404
619
+  bool filament_sensor = false;                                 // M405 turns on filament sensor control. M406 turns it off.
620
+  float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA,  // Nominal filament width. Change with M404.
621 621
         filament_width_meas = DEFAULT_MEASURED_FILAMENT_DIA;    // Measured filament diameter
622
-  int8_t measurement_delay[MAX_MEASUREMENT_DELAY + 1]; // Ring buffer to delayed measurement. Store extruder factor after subtracting 100
623
-  int filwidth_delay_index[2] = { 0, -1 };  // Indexes into ring buffer
624
-  int meas_delay_cm = MEASUREMENT_DELAY_CM;  //distance delay setting
622
+  int8_t measurement_delay[MAX_MEASUREMENT_DELAY + 1];          // Ring buffer to delayed measurement. Store extruder factor after subtracting 100
623
+  int filwidth_delay_index[2] = { 0, -1 };                      // Indexes into ring buffer
624
+  int meas_delay_cm = MEASUREMENT_DELAY_CM;                     // Distance delay setting
625 625
 #endif
626 626
 
627 627
 #if ENABLED(FILAMENT_RUNOUT_SENSOR)
@@ -8220,10 +8220,10 @@ inline void gcode_M400() { stepper.synchronize(); }
8220 8220
     NOMORE(meas_delay_cm, MAX_MEASUREMENT_DELAY);
8221 8221
 
8222 8222
     if (filwidth_delay_index[1] == -1) { // Initialize the ring buffer if not done since startup
8223
-      int temp_ratio = thermalManager.widthFil_to_size_ratio();
8223
+      const int temp_ratio = thermalManager.widthFil_to_size_ratio() - 100; // -100 to scale within a signed byte
8224 8224
 
8225 8225
       for (uint8_t i = 0; i < COUNT(measurement_delay); ++i)
8226
-        measurement_delay[i] = temp_ratio - 100;  // Subtract 100 to scale within a signed byte
8226
+        measurement_delay[i] = temp_ratio;
8227 8227
 
8228 8228
       filwidth_delay_index[0] = filwidth_delay_index[1] = 0;
8229 8229
     }
@@ -10279,7 +10279,7 @@ void process_next_command() {
10279 10279
         case 407:   // M407: Display measured filament diameter
10280 10280
           gcode_M407();
10281 10281
           break;
10282
-      #endif // ENABLED(FILAMENT_WIDTH_SENSOR)
10282
+      #endif // FILAMENT_WIDTH_SENSOR
10283 10283
 
10284 10284
       #if PLANNER_LEVELING
10285 10285
         case 420: // M420: Enable/Disable Bed Leveling

+ 2
- 1
Marlin/printcounter.cpp View File

@@ -188,7 +188,8 @@ bool PrintCounter::start() {
188 188
     }
189 189
     return true;
190 190
   }
191
-  else return false;
191
+
192
+  return false;
192 193
 }
193 194
 
194 195
 // @Override

+ 2
- 2
Marlin/printcounter.h View File

@@ -32,12 +32,12 @@
32 32
 // Print debug messages with M111 S2
33 33
 //#define DEBUG_PRINTCOUNTER
34 34
 
35
-struct printStatistics {    // 13 bytes
35
+struct printStatistics {    // 16 bytes (20 with real doubles)
36 36
   //const uint8_t magic;    // Magic header, it will always be 0x16
37 37
   uint16_t totalPrints;     // Number of prints
38 38
   uint16_t finishedPrints;  // Number of complete prints
39 39
   uint32_t printTime;       // Accumulated printing time
40
-  uint32_t longestPrint;    // Longest successfull print job
40
+  uint32_t longestPrint;    // Longest successful print job
41 41
   double   filamentUsed;    // Accumulated filament consumed in mm
42 42
 };
43 43
 

+ 6
- 7
Marlin/temperature.cpp View File

@@ -766,15 +766,14 @@ void Temperature::manage_heater() {
766 766
     if (filament_sensor) {
767 767
       meas_shift_index = filwidth_delay_index[0] - meas_delay_cm;
768 768
       if (meas_shift_index < 0) meas_shift_index += MAX_MEASUREMENT_DELAY + 1;  //loop around buffer if needed
769
+      meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY);
769 770
 
770 771
       // Get the delayed info and add 100 to reconstitute to a percent of
771 772
       // the nominal filament diameter then square it to get an area
772
-      meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY);
773
-      float vm = pow((measurement_delay[meas_shift_index] + 100.0) * 0.01, 2);
774
-      NOLESS(vm, 0.01);
775
-      volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vm;
773
+      const float vmroot = measurement_delay[meas_shift_index] * 0.01 + 1.0;
774
+      volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vmroot <= 0.1 ? 0.01 : sq(vmroot);
776 775
     }
777
-  #endif //FILAMENT_WIDTH_SENSOR
776
+  #endif // FILAMENT_WIDTH_SENSOR
778 777
 
779 778
   #if DISABLED(PIDTEMPBED)
780 779
     if (PENDING(ms, next_bed_check_ms)) return;
@@ -961,8 +960,8 @@ void Temperature::updateTemperaturesFromRawValues() {
961 960
  */
962 961
 void Temperature::init() {
963 962
 
964
-  #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1))
965
-    //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
963
+  #if MB(RUMBA) && (TEMP_SENSOR_0 == -1 || TEMP_SENSOR_1 == -1 || TEMP_SENSOR_2 == -1 || TEMP_SENSOR_BED == -1)
964
+    // Disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
966 965
     MCUCR = _BV(JTD);
967 966
     MCUCR = _BV(JTD);
968 967
   #endif

+ 2
- 2
Marlin/ultralcd.cpp View File

@@ -705,7 +705,7 @@ void kill_screen(const char* lcd_msg) {
705 705
         thermalManager.autotempShutdown();
706 706
       #endif
707 707
       wait_for_heatup = false;
708
-      lcd_setstatuspgm(PSTR(MSG_PRINT_ABORTED), true);
708
+      LCD_MESSAGEPGM(MSG_PRINT_ABORTED);
709 709
     }
710 710
 
711 711
   #endif // SDSUPPORT
@@ -2725,7 +2725,7 @@ void kill_screen(const char* lcd_msg) {
2725 2725
 
2726 2726
         START_SCREEN();                                                                                // 12345678901234567890
2727 2727
         STATIC_ITEM(MSG_INFO_PRINT_COUNT ": ", false, false, itostr3left(stats.totalPrints));          // Print Count: 999
2728
-        STATIC_ITEM(MSG_INFO_COMPLETED_PRINTS": ", false, false, itostr3left(stats.finishedPrints)); // Completed  : 666
2728
+        STATIC_ITEM(MSG_INFO_COMPLETED_PRINTS": ", false, false, itostr3left(stats.finishedPrints));   // Completed  : 666
2729 2729
 
2730 2730
         duration_t elapsed = stats.printTime;
2731 2731
         elapsed.toString(buffer);

Loading…
Cancel
Save