Browse Source

Latest upstream commits, mostly

Scott Lahteine 9 years ago
parent
commit
c185912c19
8 changed files with 230 additions and 199 deletions
  1. 75
    31
      Marlin/ConfigurationStore.cpp
  2. 6
    3
      Marlin/Marlin.h
  3. 49
    42
      Marlin/Marlin_main.cpp
  4. 1
    1
      Marlin/planner.cpp
  5. 1
    7
      Marlin/stepper.cpp
  6. 76
    79
      Marlin/temperature.cpp
  7. 17
    31
      Marlin/temperature.h
  8. 5
    5
      README.md

+ 75
- 31
Marlin/ConfigurationStore.cpp View File

3
  *
3
  *
4
  * Configuration and EEPROM storage
4
  * Configuration and EEPROM storage
5
  *
5
  *
6
- * V16 EEPROM Layout:
6
+ * IMPORTANT:  Whenever there are changes made to the variables stored in EEPROM
7
+ * in the functions below, also increment the version number. This makes sure that
8
+ * the default values are used whenever there is a change to the data, to prevent
9
+ * wrong data being written to the variables.
10
+ *
11
+ * ALSO: Variables in the Store and Retrieve sections must be in the same order.
12
+ *       If a feature is disabled, some data must still be written that, when read,
13
+ *       either sets a Sane Default, or results in No Change to the existing value.
14
+ *
15
+ */
16
+
17
+#define EEPROM_VERSION "V19"
18
+
19
+/**
20
+ * V19 EEPROM Layout:
7
  *
21
  *
8
  *  ver
22
  *  ver
9
  *  axis_steps_per_unit (x4)
23
  *  axis_steps_per_unit (x4)
47
  *  Kp[2], Ki[2], Kd[2], Kc[2]
61
  *  Kp[2], Ki[2], Kd[2], Kc[2]
48
  *  Kp[3], Ki[3], Kd[3], Kc[3]
62
  *  Kp[3], Ki[3], Kd[3], Kc[3]
49
  *
63
  *
64
+ * PIDTEMPBED:
65
+ *  bedKp, bedKi, bedKd
66
+ *
50
  * DOGLCD:
67
  * DOGLCD:
51
  *  lcd_contrast
68
  *  lcd_contrast
52
  *
69
  *
111
 
128
 
112
 #define EEPROM_OFFSET 100
129
 #define EEPROM_OFFSET 100
113
 
130
 
114
-
115
-// IMPORTANT:  Whenever there are changes made to the variables stored in EEPROM
116
-// in the functions below, also increment the version number. This makes sure that
117
-// the default values are used whenever there is a change to the data, to prevent
118
-// wrong data being written to the variables.
119
-// ALSO:  always make sure the variables in the Store and retrieve sections are in the same order.
120
-
121
-#define EEPROM_VERSION "V18"
122
-
123
 #ifdef EEPROM_SETTINGS
131
 #ifdef EEPROM_SETTINGS
124
 
132
 
125
 void Config_StoreSettings()  {
133
 void Config_StoreSettings()  {
194
   EEPROM_WRITE_VAR(i, absPreheatHPBTemp);
202
   EEPROM_WRITE_VAR(i, absPreheatHPBTemp);
195
   EEPROM_WRITE_VAR(i, absPreheatFanSpeed);
203
   EEPROM_WRITE_VAR(i, absPreheatFanSpeed);
196
 
204
 
197
-
198
   for (int e = 0; e < 4; e++) {
205
   for (int e = 0; e < 4; e++) {
199
 
206
 
200
     #ifdef PIDTEMP
207
     #ifdef PIDTEMP
209
           EEPROM_WRITE_VAR(i, dummy);
216
           EEPROM_WRITE_VAR(i, dummy);
210
         #endif
217
         #endif
211
       }
218
       }
212
-      else {
213
-    #else // !PIDTEMP
214
-      {
219
+      else
215
     #endif // !PIDTEMP
220
     #endif // !PIDTEMP
216
-
217
-        dummy = DUMMY_PID_VALUE;
221
+      {
222
+        dummy = DUMMY_PID_VALUE; // When read, will not change the existing value
218
         EEPROM_WRITE_VAR(i, dummy);
223
         EEPROM_WRITE_VAR(i, dummy);
219
         dummy = 0.0f;
224
         dummy = 0.0f;
220
         for (int q = 3; q--;) EEPROM_WRITE_VAR(i, dummy);
225
         for (int q = 3; q--;) EEPROM_WRITE_VAR(i, dummy);
222
 
227
 
223
   } // Extruders Loop
228
   } // Extruders Loop
224
 
229
 
230
+  #ifndef PIDTEMPBED
231
+    float bedKp = DUMMY_PID_VALUE, bedKi = DUMMY_PID_VALUE, bedKd = DUMMY_PID_VALUE;
232
+  #endif
233
+
234
+  EEPROM_WRITE_VAR(i, bedKp);
235
+  EEPROM_WRITE_VAR(i, bedKi);
236
+  EEPROM_WRITE_VAR(i, bedKd);
237
+
225
   #ifndef DOGLCD
238
   #ifndef DOGLCD
226
     int lcd_contrast = 32;
239
     int lcd_contrast = 32;
227
   #endif
240
   #endif
364
 
377
 
365
     #ifdef PIDTEMP
378
     #ifdef PIDTEMP
366
       for (int e = 0; e < 4; e++) { // 4 = max extruders currently supported by Marlin
379
       for (int e = 0; e < 4; e++) { // 4 = max extruders currently supported by Marlin
367
-        EEPROM_READ_VAR(i, dummy);
380
+        EEPROM_READ_VAR(i, dummy); // Kp
368
         if (e < EXTRUDERS && dummy != DUMMY_PID_VALUE) {
381
         if (e < EXTRUDERS && dummy != DUMMY_PID_VALUE) {
369
           // do not need to scale PID values as the values in EEPROM are already scaled
382
           // do not need to scale PID values as the values in EEPROM are already scaled
370
           PID_PARAM(Kp, e) = dummy;
383
           PID_PARAM(Kp, e) = dummy;
385
       for (int q=16; q--;) EEPROM_READ_VAR(i, dummy);  // 4x Kp, Ki, Kd, Kc
398
       for (int q=16; q--;) EEPROM_READ_VAR(i, dummy);  // 4x Kp, Ki, Kd, Kc
386
     #endif // !PIDTEMP
399
     #endif // !PIDTEMP
387
 
400
 
401
+    #ifndef PIDTEMPBED
402
+      float bedKp, bedKi, bedKd;
403
+    #endif
404
+
405
+    EEPROM_READ_VAR(i, dummy); // bedKp
406
+    if (dummy != DUMMY_PID_VALUE) {
407
+      bedKp = dummy;
408
+      EEPROM_READ_VAR(i, bedKi);
409
+      EEPROM_READ_VAR(i, bedKd);
410
+    }
411
+    else {
412
+      for (int q=2; q--;) EEPROM_READ_VAR(i, dummy); // bedKi, bedKd
413
+    }
414
+
388
     #ifndef DOGLCD
415
     #ifndef DOGLCD
389
       int lcd_contrast;
416
       int lcd_contrast;
390
     #endif
417
     #endif
517
     updatePID();
544
     updatePID();
518
   #endif // PIDTEMP
545
   #endif // PIDTEMP
519
 
546
 
547
+  #ifdef PIDTEMPBED
548
+    bedKp = DEFAULT_bedKp;
549
+    bedKi = scalePID_i(DEFAULT_bedKi);
550
+    bedKd = scalePID_d(DEFAULT_bedKd);
551
+  #endif
552
+
520
   #ifdef FWRETRACT
553
   #ifdef FWRETRACT
521
     autoretract_enabled = false;
554
     autoretract_enabled = false;
522
     retract_length = RETRACT_LENGTH;
555
     retract_length = RETRACT_LENGTH;
660
     SERIAL_EOL;  
693
     SERIAL_EOL;  
661
   #endif // DELTA
694
   #endif // DELTA
662
 
695
 
663
-  #ifdef PIDTEMP
696
+  #if defined(PIDTEMP) || defined(PIDTEMPBED)
664
     SERIAL_ECHO_START;
697
     SERIAL_ECHO_START;
665
     if (!forReplay) {
698
     if (!forReplay) {
666
       SERIAL_ECHOLNPGM("PID settings:");
699
       SERIAL_ECHOLNPGM("PID settings:");
667
       SERIAL_ECHO_START;
700
       SERIAL_ECHO_START;
668
     }
701
     }
669
-    SERIAL_ECHOPAIR("   M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echos values for E0
670
-    SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
671
-    SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
672
-    SERIAL_EOL;
673
-  #endif // PIDTEMP
702
+    #if defined(PIDTEMP) && defined(PIDTEMPBED)
703
+      SERIAL_EOL;
704
+    #endif
705
+    #ifdef PIDTEMP
706
+      SERIAL_ECHOPAIR("  M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echos values for E0
707
+      SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
708
+      SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
709
+      SERIAL_EOL;
710
+    #endif
711
+    #ifdef PIDTEMPBED
712
+      SERIAL_ECHOPAIR("  M304 P", bedKp); // for compatibility with hosts, only echos values for E0
713
+      SERIAL_ECHOPAIR(" I", unscalePID_i(bedKi));
714
+      SERIAL_ECHOPAIR(" D", unscalePID_d(bedKd));
715
+      SERIAL_EOL;
716
+    #endif
717
+  #endif
674
 
718
 
675
   #ifdef FWRETRACT
719
   #ifdef FWRETRACT
676
 
720
 
679
       SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
723
       SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
680
       SERIAL_ECHO_START;
724
       SERIAL_ECHO_START;
681
     }
725
     }
682
-    SERIAL_ECHOPAIR("   M207 S", retract_length);
726
+    SERIAL_ECHOPAIR("  M207 S", retract_length);
683
     SERIAL_ECHOPAIR(" F", retract_feedrate*60);
727
     SERIAL_ECHOPAIR(" F", retract_feedrate*60);
684
     SERIAL_ECHOPAIR(" Z", retract_zlift);
728
     SERIAL_ECHOPAIR(" Z", retract_zlift);
685
     SERIAL_EOL;
729
     SERIAL_EOL;
688
       SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
732
       SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
689
       SERIAL_ECHO_START;
733
       SERIAL_ECHO_START;
690
     }
734
     }
691
-    SERIAL_ECHOPAIR("   M208 S", retract_recover_length);
735
+    SERIAL_ECHOPAIR("  M208 S", retract_recover_length);
692
     SERIAL_ECHOPAIR(" F", retract_recover_feedrate*60);
736
     SERIAL_ECHOPAIR(" F", retract_recover_feedrate*60);
693
     SERIAL_EOL;
737
     SERIAL_EOL;
694
     SERIAL_ECHO_START;
738
     SERIAL_ECHO_START;
696
       SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
740
       SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
697
       SERIAL_ECHO_START;
741
       SERIAL_ECHO_START;
698
     }
742
     }
699
-    SERIAL_ECHOPAIR("   M209 S", (unsigned long)(autoretract_enabled ? 1 : 0));
743
+    SERIAL_ECHOPAIR("  M209 S", (unsigned long)(autoretract_enabled ? 1 : 0));
700
     SERIAL_EOL;
744
     SERIAL_EOL;
701
 
745
 
702
     #if EXTRUDERS > 1
746
     #if EXTRUDERS > 1
720
       SERIAL_ECHOLNPGM("Filament settings:");
764
       SERIAL_ECHOLNPGM("Filament settings:");
721
       SERIAL_ECHO_START;
765
       SERIAL_ECHO_START;
722
     }
766
     }
723
-    SERIAL_ECHOPAIR("   M200 D", filament_size[0]);
767
+    SERIAL_ECHOPAIR("  M200 D", filament_size[0]);
724
     SERIAL_EOL;
768
     SERIAL_EOL;
725
 
769
 
726
     #if EXTRUDERS > 1
770
     #if EXTRUDERS > 1
727
       SERIAL_ECHO_START;
771
       SERIAL_ECHO_START;
728
-      SERIAL_ECHOPAIR("   M200 T1 D", filament_size[1]);
772
+      SERIAL_ECHOPAIR("  M200 T1 D", filament_size[1]);
729
       SERIAL_EOL;
773
       SERIAL_EOL;
730
       #if EXTRUDERS > 2
774
       #if EXTRUDERS > 2
731
         SERIAL_ECHO_START;
775
         SERIAL_ECHO_START;
732
-        SERIAL_ECHOPAIR("   M200 T2 D", filament_size[2]);
776
+        SERIAL_ECHOPAIR("  M200 T2 D", filament_size[2]);
733
         SERIAL_EOL;
777
         SERIAL_EOL;
734
         #if EXTRUDERS > 3
778
         #if EXTRUDERS > 3
735
           SERIAL_ECHO_START;
779
           SERIAL_ECHO_START;
736
-          SERIAL_ECHOPAIR("   M200 T3 D", filament_size[3]);
780
+          SERIAL_ECHOPAIR("  M200 T3 D", filament_size[3]);
737
           SERIAL_EOL;
781
           SERIAL_EOL;
738
         #endif
782
         #endif
739
       #endif
783
       #endif
752
         SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
796
         SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
753
         SERIAL_ECHO_START;
797
         SERIAL_ECHO_START;
754
       }
798
       }
755
-      SERIAL_ECHOPAIR("   M", (unsigned long)CUSTOM_M_CODE_SET_Z_PROBE_OFFSET);
799
+      SERIAL_ECHOPAIR("  M", (unsigned long)CUSTOM_M_CODE_SET_Z_PROBE_OFFSET);
756
       SERIAL_ECHOPAIR(" Z", -zprobe_zoffset);
800
       SERIAL_ECHOPAIR(" Z", -zprobe_zoffset);
757
     #else
801
     #else
758
       if (!forReplay) {
802
       if (!forReplay) {

+ 6
- 3
Marlin/Marlin.h View File

97
 
97
 
98
 // Things to write to serial from Program memory. Saves 400 to 2k of RAM.
98
 // Things to write to serial from Program memory. Saves 400 to 2k of RAM.
99
 FORCE_INLINE void serialprintPGM(const char *str) {
99
 FORCE_INLINE void serialprintPGM(const char *str) {
100
-  char ch = pgm_read_byte(str);
101
-  while(ch) {
100
+  char ch;
101
+  while ((ch = pgm_read_byte(str))) {
102
     MYSERIAL.write(ch);
102
     MYSERIAL.write(ch);
103
-    ch = pgm_read_byte(++str);
103
+    str++;
104
   }
104
   }
105
 }
105
 }
106
 
106
 
191
  */
