Sfoglia il codice sorgente

Naming and code comments

Scott Lahteine 9 anni fa
parent
commit
09d60e0128

+ 3
- 3
Marlin/Marlin.h Vedi File

@@ -247,7 +247,7 @@ inline void refresh_cmd_timeout() { previous_cmd_ms = millis(); }
247 247
 
248 248
 extern float homing_feedrate[];
249 249
 extern bool axis_relative_modes[];
250
-extern int feedmultiply;
250
+extern int feedrate_multiplier;
251 251
 extern bool volumetric_enabled;
252 252
 extern int extruder_multiply[EXTRUDERS]; // sets extrude multiply factor (in percent) for each extruder individually
253 253
 extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder.
@@ -309,8 +309,8 @@ extern int fanSpeed;
309 309
   extern float retract_recover_length, retract_recover_length_swap, retract_recover_feedrate;
310 310
 #endif
311 311
 
312
-extern millis_t starttime;
313
-extern millis_t stoptime;
312
+extern millis_t print_job_start_ms;
313
+extern millis_t print_job_stop_ms;
314 314
 
315 315
 // Handling multiple extruders pins
316 316
 extern uint8_t active_extruder;

+ 338
- 275
Marlin/Marlin_main.cpp
File diff soppresso perché troppo grande
Vedi File


+ 1
- 1
Marlin/configurator/config/language.h Vedi File

@@ -110,7 +110,7 @@
110 110
 
111 111
 // Serial Console Messages (do not translate those!)
112 112
 
113
-#define MSG_Enqueing                        "enqueing \""
113
+#define MSG_Enqueueing                      "enqueueing \""
114 114
 #define MSG_POWERUP                         "PowerUp"
115 115
 #define MSG_EXTERNAL_RESET                  " External Reset"
116 116
 #define MSG_BROWNOUT_RESET                  " Brown out Reset"

+ 3
- 3
Marlin/dogm_lcd_implementation.h Vedi File

@@ -269,8 +269,8 @@ static void lcd_implementation_status_screen() {
269 269
     }
270 270
 
271 271
     u8g.setPrintPos(80,48);