191
  */
192
 enum AxisEnum {X_AXIS=0, Y_AXIS=1, A_AXIS=0, B_AXIS=1, Z_AXIS=2, E_AXIS=3, X_HEAD=4, Y_HEAD=5};
192
 enum AxisEnum {X_AXIS=0, Y_AXIS=1, A_AXIS=0, B_AXIS=1, Z_AXIS=2, E_AXIS=3, X_HEAD=4, Y_HEAD=5};
193
 
193
 
194
+void enable_all_steppers();
195
+void disable_all_steppers();
196
+
194
 void FlushSerialRequestResend();
197
 void FlushSerialRequestResend();
195
 void ClearToSend();
198
 void ClearToSend();
196
 
199
 

+ 49
- 42
Marlin/Marlin_main.cpp View File

110
 //        Call gcode file : "M32 P !filename#" and return to caller file after finishing (similar to #include).
110
 //        Call gcode file : "M32 P !filename#" and return to caller file after finishing (similar to #include).
111
 //        The '#' is necessary when calling from within sd files, as it stops buffer prereading
111
 //        The '#' is necessary when calling from within sd files, as it stops buffer prereading
112
 // M42  - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used.
112
 // M42  - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used.
113
+// M48  - Measure Z_Probe repeatability. M48 [n # of points] [X position] [Y position] [V_erboseness #] [E_ngage Probe] [L # of legs of travel]
113
 // M80  - Turn on Power Supply
114
 // M80  - Turn on Power Supply
114
 // M81  - Turn off Power Supply
115
 // M81  - Turn off Power Supply
115
 // M82  - Set E codes absolute (default)
116
 // M82  - Set E codes absolute (default)
1814
       // Raise Z before homing any other axes
1815
       // Raise Z before homing any other axes
1815
       if (home_all_axis || homeZ) {
1816
       if (home_all_axis || homeZ) {
1816
         destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS);    // Set destination away from bed
1817
         destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS);    // Set destination away from bed
1817
-        feedrate = max_feedrate[Z_AXIS];
1818
+        feedrate = max_feedrate[Z_AXIS] * 60;
1818
         line_to_destination();
1819
         line_to_destination();
1819
         st_synchronize();
1820
         st_synchronize();
1820
       }
1821
       }
1947
               current_position[Z_AXIS] = 0;
1948
               current_position[Z_AXIS] = 0;
1948
               plan_set_position(cpx, cpy, 0, current_position[E_AXIS]);
1949
               plan_set_position(cpx, cpy, 0, current_position[E_AXIS]);
1949
               destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS);    // Set destination away from bed
1950
               destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS);    // Set destination away from bed
1950
-              feedrate = max_feedrate[Z_AXIS];
1951
+              feedrate = max_feedrate[Z_AXIS] * 60;  // max_feedrate is in mm/s. line_to_destination is feedrate/60.
1951
               line_to_destination();
1952
               line_to_destination();
1952
               st_synchronize();
1953
               st_synchronize();
1953
               HOMEAXIS(Z);
1954
               HOMEAXIS(Z);
2571
  */
2572
  */
2572
 inline void gcode_M17() {
2573
 inline void gcode_M17() {
2573
   LCD_MESSAGEPGM(MSG_NO_MOVE);
2574
   LCD_MESSAGEPGM(MSG_NO_MOVE);
2574
-  enable_x();
2575
-  enable_y();
2576
-  enable_z();
2577
-  enable_e0();
2578
-  enable_e1();
2579
-  enable_e2();
2580
-  enable_e3();
2575
+  enable_all_steppers();
2581
 }
2576
 }
2582
 
2577
 
2583
 #ifdef SDSUPPORT
2578
 #ifdef SDSUPPORT