272
-    if (starttime != 0) {
273
-      uint16_t time = (millis() - starttime) / 60000;
272
+    if (print_job_start_ms != 0) {
273
+      uint16_t time = (millis() - print_job_start_ms) / 60000;
274 274
       lcd_print(itostr2(time/60));
275 275
       lcd_print(':');
276 276
       lcd_print(itostr2(time%60));
@@ -337,7 +337,7 @@ static void lcd_implementation_status_screen() {
337 337
   lcd_print(LCD_STR_FEEDRATE[0]);
338 338
   lcd_setFont(FONT_STATUSMENU);
339 339
   u8g.setPrintPos(12,49);
340
-  lcd_print(itostr3(feedmultiply));
340
+  lcd_print(itostr3(feedrate_multiplier));
341 341
   lcd_print('%');
342 342
 
343 343
   // Status line

+ 1
- 1
Marlin/language.h Vedi File

@@ -110,7 +110,7 @@
110 110
 
111 111
 // Serial Console Messages (do not translate those!)
112 112
 
113
-#define MSG_Enqueing                        "enqueing \""
113
+#define MSG_Enqueueing                      "enqueueing \""
114 114
 #define MSG_POWERUP                         "PowerUp"
115 115
 #define MSG_EXTERNAL_RESET                  " External Reset"
116 116
 #define MSG_BROWNOUT_RESET                  " Brown out Reset"

+ 72
- 66
Marlin/temperature.cpp Vedi File

@@ -219,7 +219,7 @@ void PID_autotune(float temp, int extruder, int ncycles)
219 219
   
220 220
   SERIAL_ECHOLN(MSG_PID_AUTOTUNE_START);
221 221
 
222
-  disable_heater(); // switch off all heaters.
222
+  disable_all_heaters(); // switch off all heaters.
223 223
 
224 224
   if (extruder < 0)
225 225
     soft_pwm_bed = bias = d = MAX_BED_POWER / 2;
@@ -458,11 +458,11 @@ inline void _temp_error(int e, const char *msg1, const char *msg2) {
458 458
 }
459 459
 
460 460
 void max_temp_error(uint8_t e) {
461
-  disable_heater();
461
+  disable_all_heaters();
462 462
   _temp_error(e, PSTR(MSG_MAXTEMP_EXTRUDER_OFF), PSTR(MSG_ERR_MAXTEMP));
463 463
 }
464 464
 void min_temp_error(uint8_t e) {
465
-  disable_heater();
465
+  disable_all_heaters();
466 466
   _temp_error(e, PSTR(MSG_MINTEMP_EXTRUDER_OFF), PSTR(MSG_ERR_MINTEMP));
467 467
 }
468 468
 void bed_max_temp_error(void) {
@@ -579,6 +579,14 @@ float get_pid_output(int e) {
579 579
   }
580 580
 #endif
581 581
 
582
+/**
583
+ * Manage heating activities for extruder hot-ends and a heated bed
584
+ *  - Acquire updated temperature readings
585
+ *  - Invoke thermal runaway protection
586
+ *  - Manage extruder auto-fan
587
+ *  - Apply filament width to the extrusion rate (may move)
588
+ *  - Update the heated bed PID output value
589
+ */
582 590
 void manage_heater() {
583 591
 
584 592
   if (!temp_meas_ready) return;
@@ -623,7 +631,7 @@ void manage_heater() {
623 631
 
624 632
     #ifdef TEMP_SENSOR_1_AS_REDUNDANT
625 633
       if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
626
-        disable_heater();
634
+        disable_all_heaters();
627 635
         _temp_error(0, PSTR(MSG_EXTRUDER_SWITCHED_OFF), PSTR(MSG_ERR_REDUNDANT_TEMP));
628 636
       }
629 637
     #endif // TEMP_SENSOR_1_AS_REDUNDANT
@@ -636,7 +644,22 @@ void manage_heater() {
636 644
       next_auto_fan_check_ms = ms + 2500;
637 645
     }
638 646
   #endif       
639
-  
647
+
648
+  // Control the extruder rate based on the width sensor
649
+  #ifdef FILAMENT_SENSOR
650
+    if (filament_sensor) {
651
+      meas_shift_index = delay_index1 - meas_delay_cm;
652
+      if (meas_shift_index < 0) meas_shift_index += MAX_MEASUREMENT_DELAY + 1;  //loop around buffer if needed
653
+      
654
+      // Get the delayed info and add 100 to reconstitute to a percent of
655
+      // the nominal filament diameter then square it to get an area
656
+      meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY);
657
+      float vm = pow((measurement_delay[meas_shift_index] + 100.0) / 100.0, 2);
658
+      if (vm < 0.01) vm = 0.01;
659
+      volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vm;
660
+    }
661
+  #endif //FILAMENT_SENSOR
662
+
640 663
   #ifndef PIDTEMPBED
641 664
     if (ms < next_bed_check_ms) return;
642 665
     next_bed_check_ms = ms + BED_CHECK_INTERVAL;
@@ -653,22 +676,22 @@ void manage_heater() {
653 676
 
654 677
       soft_pwm_bed = current_temperature_bed > BED_MINTEMP && current_temperature_bed < BED_MAXTEMP ? (int)pid_output >> 1 : 0;
655 678
 
656
-    #elif !defined(BED_LIMIT_SWITCHING)
657
-      // Check if temperature is within the correct range
679
+    #elif defined(BED_LIMIT_SWITCHING)
680
+      // Check if temperature is within the correct band
658 681
       if (current_temperature_bed > BED_MINTEMP && current_temperature_bed < BED_MAXTEMP) {
659
-        soft_pwm_bed = current_temperature_bed < target_temperature_bed ? MAX_BED_POWER >> 1 : 0;
682
+        if (current_temperature_bed >= target_temperature_bed + BED_HYSTERESIS)
683
+          soft_pwm_bed = 0;
684
+        else if (current_temperature_bed <= target_temperature_bed - BED_HYSTERESIS)
685
+          soft_pwm_bed = MAX_BED_POWER >> 1;
660 686
       }
661 687
       else {
662 688
         soft_pwm_bed = 0;
663 689
         WRITE_HEATER_BED(LOW);
664 690
       }
665
-    #else //#ifdef BED_LIMIT_SWITCHING
666
-      // Check if temperature is within the correct band
691
+    #else // BED_LIMIT_SWITCHING
692
+      // Check if temperature is within the correct range
667 693
       if (current_temperature_bed > BED_MINTEMP && current_temperature_bed < BED_MAXTEMP) {
668
-        if (current_temperature_bed >= target_temperature_bed + BED_HYSTERESIS)
669
-          soft_pwm_bed = 0;
670
-        else if (current_temperature_bed <= target_temperature_bed - BED_HYSTERESIS)
671
-          soft_pwm_bed = MAX_BED_POWER >> 1;
694
+        soft_pwm_bed = current_temperature_bed < target_temperature_bed ? MAX_BED_POWER >> 1 : 0;
672 695
       }
673 696
       else {
674 697
         soft_pwm_bed = 0;
@@ -676,56 +699,36 @@ void manage_heater() {
676 699
       }
677 700
     #endif
678 701
   #endif //TEMP_SENSOR_BED != 0
679
-  
680
-  // Control the extruder rate based on the width sensor
681
-  #ifdef FILAMENT_SENSOR
682
-    if (filament_sensor) {
683
-      meas_shift_index = delay_index1 - meas_delay_cm;
684
-      if (meas_shift_index < 0) meas_shift_index += MAX_MEASUREMENT_DELAY + 1;  //loop around buffer if needed
685
-      
686
-      // Get the delayed info and add 100 to reconstitute to a percent of
687
-      // the nominal filament diameter then square it to get an area
688
-      meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY);
689
-      float vm = pow((measurement_delay[meas_shift_index] + 100.0) / 100.0, 2);
690
-      if (vm < 0.01) vm = 0.01;
691
-      volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vm;
692
-    }
693
-  #endif //FILAMENT_SENSOR
694 702
 }
695 703
 
696 704
 #define PGM_RD_W(x)   (short)pgm_read_word(&x)
697 705
 // Derived from RepRap FiveD extruder::getTemperature()
698 706
 // For hot end temperature measurement.
699 707
 static float analog2temp(int raw, uint8_t e) {
700
-#ifdef TEMP_SENSOR_1_AS_REDUNDANT
701
-  if (e > EXTRUDERS)
702
-#else
703
-  if (e >= EXTRUDERS)
704
-#endif
705
-  {
708
+  #ifdef TEMP_SENSOR_1_AS_REDUNDANT
709
+    if (e > EXTRUDERS)
710
+  #else
711
+    if (e >= EXTRUDERS)
712
+  #endif
713
+    {
706 714
       SERIAL_ERROR_START;
707 715
       SERIAL_ERROR((int)e);
708 716
       SERIAL_ERRORLNPGM(MSG_INVALID_EXTRUDER_NUM);
709 717
       kill();
710 718
       return 0.0;
711
-  } 
719
+    } 
720
+
712 721
   #ifdef HEATER_0_USES_MAX6675
713
-    if (e == 0)
714
-    {
715
-      return 0.25 * raw;
716
-    }
722
+    if (e == 0) return 0.25 * raw;
717 723
   #endif
718 724
 
719
-  if(heater_ttbl_map[e] != NULL)
720
-  {
725
+  if (heater_ttbl_map[e] != NULL) {
721 726
     float celsius = 0;
722 727
     uint8_t i;
723 728
     short (*tt)[][2] = (short (*)[][2])(heater_ttbl_map[e]);
724 729
 
725
-    for (i=1; i<heater_ttbllen_map[e]; i++)
726
-    {
727
-      if (PGM_RD_W((*tt)[i][0]) > raw)
728
-      {
730
+    for (i = 1; i < heater_ttbllen_map[e]; i++) {
731
+      if (PGM_RD_W((*tt)[i][0]) > raw) {
729 732
         celsius = PGM_RD_W((*tt)[i-1][1]) + 
730 733
           (raw - PGM_RD_W((*tt)[i-1][0])) * 
731 734
           (float)(PGM_RD_W((*tt)[i][1]) - PGM_RD_W((*tt)[i-1][1])) /
@@ -749,10 +752,8 @@ static float analog2tempBed(int raw) {
749 752
     float celsius = 0;
750 753
     byte i;
751 754
 
752
-    for (i=1; i<BEDTEMPTABLE_LEN; i++)
753
-    {
754
-      if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw)
755
-      {
755
+    for (i = 1; i < BEDTEMPTABLE_LEN; i++) {
756
+      if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) {
756 757
         celsius  = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + 
757 758
           (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * 
758 759
           (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i-1][1])) /
@@ -816,11 +817,11 @@ static void updateTemperaturesFromRawValues() {
816 817
 #endif
817 818
 
818 819
 
819
-
820
-
821
-
822
-void tp_init()
823
-{
820
+/**
821
+ * Initialize the temperature manager
822
+ * The manager is implemented by periodic calls to manage_heater()
823
+ */
824
+void tp_init() {
824 825
   #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1))
825 826
     //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
826 827
     MCUCR=BIT(JTD);
@@ -1059,7 +1060,7 @@ void setWatch() {
1059 1060
         SERIAL_ERRORLNPGM(MSG_THERMAL_RUNAWAY_STOP);
1060 1061
         if (heater_id < 0) SERIAL_ERRORLNPGM("bed"); else SERIAL_ERRORLN(heater_id);
1061 1062
         LCD_ALERTMESSAGEPGM(MSG_THERMAL_RUNAWAY);
1062
-        disable_heater();
1063
+        disable_all_heaters();
1063 1064
         disable_all_steppers();
1064 1065
         for (;;) {
1065 1066
           manage_heater();
@@ -1070,7 +1071,7 @@ void setWatch() {
1070 1071
 
1071 1072
 #endif // HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION
1072 1073
 
1073
-void disable_heater() {
1074
+void disable_all_heaters() {
1074 1075
   for (int i=0; i<EXTRUDERS; i++) setTargetHotend(0, i);
1075 1076
   setTargetBed(0);
1076 1077
 
@@ -1208,11 +1209,15 @@ static void set_current_temp_raw() {
1208 1209
   temp_meas_ready = true;
1209 1210
 }
1210 1211
 
1211
-//
1212
-// Timer 0 is shared with millies
1213
-//
1212
+/**
1213
+ * Timer 0 is shared with millies
1214
+ *  - Manage PWM to all the heaters and fan
1215
+ *  - Update the raw temperature values
1216
+ *  - Check new temperature values for MIN/MAX errors
1217
+ *  - Step the babysteps value for each axis towards 0
1218
+ */
1214 1219
 ISR(TIMER0_COMPB_vect) {
1215
-  //these variables are only accesible from the ISR, but static, so they don't lose their value
1220
+
1216 1221
   static unsigned char temp_count = 0;
1217 1222
   static TempState temp_state = StartupDelay;
1218 1223
   static unsigned char pwm_count = BIT(SOFT_PWM_SCALE);
@@ -1414,6 +1419,7 @@ ISR(TIMER0_COMPB_vect) {
1414 1419
     #define START_ADC(pin) ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
1415 1420
   #endif
1416 1421
 
1422
+  // Prepare or measure a sensor, each one every 12th frame
1417 1423
   switch(temp_state) {
1418 1424
     case PrepareTemp_0:
1419 1425
       #if HAS_TEMP_0
@@ -1582,16 +1588,16 @@ ISR(TIMER0_COMPB_vect) {
1582 1588
   } // temp_count >= OVERSAMPLENR
1583 1589
 
1584 1590
   #ifdef BABYSTEPPING
1585
-    for (uint8_t axis=X_AXIS; axis<=Z_AXIS; axis++) {
1586
-      int curTodo=babystepsTodo[axis]; //get rid of volatile for performance
1591
+    for (uint8_t axis = X_AXIS; axis <= Z_AXIS; axis++) {
1592
+      int curTodo = babystepsTodo[axis]; //get rid of volatile for performance
1587 1593
      
1588 1594
       if (curTodo > 0) {
1589 1595
         babystep(axis,/*fwd*/true);
1590
-        babystepsTodo[axis]--; //less to do next time
1596
+        babystepsTodo[axis]--; //fewer to do next time
1591 1597
       }
1592
-      else if(curTodo < 0) {
1598
+      else if (curTodo < 0) {
1593 1599
         babystep(axis,/*fwd*/false);
1594
-        babystepsTodo[axis]++; //less to do next time
1600
+        babystepsTodo[axis]++; //fewer to do next time
1595 1601
       }
1596 1602
     }
1597 1603
   #endif //BABYSTEPPING

+ 1
- 1
Marlin/temperature.h Vedi File

@@ -129,7 +129,7 @@ HOTEND_ROUTINES(0);
129 129
 #endif
130 130
 
131 131
 int getHeaterPower(int heater);
132
-void disable_heater();
132
+void disable_all_heaters();
133 133
 void setWatch();
134 134
 void updatePID();
135 135
 

+ 13
- 13
Marlin/ultralcd.cpp Vedi File

@@ -152,10 +152,10 @@ static void lcd_status_screen();
152 152
    *     lcd_implementation_drawmenu_function(sel, row, PSTR(MSG_PAUSE_PRINT), lcd_sdcard_pause)
153 153
    *     menu_action_function(lcd_sdcard_pause)
154 154
    *
155
-   *   MENU_ITEM_EDIT(int3, MSG_SPEED, &feedmultiply, 10, 999)
156
-   *   MENU_ITEM(setting_edit_int3, MSG_SPEED, PSTR(MSG_SPEED), &feedmultiply, 10, 999)
157
-   *     lcd_implementation_drawmenu_setting_edit_int3(sel, row, PSTR(MSG_SPEED), PSTR(MSG_SPEED), &feedmultiply, 10, 999)
158
-   *     menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedmultiply, 10, 999)
155
+   *   MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999)
156
+   *   MENU_ITEM(setting_edit_int3, MSG_SPEED, PSTR(MSG_SPEED), &feedrate_multiplier, 10, 999)
157
+   *     lcd_implementation_drawmenu_setting_edit_int3(sel, row, PSTR(MSG_SPEED), PSTR(MSG_SPEED), &feedrate_multiplier, 10, 999)
158
+   *     menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedrate_multiplier, 10, 999)
159 159
    *
160 160
    */
161 161
   #define MENU_ITEM(type, label, args...) do { \
@@ -328,28 +328,28 @@ static void lcd_status_screen() {
328 328
 
329 329
     #ifdef ULTIPANEL_FEEDMULTIPLY
330 330
       // Dead zone at 100% feedrate
331
-      if ((feedmultiply < 100 && (feedmultiply + int(encoderPosition)) > 100) ||
332
-              (feedmultiply > 100 && (feedmultiply + int(encoderPosition)) < 100)) {
331
+      if ((feedrate_multiplier < 100 && (feedrate_multiplier + int(encoderPosition)) > 100) ||
332
+              (feedrate_multiplier > 100 && (feedrate_multiplier + int(encoderPosition)) < 100)) {
333 333
         encoderPosition = 0;
334
-        feedmultiply = 100;
334
+        feedrate_multiplier = 100;
335 335
       }
336
-      if (feedmultiply == 100) {
336
+      if (feedrate_multiplier == 100) {
337 337
         if (int(encoderPosition) > ENCODER_FEEDRATE_DEADZONE) {
338
-          feedmultiply += int(encoderPosition) - ENCODER_FEEDRATE_DEADZONE;
338
+          feedrate_multiplier += int(encoderPosition) - ENCODER_FEEDRATE_DEADZONE;
339 339
           encoderPosition = 0;
340 340
         }
341 341
         else if (int(encoderPosition) < -ENCODER_FEEDRATE_DEADZONE) {
342
-          feedmultiply += int(encoderPosition) + ENCODER_FEEDRATE_DEADZONE;
342
+          feedrate_multiplier += int(encoderPosition) + ENCODER_FEEDRATE_DEADZONE;
343 343
           encoderPosition = 0;
344 344
         }
345 345
       }
346 346
       else {
347
-        feedmultiply += int(encoderPosition);
347
+        feedrate_multiplier += int(encoderPosition);
348 348
         encoderPosition = 0;
349 349
       }
350 350
     #endif // ULTIPANEL_FEEDMULTIPLY
351 351
 
352
-    feedmultiply = constrain(feedmultiply, 10, 999);
352
+    feedrate_multiplier = constrain(feedrate_multiplier, 10, 999);
353 353
 
354 354
   #endif //ULTIPANEL
355 355
 }
@@ -456,7 +456,7 @@ void lcd_set_home_offsets() {
456 456
 static void lcd_tune_menu() {
457 457
   START_MENU();
458 458
   MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
459
-  MENU_ITEM_EDIT(int3, MSG_SPEED, &feedmultiply, 10, 999);
459
+  MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999);
460 460
   #if TEMP_SENSOR_0 != 0
461 461
     MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15);
462 462
   #endif

+ 3
- 3
Marlin/ultralcd_implementation_hitachi_HD44780.h Vedi File

@@ -550,7 +550,7 @@ static void lcd_implementation_status_screen() {
550 550
 
551 551
     lcd.setCursor(0, 2);
552 552
     lcd.print(LCD_STR_FEEDRATE[0]);
553
-    lcd.print(itostr3(feedmultiply));
553
+    lcd.print(itostr3(feedrate_multiplier));
554 554
     lcd.print('%');
555 555
 
556 556
     #if LCD_WIDTH > 19 && defined(SDSUPPORT)
@@ -567,8 +567,8 @@ static void lcd_implementation_status_screen() {
567 567
 
568 568
     lcd.setCursor(LCD_WIDTH - 6, 2);
569 569
     lcd.print(LCD_STR_CLOCK[0]);
570
-    if (starttime != 0) {
571
-      uint16_t time = millis()/60000 - starttime/60000;
570
+    if (print_job_start_ms != 0) {
571
+      uint16_t time = millis()/60000 - print_job_start_ms/60000;
572 572
       lcd.print(itostr2(time/60));
573 573
       lcd.print(':');
574 574
       lcd.print(itostr2(time%60));

Loading…
Annulla
Salva