3060
 inline void gcode_M105() {
3055
 inline void gcode_M105() {
3061
   if (setTargetedHotend(105)) return;
3056
   if (setTargetedHotend(105)) return;
3062
 
3057
 
3063
-  #if HAS_TEMP_0
3064
-    SERIAL_PROTOCOLPGM("ok T:");
3065
-    SERIAL_PROTOCOL_F(degHotend(target_extruder),1);
3066
-    SERIAL_PROTOCOLPGM(" /");
3067
-    SERIAL_PROTOCOL_F(degTargetHotend(target_extruder),1);
3058
+  #if HAS_TEMP_0 || HAS_TEMP_BED
3059
+    SERIAL_PROTOCOLPGM("ok");
3060
+    #if HAS_TEMP_0
3061
+      SERIAL_PROTOCOLPGM(" T:");
3062
+      SERIAL_PROTOCOL_F(degHotend(tmp_extruder), 1);
3063
+      SERIAL_PROTOCOLPGM(" /");
3064
+      SERIAL_PROTOCOL_F(degTargetHotend(tmp_extruder), 1);
3065
+    #endif
3068
     #if HAS_TEMP_BED
3066
     #if HAS_TEMP_BED
3069
       SERIAL_PROTOCOLPGM(" B:");
3067
       SERIAL_PROTOCOLPGM(" B:");
3070
-      SERIAL_PROTOCOL_F(degBed(),1);
3068
+      SERIAL_PROTOCOL_F(degBed(), 1);
3071
       SERIAL_PROTOCOLPGM(" /");
3069
       SERIAL_PROTOCOLPGM(" /");
3072
-      SERIAL_PROTOCOL_F(degTargetBed(),1);
3073
-    #endif // HAS_TEMP_BED
3074
-    for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
3070
+      SERIAL_PROTOCOL_F(degTargetBed(), 1);
3071
+    #endif
3072
+    for (int8_t e = 0; e < EXTRUDERS; ++e) {
3075
       SERIAL_PROTOCOLPGM(" T");
3073
       SERIAL_PROTOCOLPGM(" T");
3076
-      SERIAL_PROTOCOL(cur_extruder);
3074
+      SERIAL_PROTOCOL(e);
3077
       SERIAL_PROTOCOLCHAR(':');
3075
       SERIAL_PROTOCOLCHAR(':');
3078
-      SERIAL_PROTOCOL_F(degHotend(cur_extruder),1);
3076
+      SERIAL_PROTOCOL_F(degHotend(e), 1);
3079
       SERIAL_PROTOCOLPGM(" /");
3077
       SERIAL_PROTOCOLPGM(" /");
3080
-      SERIAL_PROTOCOL_F(degTargetHotend(cur_extruder),1);
3078
+      SERIAL_PROTOCOL_F(degTargetHotend(e), 1);
3081
     }
3079
     }
3082
-  #else // !HAS_TEMP_0
3080
+  #else // !HAS_TEMP_0 && !HAS_TEMP_BED
3083
     SERIAL_ERROR_START;
3081
     SERIAL_ERROR_START;
3084
     SERIAL_ERRORLNPGM(MSG_ERR_NO_THERMISTORS);
3082
     SERIAL_ERRORLNPGM(MSG_ERR_NO_THERMISTORS);
3085
   #endif
3083
   #endif
3117
     }
3115
     }
3118
   #endif
3116
   #endif
3119
 
3117
 
3120
-  SERIAL_PROTOCOLLN("");
3118
+  SERIAL_EOL;
3121
 }
3119
 }
3122
 
3120
 
3123
 #if HAS_FAN
3121
 #if HAS_FAN
3132
    */
3130
    */
3133
   inline void gcode_M107() { fanSpeed = 0; }
3131
   inline void gcode_M107() { fanSpeed = 0; }
3134
 
3132
 
3135
-#endif //FAN_PIN
3133
+#endif // HAS_FAN
3136
 
3134
 
3137
 /**
3135
 /**
3138
  * M109: Wait for extruder(s) to reach temperature
3136
  * M109: Wait for extruder(s) to reach temperature
3191
             SERIAL_PROTOCOLLN( timetemp );
3189
             SERIAL_PROTOCOLLN( timetemp );
3192
           }
3190
           }
3193
           else {
3191
           else {
3194
-            SERIAL_PROTOCOLLN( "?" );
3192
+            SERIAL_PROTOCOLLNPGM("?");
3195
           }
3193
           }
3196
         #else
3194
         #else
3197
-          SERIAL_PROTOCOLLN("");
3195
+          SERIAL_EOL;
3198
         #endif
3196
         #endif
3199
         timetemp = millis();
3197
         timetemp = millis();
3200
       }
3198
       }
3246
         SERIAL_PROTOCOL((int)active_extruder);
3244
         SERIAL_PROTOCOL((int)active_extruder);
3247
         SERIAL_PROTOCOLPGM(" B:");
3245
         SERIAL_PROTOCOLPGM(" B:");
3248
         SERIAL_PROTOCOL_F(degBed(), 1);
3246
         SERIAL_PROTOCOL_F(degBed(), 1);
3249
-        SERIAL_PROTOCOLLN("");
3247
+        SERIAL_EOL;
3250
       }
3248
       }
3251
       manage_heater();
3249
       manage_heater();
3252
       manage_inactivity();
3250
       manage_inactivity();
3447
   SERIAL_PROTOCOLPGM(" Z:");
3445
   SERIAL_PROTOCOLPGM(" Z:");
3448
   SERIAL_PROTOCOL(float(st_get_position(Z_AXIS))/axis_steps_per_unit[Z_AXIS]);
3446
   SERIAL_PROTOCOL(float(st_get_position(Z_AXIS))/axis_steps_per_unit[Z_AXIS]);
3449
 
3447
 
3450
-  SERIAL_PROTOCOLLN("");
3448
+  SERIAL_EOL;
3451
 
3449
 
3452
   #ifdef SCARA
3450
   #ifdef SCARA
3453
     SERIAL_PROTOCOLPGM("SCARA Theta:");
3451
     SERIAL_PROTOCOLPGM("SCARA Theta:");
3454
     SERIAL_PROTOCOL(delta[X_AXIS]);
3452
     SERIAL_PROTOCOL(delta[X_AXIS]);
3455
     SERIAL_PROTOCOLPGM("   Psi+Theta:");
3453
     SERIAL_PROTOCOLPGM("   Psi+Theta:");
3456
     SERIAL_PROTOCOL(delta[Y_AXIS]);
3454
     SERIAL_PROTOCOL(delta[Y_AXIS]);
3457
-    SERIAL_PROTOCOLLN("");
3455
+    SERIAL_EOL;
3458
     
3456
     
3459
     SERIAL_PROTOCOLPGM("SCARA Cal - Theta:");
3457
     SERIAL_PROTOCOLPGM("SCARA Cal - Theta:");
3460
     SERIAL_PROTOCOL(delta[X_AXIS]+home_offset[X_AXIS]);
3458
     SERIAL_PROTOCOL(delta[X_AXIS]+home_offset[X_AXIS]);
3461
     SERIAL_PROTOCOLPGM("   Psi+Theta (90):");
3459
     SERIAL_PROTOCOLPGM("   Psi+Theta (90):");
3462
     SERIAL_PROTOCOL(delta[Y_AXIS]-delta[X_AXIS]-90+home_offset[Y_AXIS]);
3460
     SERIAL_PROTOCOL(delta[Y_AXIS]-delta[X_AXIS]-90+home_offset[Y_AXIS]);
3463
-    SERIAL_PROTOCOLLN("");
3461
+    SERIAL_EOL;
3464
     
3462
     
3465
     SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:");
3463
     SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:");
3466
     SERIAL_PROTOCOL(delta[X_AXIS]/90*axis_steps_per_unit[X_AXIS]);
3464
     SERIAL_PROTOCOL(delta[X_AXIS]/90*axis_steps_per_unit[X_AXIS]);
3467
     SERIAL_PROTOCOLPGM("   Psi+Theta:");
3465
     SERIAL_PROTOCOLPGM("   Psi+Theta:");
3468
     SERIAL_PROTOCOL((delta[Y_AXIS]-delta[X_AXIS])/90*axis_steps_per_unit[Y_AXIS]);
3466
     SERIAL_PROTOCOL((delta[Y_AXIS]-delta[X_AXIS])/90*axis_steps_per_unit[Y_AXIS]);
3469
-    SERIAL_PROTOCOLLN("");
3470
-    SERIAL_PROTOCOLLN("");
3467
+    SERIAL_EOL; SERIAL_EOL;
3471
   #endif
3468
   #endif
3472
 }
3469
 }
3473
 
3470
 
3909
       SERIAL_PROTOCOL(servo_index);
3906
       SERIAL_PROTOCOL(servo_index);
3910
       SERIAL_PROTOCOL(": ");
3907
       SERIAL_PROTOCOL(": ");
3911
       SERIAL_PROTOCOL(servos[servo_index].read());
3908
       SERIAL_PROTOCOL(servos[servo_index].read());
3912
-      SERIAL_PROTOCOLLN("");
3909
+      SERIAL_EOL;
3913
     }
3910
     }
3914
   }
3911
   }
3915
 
3912
 
3977
         //Kc does not have scaling applied above, or in resetting defaults
3974
         //Kc does not have scaling applied above, or in resetting defaults
3978
         SERIAL_PROTOCOL(PID_PARAM(Kc, e));
3975
         SERIAL_PROTOCOL(PID_PARAM(Kc, e));
3979
       #endif
3976
       #endif
3980
-      SERIAL_PROTOCOLLN("");    
3977
+      SERIAL_EOL;    
3981
     }
3978
     }
3982
     else {
3979
     else {
3983
       SERIAL_ECHO_START;
3980
       SERIAL_ECHO_START;
4002
     SERIAL_PROTOCOL(unscalePID_i(bedKi));
3999
     SERIAL_PROTOCOL(unscalePID_i(bedKi));
4003
     SERIAL_PROTOCOL(" d:");
4000
     SERIAL_PROTOCOL(" d:");
4004
     SERIAL_PROTOCOL(unscalePID_d(bedKd));
4001
     SERIAL_PROTOCOL(unscalePID_d(bedKd));
4005
-    SERIAL_PROTOCOLLN("");
4002
+    SERIAL_EOL;
4006
   }
4003
   }
4007
 
4004
 
4008
 #endif // PIDTEMPBED
4005
 #endif // PIDTEMPBED
4052
     if (code_seen('C')) lcd_setcontrast(code_value_short() & 0x3F);
4049
     if (code_seen('C')) lcd_setcontrast(code_value_short() & 0x3F);
4053
     SERIAL_PROTOCOLPGM("lcd contrast value: ");
4050
     SERIAL_PROTOCOLPGM("lcd contrast value: ");
4054
     SERIAL_PROTOCOL(lcd_contrast);
4051
     SERIAL_PROTOCOL(lcd_contrast);
4055
-    SERIAL_PROTOCOLLN("");
4052
+    SERIAL_EOL;
4056
   }
4053
   }
4057
 
4054
 
4058
 #endif // DOGLCD
4055
 #endif // DOGLCD
4325
         zprobe_zoffset = -value; // compare w/ line 278 of ConfigurationStore.cpp
4322
         zprobe_zoffset = -value; // compare w/ line 278 of ConfigurationStore.cpp
4326
         SERIAL_ECHO_START;
4323
         SERIAL_ECHO_START;
4327
         SERIAL_ECHOLNPGM(MSG_ZPROBE_ZOFFSET " " MSG_OK);
4324
         SERIAL_ECHOLNPGM(MSG_ZPROBE_ZOFFSET " " MSG_OK);
4328
-        SERIAL_PROTOCOLLN("");
4325
+        SERIAL_EOL;
4329
       }
4326
       }
4330
       else {
4327
       else {
4331
         SERIAL_ECHO_START;
4328
         SERIAL_ECHO_START;
4334
         SERIAL_ECHO(Z_PROBE_OFFSET_RANGE_MIN);
4331
         SERIAL_ECHO(Z_PROBE_OFFSET_RANGE_MIN);
4335
         SERIAL_ECHOPGM(MSG_Z_MAX);
4332
         SERIAL_ECHOPGM(MSG_Z_MAX);
4336
         SERIAL_ECHO(Z_PROBE_OFFSET_RANGE_MAX);
4333
         SERIAL_ECHO(Z_PROBE_OFFSET_RANGE_MAX);
4337
-        SERIAL_PROTOCOLLN("");
4334
+        SERIAL_EOL;
4338
       }
4335
       }
4339
     }
4336
     }
4340
     else {
4337
     else {
4341
       SERIAL_ECHO_START;
4338
       SERIAL_ECHO_START;
4342
       SERIAL_ECHOLNPGM(MSG_ZPROBE_ZOFFSET " : ");
4339
       SERIAL_ECHOLNPGM(MSG_ZPROBE_ZOFFSET " : ");
4343
       SERIAL_ECHO(-zprobe_zoffset);
4340
       SERIAL_ECHO(-zprobe_zoffset);
4344
-      SERIAL_PROTOCOLLN("");
4341
+      SERIAL_EOL;
4345
     }
4342
     }
4346
   }
4343
   }
4347
 
4344
 
5700
 }
5697
 }
5701
 #endif
5698
 #endif
5702
 
5699
 
5703
-void disable_all_axes() {
5700
+void enable_all_steppers() {
5701
+  enable_x();
5702
+  enable_y();
5703
+  enable_z();
5704
+  enable_e0();
5705
+  enable_e1();
5706
+  enable_e2();
5707
+  enable_e3();
5708
+}
5709
+
5710
+void disable_all_steppers() {
5704
   disable_x();
5711
   disable_x();
5705
   disable_y();
5712
   disable_y();
5706
   disable_z();
5713
   disable_z();
5728
 
5735
 
5729
   if (stepper_inactive_time && ms > previous_millis_cmd + stepper_inactive_time
5736
   if (stepper_inactive_time && ms > previous_millis_cmd + stepper_inactive_time
5730
       && !ignore_stepper_queue && !blocks_queued())
5737
       && !ignore_stepper_queue && !blocks_queued())
5731
-    disable_all_axes();
5738
+    disable_all_steppers();
5732
 
5739
 
5733
   #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH
5740
   #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH
5734
     if (chdkActive && ms > chdkHigh + CHDK_DELAY) {
5741
     if (chdkActive && ms > chdkHigh + CHDK_DELAY) {
5816
   cli(); // Stop interrupts
5823
   cli(); // Stop interrupts
5817
   disable_heater();
5824
   disable_heater();
5818
 
5825
 
5819
-  disable_all_axes();
5826
+  disable_all_steppers();
5820
 
5827
 
5821
   #if HAS_POWER_SWITCH
5828
   #if HAS_POWER_SWITCH
5822
     pinMode(PS_ON_PIN, INPUT);
5829
     pinMode(PS_ON_PIN, INPUT);

+ 1
- 1
Marlin/planner.cpp View File

67
 //===========================================================================
67
 //===========================================================================
68
 
68
 
69
 unsigned long minsegmenttime;
69
 unsigned long minsegmenttime;
70
-float max_feedrate[NUM_AXIS]; // set the max speeds
70
+float max_feedrate[NUM_AXIS]; // Max speeds in mm per minute
71
 float axis_steps_per_unit[NUM_AXIS];
71
 float axis_steps_per_unit[NUM_AXIS];
72
 unsigned long max_acceleration_units_per_sq_second[NUM_AXIS]; // Use M201 to override by software
72
 unsigned long max_acceleration_units_per_sq_second[NUM_AXIS]; // Use M201 to override by software
73
 float minimumfeedrate;
73
 float minimumfeedrate;

+ 1
- 7
Marlin/stepper.cpp View File

1127
 
1127
 
1128
 void finishAndDisableSteppers() {
1128
 void finishAndDisableSteppers() {
1129
   st_synchronize();
1129
   st_synchronize();
1130
-  disable_x();
1131
-  disable_y();
1132
-  disable_z();
1133
-  disable_e0();
1134
-  disable_e1();
1135
-  disable_e2();
1136
-  disable_e3();
1130
+  disable_all_steppers();
1137
 }
1131
 }
1138
 
1132
 
1139
 void quickStop() {
1133
 void quickStop() {

+ 76
- 79
Marlin/temperature.cpp View File

1
 /*
1
 /*
2
-  temperature.c - temperature control
2
+  temperature.cpp - temperature control
3
   Part of Marlin
3
   Part of Marlin
4
   
4
   
5
  Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
5
  Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
16
  
16
  
17
  You should have received a copy of the GNU General Public License
17
  You should have received a copy of the GNU General Public License
18
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
- */
20
-
21
-/*
22
- This firmware is a mashup between Sprinter and grbl.
23
-  (https://github.com/kliment/Sprinter)
24
-  (https://github.com/simen/grbl/tree)
25
- 
26
- It has preliminary support for Matthew Roberts advance algorithm 
27
-    http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
28
-
29
- */
30
-
19
+*/
31
 
20
 
32
 #include "Marlin.h"
21
 #include "Marlin.h"
33
 #include "ultralcd.h"
22
 #include "ultralcd.h"
87
 #define HAS_HEATER_THERMAL_PROTECTION (defined(THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0)
76
 #define HAS_HEATER_THERMAL_PROTECTION (defined(THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0)
88
 #define HAS_BED_THERMAL_PROTECTION (defined(THERMAL_RUNAWAY_PROTECTION_BED_PERIOD) && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0 && TEMP_SENSOR_BED != 0)
77
 #define HAS_BED_THERMAL_PROTECTION (defined(THERMAL_RUNAWAY_PROTECTION_BED_PERIOD) && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0 && TEMP_SENSOR_BED != 0)
89
 #if HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION
78
 #if HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION
79
+  enum TRState { TRInactive, TRFirstHeating, TRStable };
90
   static bool thermal_runaway = false;
80
   static bool thermal_runaway = false;
91
-  void thermal_runaway_protection(int *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc);
81
+  void thermal_runaway_protection(TRState *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc);
92
   #if HAS_HEATER_THERMAL_PROTECTION
82
   #if HAS_HEATER_THERMAL_PROTECTION
93
-    static int thermal_runaway_state_machine[4]; // = {0,0,0,0};
83
+    static TRState thermal_runaway_state_machine[4] = { TRInactive, TRInactive, TRInactive, TRInactive };
94
     static unsigned long thermal_runaway_timer[4]; // = {0,0,0,0};
84
     static unsigned long thermal_runaway_timer[4]; // = {0,0,0,0};
95
   #endif
85
   #endif
96
   #if HAS_BED_THERMAL_PROTECTION
86
   #if HAS_BED_THERMAL_PROTECTION
97
-    static int thermal_runaway_bed_state_machine;
87
+    static TRState thermal_runaway_bed_state_machine = { TRInactive, TRInactive, TRInactive, TRInactive };
98
     static unsigned long thermal_runaway_bed_timer;
88
     static unsigned long thermal_runaway_bed_timer;
99
   #endif
89
   #endif
100
 #endif
90
 #endif
238
     soft_pwm[extruder] = bias = d = PID_MAX / 2;
228
     soft_pwm[extruder] = bias = d = PID_MAX / 2;
239
 
229
 
240
   // PID Tuning loop
230
   // PID Tuning loop
241
-  for(;;) {
231
+  for (;;) {
242
 
232
 
243
     unsigned long ms = millis();
233
     unsigned long ms = millis();
244
 
234
 
609
   // Loop through all extruders
599
   // Loop through all extruders
610
   for (int e = 0; e < EXTRUDERS; e++) {
600
   for (int e = 0; e < EXTRUDERS; e++) {
611
 
601
 
612
-    #if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0
602
+    #if HAS_HEATER_THERMAL_PROTECTION
613
       thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_RUNAWAY_PROTECTION_PERIOD, THERMAL_RUNAWAY_PROTECTION_HYSTERESIS);
603
       thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_RUNAWAY_PROTECTION_PERIOD, THERMAL_RUNAWAY_PROTECTION_HYSTERESIS);
614
     #endif
604
     #endif
615
 
605
 
637
         disable_heater();
627
         disable_heater();
638
         _temp_error(0, PSTR(MSG_EXTRUDER_SWITCHED_OFF), PSTR(MSG_ERR_REDUNDANT_TEMP));
628
         _temp_error(0, PSTR(MSG_EXTRUDER_SWITCHED_OFF), PSTR(MSG_ERR_REDUNDANT_TEMP));
639
       }
629
       }
640
-    #endif //TEMP_SENSOR_1_AS_REDUNDANT
630
+    #endif // TEMP_SENSOR_1_AS_REDUNDANT
641
 
631
 
642
   } // Extruders Loop
632
   } // Extruders Loop
643
 
633
 
656
   #if TEMP_SENSOR_BED != 0
646
   #if TEMP_SENSOR_BED != 0
657
   
647
   
658
     #if HAS_BED_THERMAL_PROTECTION
648
     #if HAS_BED_THERMAL_PROTECTION
659
-      thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, 9, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS);
649
+      thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, -1, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS);
660
     #endif
650
     #endif
661
 
651
 
662
     #ifdef PIDTEMPBED
652
     #ifdef PIDTEMPBED
1014
 }
1004
 }
1015
 
1005
 
1016
 #if HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION
1006
 #if HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION
1017
-void thermal_runaway_protection(int *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc)
1018
-{
1019
-/*
1020
-      SERIAL_ECHO_START;
1021
-      SERIAL_ECHO("Thermal Thermal Runaway Running. Heater ID:");
1022
-      SERIAL_ECHO(heater_id);
1023
-      SERIAL_ECHO(" ;  State:");
1024
-      SERIAL_ECHO(*state);
1025
-      SERIAL_ECHO(" ;  Timer:");
1026
-      SERIAL_ECHO(*timer);
1027
-      SERIAL_ECHO(" ;  Temperature:");
1028
-      SERIAL_ECHO(temperature);
1029
-      SERIAL_ECHO(" ;  Target Temp:");
1030
-      SERIAL_ECHO(target_temperature);
1031
-      SERIAL_ECHOLN("");    
1032
-*/
1033
-  if ((target_temperature == 0) || thermal_runaway)
1034
-  {
1035
-    *state = 0;
1036
-    *timer = 0;
1037
-    return;
1038
-  }
1039
-  switch (*state)
1040
-  {
1041
-    case 0: // "Heater Inactive" state
1042
-      if (target_temperature > 0) *state = 1;
1043
-      break;
1044
-    case 1: // "First Heating" state
1045
-      if (temperature >= target_temperature) *state = 2;
1046
-      break;
1047
-    case 2: // "Temperature Stable" state
1048
-    {
1049
-      unsigned long ms = millis();
1050
-      if (temperature >= (target_temperature - hysteresis_degc))
1051
-      {
1052
-        *timer = ms;
1053
-      } 
1054
-      else if ( (ms - *timer) > ((unsigned long) period_seconds) * 1000)
1007
+
1008
+  void thermal_runaway_protection(TRState *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) {
1009
+
1010
+    static int tr_target_temperature[EXTRUDERS+1];
1011
+
1012
+    /*
1013
+        SERIAL_ECHO_START;
1014
+        SERIAL_ECHOPGM("Thermal Thermal Runaway Running. Heater ID: ");
1015
+        if (heater_id < 0) SERIAL_ECHOPGM("bed"); else SERIAL_ECHOPGM(heater_id);
1016
+        SERIAL_ECHOPGM(" ;  State:");
1017
+        SERIAL_ECHOPGM(*state);
1018
+        SERIAL_ECHOPGM(" ;  Timer:");
1019
+        SERIAL_ECHOPGM(*timer);
1020
+        SERIAL_ECHOPGM(" ;  Temperature:");
1021
+        SERIAL_ECHOPGM(temperature);
1022
+        SERIAL_ECHOPGM(" ;  Target Temp:");
1023
+        SERIAL_ECHOPGM(target_temperature);
1024
+        SERIAL_EOL;
1025
+    */
1026
+    if (target_temperature == 0 || thermal_runaway) {
1027
+      *state = TRInactive;
1028
+      *timer = 0;
1029
+      return;
1030
+    }
1031
+
1032
+    int heater_index = heater_id >= 0 ? heater_id : EXTRUDERS;
1033
+
1034
+    switch (*state) {
1035
+      // Inactive state waits for a target temperature to be set
1036
+      case TRInactive:
1037
+        if (target_temperature > 0) {
1038
+          *state = TRFirstHeating;
1039
+          tr_target_temperature[heater_index] = target_temperature;
1040
+        }
1041
+        break;
1042
+      // When first heating, wait for the temperature to be reached then go to Stable state
1043
+      case TRFirstHeating:
1044
+        if (temperature >= tr_target_temperature[heater_index]) *state = TRStable;
1045
+        break;
1046
+      // While the temperature is stable watch for a bad temperature
1047
+      case TRStable:
1055
       {
1048
       {
1056
-        SERIAL_ERROR_START;
1057
-        SERIAL_ERRORLNPGM(MSG_THERMAL_RUNAWAY_STOP);
1058
-        SERIAL_ERRORLN((int)heater_id);
1059
-        LCD_ALERTMESSAGEPGM(MSG_THERMAL_RUNAWAY); // translatable
1060
-        thermal_runaway = true;
1061
-        while(1)
1062
-        {
1063
-          disable_heater();
1064
-          disable_x();
1065
-          disable_y();
1066
-          disable_z();
1067
-          disable_e0();
1068
-          disable_e1();
1069
-          disable_e2();
1070
-          disable_e3();
1071
-          manage_heater();
1072
-          lcd_update();
1049
+        // If the target temperature changes, restart
1050
+        if (tr_target_temperature[heater_index] != target_temperature) {
1051
+          *state = TRInactive;
1052
+          break;
1073
         }
1053
         }
1074
-      }
1075
-    } break;
1054
+
1055
+        // If the temperature is over the target (-hysteresis) restart the timer
1056
+        if (temperature >= tr_target_temperature[heater_index] - hysteresis_degc) *timer = millis();
1057
+
1058
+        // If the timer goes too long without a reset, trigger shutdown
1059
+        else if (millis() > *timer + period_seconds * 1000UL) {
1060
+          SERIAL_ERROR_START;
1061
+          SERIAL_ERRORLNPGM(MSG_THERMAL_RUNAWAY_STOP);
1062
+          if (heater_id < 0) SERIAL_ERRORLNPGM("bed"); else SERIAL_ERRORLN(heater_id);
1063
+          LCD_ALERTMESSAGEPGM(MSG_THERMAL_RUNAWAY);
1064
+          thermal_runaway = true;
1065
+          for (;;) {
1066
+            disable_heater();
1067
+            disable_all_steppers();
1068
+            manage_heater();
1069
+            lcd_update();
1070
+          }
1071
+        }
1072
+      } break;
1073
+    }
1076
   }
1074
   }
1077
-}
1078
-#endif //THERMAL_RUNAWAY_PROTECTION_PERIOD
1079
 
1075
 
1076
+#endif // HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION
1080
 
1077
 
1081
 void disable_heater() {
1078
 void disable_heater() {
1082
   for (int i=0; i<EXTRUDERS; i++) setTargetHotend(0, i);
1079
   for (int i=0; i<EXTRUDERS; i++) setTargetHotend(0, i);

+ 17
- 31
Marlin/temperature.h View File

18
   along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
18
   along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
19
 */
19
 */
20
 
20
 
21
-#ifndef temperature_h
22
-#define temperature_h 
21
+#ifndef TEMPERATURE_H
22
+#define TEMPERATURE_H 
23
 
23
 
24
 #include "Marlin.h"
24
 #include "Marlin.h"
25
 #include "planner.h"
25
 #include "planner.h"
72
   float unscalePID_d(float d);
72
   float unscalePID_d(float d);
73
 
73
 
74
 #endif
74
 #endif
75
+
75
 #ifdef PIDTEMPBED
76
 #ifdef PIDTEMPBED
76
   extern float bedKp,bedKi,bedKd;
77
   extern float bedKp,bedKi,bedKd;
77
 #endif
78
 #endif
78
   
79
   
79
-  
80
 #ifdef BABYSTEPPING
80
 #ifdef BABYSTEPPING
81
   extern volatile int babystepsTodo[3];
81
   extern volatile int babystepsTodo[3];
82
 #endif
82
 #endif
105
 FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { return target_temperature[extruder] < current_temperature[extruder]; }
105
 FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { return target_temperature[extruder] < current_temperature[extruder]; }
106
 FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; }
106
 FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; }
107
 
107
 
108
-#define degHotend0() degHotend(0)
109
-#define degTargetHotend0() degTargetHotend(0)
110
-#define setTargetHotend0(_celsius) setTargetHotend((_celsius), 0)
111
-#define isHeatingHotend0() isHeatingHotend(0)
112
-#define isCoolingHotend0() isCoolingHotend(0)
108
+#define HOTEND_ROUTINES(NR) \
109
+  FORCE_INLINE float degHotend##NR() { return degHotend(NR); } \
110
+  FORCE_INLINE float degTargetHotend##NR() { return degTargetHotend(NR); } \
111
+  FORCE_INLINE void setTargetHotend##NR(const float c) { setTargetHotend(c, NR); } \
112
+  FORCE_INLINE bool isHeatingHotend##NR() { return isHeatingHotend(NR); } \
113
+  FORCE_INLINE bool isCoolingHotend##NR() { return isCoolingHotend(NR); }
114
+HOTEND_ROUTINES(0);
113
 #if EXTRUDERS > 1
115
 #if EXTRUDERS > 1
114
-  #define degHotend1() degHotend(1)
115
-  #define degTargetHotend1() degTargetHotend(1)
116
-  #define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1)
117
-  #define isHeatingHotend1() isHeatingHotend(1)
118
-  #define isCoolingHotend1() isCoolingHotend(1)
116
+  HOTEND_ROUTINES(1);
119
 #else
117
 #else
120
-  #define setTargetHotend1(_celsius) do{}while(0)
118
+  #define setTargetHotend1(c) do{}while(0)
121
 #endif
119
 #endif
122
 #if EXTRUDERS > 2
120
 #if EXTRUDERS > 2
123
-  #define degHotend2() degHotend(2)
124
-  #define degTargetHotend2() degTargetHotend(2)
125
-  #define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2)
126
-  #define isHeatingHotend2() isHeatingHotend(2)
127
-  #define isCoolingHotend2() isCoolingHotend(2)
121
+  HOTEND_ROUTINES(2);
128
 #else
122
 #else
129
-  #define setTargetHotend2(_celsius) do{}while(0)
123
+  #define setTargetHotend2(c) do{}while(0)
130
 #endif
124
 #endif
131
 #if EXTRUDERS > 3
125
 #if EXTRUDERS > 3
132
-  #define degHotend3() degHotend(3)
133
-  #define degTargetHotend3() degTargetHotend(3)
134
-  #define setTargetHotend3(_celsius) setTargetHotend((_celsius), 3)
135
-  #define isHeatingHotend3() isHeatingHotend(3)
136
-  #define isCoolingHotend3() isCoolingHotend(3)
126
+  HOTEND_ROUTINES(3);
137
 #else
127
 #else
138
-  #define setTargetHotend3(_celsius) do{}while(0)
139
-#endif
140
-#if EXTRUDERS > 4
141
-  #error Invalid number of extruders
128
+  #define setTargetHotend3(c) do{}while(0)
142
 #endif
129
 #endif
143
 
130
 
144
 int getHeaterPower(int heater);
131
 int getHeaterPower(int heater);
161
   #endif
148
   #endif
162
 }
149
 }
163
 
150
 
164
-
165
-#endif
151
+#endif // TEMPERATURE_H

+ 5
- 5
README.md View File

18
 ## Quick Information
18
 ## Quick Information
19
 
19
 
20
 This is a firmware for reprap single-processor electronics setups.
20
 This is a firmware for reprap single-processor electronics setups.
21
-It also works on the Ultimaker PCB. It supports printing from SD card+Folders, and look-ahead trajectory planning.
22
-This firmware is a mashup between [Sprinter](https://github.com/kliment/Sprinter), [grbl](https://github.com/simen/grbl) and many original parts.
21
+It also works on the Ultimaker PCB. It supports printing from SD card+Folders and look-ahead trajectory planning.
22
+This firmware is a mashup between [Sprinter](https://github.com/kliment/Sprinter), [grbl](https://github.com/simen/grbl), and many original parts.
23
 
23
 
24
 ## Current Status: Bug Fixing
24
 ## Current Status: Bug Fixing
25
 
25
 
31
 
31
 
32
 ## Contact
32
 ## Contact
33
 
33
 
34
-__IRC:__ #marlin-firmware @freenode ([WebChat Client](https://webchat.freenode.net/?channels=marlin-firmware)
34
+__IRC:__ #marlin-firmware @freenode ([WebChat Client](https://webchat.freenode.net/?channels=marlin-firmware))
35
 
35
 
36
 ## Credits
36
 ## Credits
37
 
37
 
41
  - [@daid](https://github.com/daid)
41
  - [@daid](https://github.com/daid)
42
 
42
 
43
 Sprinters lead developers are Kliment and caru.
43
 Sprinters lead developers are Kliment and caru.
44
-Grbls lead developer is Simen Svale Skogsrud.
45
-Sonney Jeon (Chamnit) improved some parts of grbl
44
+Grbl's lead developer is Simen Svale Skogsrud.
45
+Sonney Jeon (Chamnit) improved some parts of grbl.
46
 A fork by bkubicek for the Ultimaker was merged.
46
 A fork by bkubicek for the Ultimaker was merged.
47
 
47
 
48
 More features have been added by:
48
 More features have been added by:

Loading…
Cancel
Save