Browse Source

Merge branch 'Development' into pr-felix

chrono 10 years ago
parent
commit
c13d81ce15

+ 1
- 8
Marlin/BlinkM.cpp View File

@@ -5,16 +5,9 @@
5 5
 #include "Marlin.h"
6 6
 #ifdef BLINKM
7 7
 
8
-#if (ARDUINO >= 100)
9
-  # include "Arduino.h"
10
-#else
11
-  # include "WProgram.h"
12
-#endif
13
-
14 8
 #include "BlinkM.h"
15 9
 
16
-void SendColors(byte red, byte grn, byte blu)
17
-{
10
+void SendColors(byte red, byte grn, byte blu) {
18 11
   Wire.begin(); 
19 12
   Wire.beginTransmission(0x09);
20 13
   Wire.write('o');                    //to disable ongoing script, only needs to be used once

+ 3
- 4
Marlin/BlinkM.h View File

@@ -2,13 +2,12 @@
2 2
   BlinkM.h
3 3
   Library header file for BlinkM library
4 4
  */
5
-#if (ARDUINO >= 100)
6
-  # include "Arduino.h"
5
+#if ARDUINO >= 100
6
+  #include "Arduino.h"
7 7
 #else
8
-  # include "WProgram.h"
8
+  #include "WProgram.h"
9 9
 #endif
10 10
 
11 11
 #include "Wire.h"
12 12
 
13 13
 void SendColors(byte red, byte grn, byte blu);
14
-

+ 44
- 57
Marlin/Configuration.h View File

@@ -8,7 +8,7 @@
8 8
 //===========================================================================
9 9
 /*
10 10
 Here are some standard links for getting your machine calibrated:
11
- * http://reprap.org/wiki/Calibration 
11
+ * http://reprap.org/wiki/Calibration
12 12
  * http://youtu.be/wAL9d7FgInk
13 13
  * http://calculator.josefprusa.cz
14 14
  * http://reprap.org/wiki/Triffid_Hunter%27s_Calibration_Guide
@@ -59,7 +59,7 @@ Here are some standard links for getting your machine calibrated:
59 59
 // The following define selects which electronics board you have.
60 60
 // Please choose the name from boards.h that matches your setup
61 61
 #ifndef MOTHERBOARD
62
-  #define MOTHERBOARD BOARD_ULTIMAKER
62
+  #define MOTHERBOARD BOARD_FELIX2
63 63
 #endif
64 64
 
65 65
 // Define this to set a custom name for your generic Mendel,
@@ -70,7 +70,7 @@ Here are some standard links for getting your machine calibrated:
70 70
 // #define MACHINE_UUID "00000000-0000-0000-0000-000000000000"
71 71
 
72 72
 // This defines the number of extruders
73
-#define EXTRUDERS 1
73
+#define EXTRUDERS 2
74 74
 
75 75
 //// The following define selects which power supply you have. Please choose the one that matches your setup
76 76
 // 1 = ATX
@@ -79,7 +79,7 @@ Here are some standard links for getting your machine calibrated:
79 79
 #define POWER_SUPPLY 1
80 80
 
81 81
 // Define this to have the electronics keep the power supply off on startup. If you don't know what this is leave it.
82
-// #define PS_DEFAULT_OFF
82
+#define PS_DEFAULT_OFF
83 83
 
84 84
 //===========================================================================
85 85
 //============================= Thermal Settings ============================
@@ -104,7 +104,7 @@ Here are some standard links for getting your machine calibrated:
104 104
 // 10 is 100k RS thermistor 198-961 (4.7k pullup)
105 105
 // 11 is 100k beta 3950 1% thermistor (4.7k pullup)
106 106
 // 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed)
107
-// 13 is 100k Hisens 3950  1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" 
107
+// 13 is 100k Hisens 3950  1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE"
108 108
 // 20 is the PT100 circuit found in the Ultimainboard V2.x
109 109
 // 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950
110 110
 //
@@ -118,23 +118,23 @@ Here are some standard links for getting your machine calibrated:
118 118
 // 1010 is Pt1000 with 1k pullup (non standard)
119 119
 // 147 is Pt100 with 4k7 pullup
120 120
 // 110 is Pt100 with 1k pullup (non standard)
121
-// 998 and 999 are Dummy Tables. They will ALWAYS read 25°C or the temperature defined below. 
121
+// 998 and 999 are Dummy Tables. They will ALWAYS read 25°C or the temperature defined below.
122 122
 //     Use it for Testing or Development purposes. NEVER for production machine.
123 123
 //     #define DUMMY_THERMISTOR_998_VALUE 25
124 124
 //     #define DUMMY_THERMISTOR_999_VALUE 100
125 125
 
126
-#define TEMP_SENSOR_0 -1
127
-#define TEMP_SENSOR_1 -1
126
+#define TEMP_SENSOR_0 1
127
+#define TEMP_SENSOR_1 1
128 128
 #define TEMP_SENSOR_2 0
129 129
 #define TEMP_SENSOR_3 0
130
-#define TEMP_SENSOR_BED 0
130
+#define TEMP_SENSOR_BED 1
131 131
 
132 132
 // This makes temp sensor 1 a redundant sensor for sensor 0. If the temperatures difference between these sensors is to high the print will be aborted.
133 133
 //#define TEMP_SENSOR_1_AS_REDUNDANT
134 134
 #define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
135 135
 
136 136
 // Actual temperature must be close to target for this long before M109 returns success
137
-#define TEMP_RESIDENCY_TIME 10  // (seconds)
137
+#define TEMP_RESIDENCY_TIME 15  // (seconds)
138 138
 #define TEMP_HYSTERESIS 3       // (degC) range of +/- temperatures considered "close" to the target one
139 139
 #define TEMP_WINDOW     1       // (degC) Window around target to start the residency timer x degC early.
140 140
 
@@ -186,21 +186,11 @@ Here are some standard links for getting your machine calibrated:
186 186
   #define K1 0.95 //smoothing factor within the PID
187 187
   #define PID_dT ((OVERSAMPLENR * 10.0)/(F_CPU / 64.0 / 256.0)) //sampling period of the temperature routine
188 188
 
189
-// If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it
190
-// Ultimaker
191
-    #define  DEFAULT_Kp 22.2
192
-    #define  DEFAULT_Ki 1.08
193
-    #define  DEFAULT_Kd 114
194
-
195
-// MakerGear
196
-//    #define  DEFAULT_Kp 7.0
197
-//    #define  DEFAULT_Ki 0.1
198
-//    #define  DEFAULT_Kd 12
199
-
200
-// Mendel Parts V9 on 12V
201
-//    #define  DEFAULT_Kp 63.0
202
-//    #define  DEFAULT_Ki 2.25
203
-//    #define  DEFAULT_Kd 440
189
+  // Felix 2.0+ electronics with v4 Hotend
190
+  #define DEFAULT_Kp 12
191
+  #define DEFAULT_Ki 0.84
192
+  #define DEFAULT_Kd 85
193
+
204 194
 #endif // PIDTEMP
205 195
 
206 196
 //===========================================================================
@@ -263,15 +253,15 @@ The issue: If a thermistor come off, it will read a lower temperature than actua
263 253
 The system will turn the heater on forever, burning up the filament and anything
264 254
 else around.
265 255
 
266
-After the temperature reaches the target for the first time, this feature will 
267
-start measuring for how long the current temperature stays below the target 
256
+After the temperature reaches the target for the first time, this feature will
257
+start measuring for how long the current temperature stays below the target
268 258
 minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS).
269 259
 
270 260
 If it stays longer than _PERIOD, it means the thermistor temperature
271 261
 cannot catch up with the target, so something *may be* wrong. Then, to be on the
272 262
 safe side, the system will he halt.
273 263
 
274
-Bear in mind the count down will just start AFTER the first time the 
264
+Bear in mind the count down will just start AFTER the first time the
275 265
 thermistor temperature is over the target, so you will have no problem if
276 266
 your extruder heater takes 2 minutes to hit the target on heating.
277 267
 
@@ -321,13 +311,13 @@ your extruder heater takes 2 minutes to hit the target on heating.
321 311
 #endif
322 312
 
323 313
 // The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
324
-const bool X_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
325
-const bool Y_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
326
-const bool Z_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
314
+const bool X_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
315
+const bool Y_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
316
+const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
327 317
 const bool X_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
328 318
 const bool Y_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
329 319
 const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
330
-//#define DISABLE_MAX_ENDSTOPS
320
+#define DISABLE_MAX_ENDSTOPS
331 321
 //#define DISABLE_MIN_ENDSTOPS
332 322
 
333 323
 // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
@@ -344,7 +334,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
344 334
 #define DISABLE_INACTIVE_EXTRUDER true //disable only inactive extruders and keep active extruder enabled
345 335
 
346 336
 #define INVERT_X_DIR true     // for Mendel set to false, for Orca set to true
347
-#define INVERT_Y_DIR false    // for Mendel set to true, for Orca set to false
337
+#define INVERT_Y_DIR true    // for Mendel set to true, for Orca set to false
348 338
 #define INVERT_Z_DIR true     // for Mendel set to false, for Orca set to true
349 339
 #define INVERT_E0_DIR false   // for direct drive extruder v9 set to true, for geared extruder set to false
350 340
 #define INVERT_E1_DIR false   // for direct drive extruder v9 set to true, for geared extruder set to false
@@ -361,11 +351,11 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
361 351
 #define max_software_endstops true  // If true, axis won't move to coordinates greater than the defined lengths below.
362 352
 
363 353
 // Travel limits after homing (units are in mm)
364
-#define X_MAX_POS 205
354
+#define X_MAX_POS 245
365 355
 #define X_MIN_POS 0
366 356
 #define Y_MAX_POS 205
367 357
 #define Y_MIN_POS 0
368
-#define Z_MAX_POS 200
358
+#define Z_MAX_POS 235
369 359
 #define Z_MIN_POS 0
370 360
 
371 361
 #define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS)
@@ -378,7 +368,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
378 368
 //===========================================================================
379 369
 
380 370
 //#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line)
381
-#define Z_PROBE_REPEATABILITY_TEST  // If not commented out, Z-Probe Repeatability test will be included if Auto Bed Leveling is Enabled.
371
+//#define Z_PROBE_REPEATABILITY_TEST  // If not commented out, Z-Probe Repeatability test will be included if Auto Bed Leveling is Enabled.
382 372
 
383 373
 #ifdef ENABLE_AUTO_BED_LEVELING
384 374
 
@@ -487,9 +477,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
487 477
 	  #endif
488 478
 	#endif
489 479
 
490
-	
480
+
491 481
   #endif
492
-  
482
+
493 483
 #endif // ENABLE_AUTO_BED_LEVELING
494 484
 
495 485
 
@@ -510,12 +500,13 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
510 500
 
511 501
 // default settings
512 502
 
513
-#define DEFAULT_AXIS_STEPS_PER_UNIT   {78.7402,78.7402,200.0*8/3,760*1.1}  // default steps per unit for Ultimaker
503
+// default steps per unit for Felix 2.0/3.0: 0.00249mm x/y rounding error with 3mm pitch HTD belt and 14 tooth pulleys. 0 z error.
504
+#define DEFAULT_AXIS_STEPS_PER_UNIT   {76.190476, 76.190476, 1600, 164}
514 505
 #define DEFAULT_MAX_FEEDRATE          {500, 500, 5, 25}    // (mm/sec)
515
-#define DEFAULT_MAX_ACCELERATION      {9000,9000,100,10000}    // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for Skeinforge 40+, for older versions raise them a lot.
506
+#define DEFAULT_MAX_ACCELERATION      {5000,5000,100,80000}    // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.
516 507
 
517
-#define DEFAULT_ACCELERATION          3000    // X, Y, Z and E max acceleration in mm/s^2 for printing moves
518
-#define DEFAULT_RETRACT_ACCELERATION  3000   // X, Y, Z and E max acceleration in mm/s^2 for retracts
508
+#define DEFAULT_ACCELERATION          1750 //1500    // X, Y, Z and E max acceleration in mm/s^2 for printing moves
509
+#define DEFAULT_RETRACT_ACCELERATION  5000   // X, Y, Z and E max acceleration in mm/s^2 for r retracts
519 510
 
520 511
 // Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
521 512
 // The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
@@ -524,8 +515,8 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
524 515
 // #define EXTRUDER_OFFSET_Y {0.0, 5.00}  // (in mm) for each extruder, offset of the hotend on the Y axis
525 516
 
526 517
 // The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously)
527
-#define DEFAULT_XYJERK                20.0    // (mm/sec)
528
-#define DEFAULT_ZJERK                 0.4     // (mm/sec)
518
+#define DEFAULT_XYJERK                10   // (mm/sec)
519
+#define DEFAULT_ZJERK                 0.3  //0.4   // (mm/sec)
529 520
 #define DEFAULT_EJERK                 5.0    // (mm/sec)
530 521
 
531 522
 
@@ -570,7 +561,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
570 561
 //#define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en)
571 562
 
572 563
 // Character based displays can have different extended charsets.
573
-#define DISPLAY_CHARSET_HD44780_JAPAN     // "ääööüüß23°"
564
+//#define DISPLAY_CHARSET_HD44780_JAPAN     // "ääööüüß23°"
574 565
 //#define DISPLAY_CHARSET_HD44780_WESTERN // "ÄäÖöÜüß²³°" if you see a '~' instead of a 'arrow_right' at the right of submenuitems - this is the right one.
575 566
 
576 567
 //#define ULTRA_LCD  //general LCD support, also 16x2
@@ -636,13 +627,13 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
636 627
  #define ULTRA_LCD  //general LCD support, also 16x2
637 628
  #define DOGLCD  // Support for SPI LCD 128x64 (Controller ST7565R graphic Display Family)
638 629
  #define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
639
- 
630
+
640 631
   #ifdef miniVIKI
641 632
    #define DEFAULT_LCD_CONTRAST 95
642 633
   #else
643 634
    #define DEFAULT_LCD_CONTRAST 40
644 635
   #endif
645
-  
636
+
646 637
  #define ENCODER_PULSES_PER_STEP 4
647 638
  #define ENCODER_STEPS_PER_MENU_ITEM 1
648 639
 #endif
@@ -733,7 +724,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
733 724
 // Shift register panels
734 725
 // ---------------------
735 726
 // 2 wire Non-latching LCD SR from:
736
-// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection 
727
+// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection
737 728
 
738 729
 //#define SAV_3DLCD
739 730
 #ifdef SAV_3DLCD
@@ -774,7 +765,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
774 765
 #endif
775 766
 
776 767
 // Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino
777
-//#define FAST_PWM_FAN
768
+#define FAST_PWM_FAN
778 769
 
779 770
 // Temperature status LEDs that display the hotend and bet temperature.
780 771
 // If all hotends and bed temperature and temperature setpoint are < 54C then the BLUE led is on.
@@ -782,7 +773,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
782 773
 //#define TEMP_STAT_LEDS
783 774
 
784 775
 // Use software PWM to drive the fan, as for the heaters. This uses a very low frequency
785
-// which is not ass annoying as with the hardware PWM. On the other hand, if this frequency
776
+// which is not as annoying as with the hardware PWM. On the other hand, if this frequency
786 777
 // is too low, you should also increment SOFT_PWM_SCALE.
787 778
 //#define FAN_SOFT_PWM
788 779
 
@@ -831,9 +822,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
831 822
  * Support for a filament diameter sensor
832 823
  * Also allows adjustment of diameter at print time (vs  at slicing)
833 824
  * Single extruder only at this point (extruder 0)
834
- * 
825
+ *
835 826
  * Motherboards
836
- * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector 
827
+ * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector
837 828
  * 81 - Printrboard - Uses Analog input 2 on the Exp1 connector (version B,C,D,E)
838 829
  * 301 - Rambo  - uses Analog input 3
839 830
  * Note may require analog pins to be defined for different motherboards
@@ -850,16 +841,12 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
850 841
 #define MAX_MEASUREMENT_DELAY			20  //delay buffer size in bytes (1 byte = 1cm)- limits maximum measurement delay allowable (must be larger than MEASUREMENT_DELAY_CM  and lower number saves RAM)
851 842
 
852 843
 //defines used in the code
853
-#define DEFAULT_MEASURED_FILAMENT_DIA  DEFAULT_NOMINAL_FILAMENT_DIA  //set measured to nominal initially 
844
+#define DEFAULT_MEASURED_FILAMENT_DIA  DEFAULT_NOMINAL_FILAMENT_DIA  //set measured to nominal initially
854 845
 
855 846
 //When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status.  Status will appear for 5 sec.
856 847
 //#define FILAMENT_LCD_DISPLAY
857 848
 
858 849
 
859
-
860
-
861
-
862
-
863 850
 #include "Configuration_adv.h"
864 851
 #include "thermistortables.h"
865 852
 

+ 3
- 3
Marlin/ConfigurationStore.h View File

@@ -1,5 +1,5 @@
1
-#ifndef CONFIG_STORE_H
2
-#define CONFIG_STORE_H
1
+#ifndef CONFIGURATIONSTORE_H
2
+#define CONFIGURATIONSTORE_H
3 3
 
4 4
 #include "Configuration.h"
5 5
 
@@ -19,4 +19,4 @@ void Config_ResetDefault();
19 19
   FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); }
20 20
 #endif
21 21
 
22
-#endif // __CONFIG_STORE_H
22
+#endif //CONFIGURATIONSTORE_H

+ 2
- 2
Marlin/Marlin.h View File

@@ -180,8 +180,8 @@ void manage_inactivity(bool ignore_stepper_queue=false);
180 180
   #define disable_e3() /* nothing */
181 181
 #endif
182 182
 
183
-enum AxisEnum {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, E_AXIS=3, X_HEAD=4, Y_HEAD=5};
184
-
183
+enum AxisEnum {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, E_AXIS=3, X_HEAD=4, Y_HEAD=5}; 
184
+//X_HEAD and Y_HEAD is used for systems that don't have a 1:1 relationship between X_AXIS and X Head movement, like CoreXY bots.
185 185
 
186 186
 void FlushSerialRequestResend();
187 187
 void ClearToSend();

+ 10
- 10
Marlin/Marlin_main.cpp View File

@@ -1734,16 +1734,6 @@ void process_commands()
1734 1734
                 SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN);
1735 1735
                 break; // abort G29, since we don't know where we are
1736 1736
             }
1737
-            int left_probe_bed_position=LEFT_PROBE_BED_POSITION;
1738
-            int right_probe_bed_position=RIGHT_PROBE_BED_POSITION;
1739
-            int back_probe_bed_position=BACK_PROBE_BED_POSITION;
1740
-            int front_probe_bed_position=FRONT_PROBE_BED_POSITION;
1741
-            int auto_bed_leveling_grid_points=AUTO_BED_LEVELING_GRID_POINTS;
1742
-            if (code_seen('L')) left_probe_bed_position=(int)code_value();
1743
-            if (code_seen('R')) right_probe_bed_position=(int)code_value();
1744
-            if (code_seen('B')) back_probe_bed_position=(int)code_value();
1745
-            if (code_seen('F')) front_probe_bed_position=(int)code_value();
1746
-            if (code_seen('P')) auto_bed_leveling_grid_points=(int)code_value();
1747 1737
 
1748 1738
 #ifdef Z_PROBE_SLED
1749 1739
             dock_sled(false);
@@ -1764,6 +1754,16 @@ void process_commands()
1764 1754
             feedrate = homing_feedrate[Z_AXIS];
1765 1755
 #ifdef AUTO_BED_LEVELING_GRID
1766 1756
             // probe at the points of a lattice grid
1757
+            int left_probe_bed_position=LEFT_PROBE_BED_POSITION;
1758
+            int right_probe_bed_position=RIGHT_PROBE_BED_POSITION;
1759
+            int back_probe_bed_position=BACK_PROBE_BED_POSITION;
1760
+            int front_probe_bed_position=FRONT_PROBE_BED_POSITION;
1761
+            int auto_bed_leveling_grid_points=AUTO_BED_LEVELING_GRID_POINTS;
1762
+            if (code_seen('L')) left_probe_bed_position=(int)code_value();
1763
+            if (code_seen('R')) right_probe_bed_position=(int)code_value();
1764
+            if (code_seen('B')) back_probe_bed_position=(int)code_value();
1765
+            if (code_seen('F')) front_probe_bed_position=(int)code_value();
1766
+            if (code_seen('P')) auto_bed_leveling_grid_points=(int)code_value();
1767 1767
 
1768 1768
             int xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (auto_bed_leveling_grid_points-1);
1769 1769
             int yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (auto_bed_leveling_grid_points-1);

+ 252
- 378
Marlin/cardreader.cpp View File

@@ -7,476 +7,383 @@
7 7
 
8 8
 #ifdef SDSUPPORT
9 9
 
10
+CardReader::CardReader() {
11
+  filesize = 0;
12
+  sdpos = 0;
13
+  sdprinting = false;
14
+  cardOK = false;
15
+  saving = false;
16
+  logging = false;
17
+  workDirDepth = 0;
18
+  file_subcall_ctr = 0;
19
+  memset(workDirParents, 0, sizeof(workDirParents));
10 20
 
11
-
12
-CardReader::CardReader()
13
-{
14
-   filesize = 0;
15
-   sdpos = 0;
16
-   sdprinting = false;
17
-   cardOK = false;
18
-   saving = false;
19
-   logging = false;
20
-   autostart_atmillis=0;
21
-   workDirDepth = 0;
22
-   file_subcall_ctr=0;
23
-   memset(workDirParents, 0, sizeof(workDirParents));
24
-
25
-   autostart_stilltocheck=true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software.
26
-   autostart_index=0;
21
+  autostart_stilltocheck = true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software.
22
+  autostart_index = 0;
27 23
   //power to SD reader
28 24
   #if SDPOWER > -1
29
-    SET_OUTPUT(SDPOWER); 
30
-    WRITE(SDPOWER,HIGH);
25
+    SET_OUTPUT(SDPOWER);
26
+    WRITE(SDPOWER, HIGH);
31 27
   #endif //SDPOWER
32
-  
33
-  autostart_atmillis=millis()+5000;
28
+
29
+  autostart_atmillis = millis() + 5000;
34 30
 }
35 31
 
36
-char *createFilename(char *buffer,const dir_t &p) //buffer>12characters
37
-{
38
-  char *pos=buffer;
39
-  for (uint8_t i = 0; i < 11; i++) 
40
-  {
41
-    if (p.name[i] == ' ')continue;
42
-    if (i == 8) 
43
-    {
44
-      *pos++='.';
45
-    }
46
-    *pos++=p.name[i];
32
+char *createFilename(char *buffer, const dir_t &p) { //buffer > 12characters
33
+  char *pos = buffer;
34
+  for (uint8_t i = 0; i < 11; i++) {
35
+    if (p.name[i] == ' ') continue;
36
+    if (i == 8) *pos++ = '.';
37
+    *pos++ = p.name[i];
47 38
   }
48
-  *pos++=0;
39
+  *pos++ = 0;
49 40
   return buffer;
50 41
 }
51 42
 
52
-
53
-void CardReader::lsDive(const char *prepend, SdFile parent, const char * const match/*=NULL*/)
54
-{
43
+void CardReader::lsDive(const char *prepend, SdFile parent, const char * const match/*=NULL*/) {
55 44
   dir_t p;
56
- uint8_t cnt=0;
57
- 
58
-  while (parent.readDir(p, longFilename) > 0)
59
-  {
60
-    if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint
61
-    {
45
+  uint8_t cnt = 0;
62 46
 
47
+  while (parent.readDir(p, longFilename) > 0) {
48
+    if (DIR_IS_SUBDIR(&p) && lsAction != LS_Count && lsAction != LS_GetFilename) { // hence LS_SerialPrint
63 49
       char path[FILENAME_LENGTH*2];
64 50
       char lfilename[FILENAME_LENGTH];
65
-      createFilename(lfilename,p);
66
-      
67
-      path[0]=0;
68
-      if(prepend[0]==0) //avoid leading / if already in prepend
69
-      {
70
-       strcat(path,"/");
71
-      }
72
-      strcat(path,prepend);
73
-      strcat(path,lfilename);
74
-      strcat(path,"/");
75
-      
51
+      createFilename(lfilename, p);
52
+
53
+      path[0] = 0;
54
+      if (prepend[0] == 0) strcat(path, "/"); //avoid leading / if already in prepend
55
+      strcat(path, prepend);
56
+      strcat(path, lfilename);
57
+      strcat(path, "/");
58
+
76 59
       //Serial.print(path);
77
-      
60
+
78 61
       SdFile dir;
79
-      if(!dir.open(parent,lfilename, O_READ))
80
-      {
81
-        if(lsAction==LS_SerialPrint)
82
-        {
62
+      if (!dir.open(parent, lfilename, O_READ)) {
63
+        if (lsAction == LS_SerialPrint) {
83 64
           SERIAL_ECHO_START;
84 65
           SERIAL_ECHOLN(MSG_SD_CANT_OPEN_SUBDIR);
85 66
           SERIAL_ECHOLN(lfilename);
86 67
         }
87 68
       }
88
-      lsDive(path,dir);
69
+      lsDive(path, dir);
89 70
       //close done automatically by destructor of SdFile
90
-
91
-      
92 71
     }
93
-    else
94
-    {
72
+    else {
95 73
       char pn0 = p.name[0];
96 74
       if (pn0 == DIR_NAME_FREE) break;
97
-      if (pn0 == DIR_NAME_DELETED || pn0 == '.' || pn0 == '_') continue;
75
+      if (pn0 == DIR_NAME_DELETED || pn0 == '.') continue;
98 76
       char lf0 = longFilename[0];
99
-      if (lf0 == '.' || lf0 == '_') continue;
77
+      if (lf0 == '.') continue;
100 78
 
101 79
       if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
102
-      filenameIsDir=DIR_IS_SUBDIR(&p);
103
-      
104
-      
105
-      if(!filenameIsDir)
106
-      {
107
-        if(p.name[8]!='G') continue;
108
-        if(p.name[9]=='~') continue;
109
-      }
110
-      //if(cnt++!=nr) continue;
111
-      createFilename(filename,p);
112
-      if(lsAction==LS_SerialPrint)
113
-      {
80
+
81
+      filenameIsDir = DIR_IS_SUBDIR(&p);
82
+
83
+      if (!filenameIsDir && (p.name[8] != 'G' || p.name[9] == '~')) continue;
84
+
85
+      //if (cnt++ != nr) continue;
86
+      createFilename(filename, p);
87
+      if (lsAction == LS_SerialPrint) {
114 88
         SERIAL_PROTOCOL(prepend);
115 89
         SERIAL_PROTOCOLLN(filename);
116 90
       }
117
-      else if(lsAction==LS_Count)
118
-      {
91
+      else if (lsAction == LS_Count) {
119 92
         nrFiles++;
120
-      } 
121
-      else if(lsAction==LS_GetFilename)
122
-      {
93
+      }
94
+      else if (lsAction == LS_GetFilename) {
123 95
         if (match != NULL) {
124 96
           if (strcasecmp(match, filename) == 0) return;
125 97
         }
126 98
         else if (cnt == nrFiles) return;
127 99
         cnt++;
128
-        
129 100
       }
130 101
     }
131 102
   }
132 103
 }
133 104
 
134
-void CardReader::ls() 
135
-{
136
-  lsAction=LS_SerialPrint;
137
-  if(lsAction==LS_Count)
138
-  nrFiles=0;
139
-
105
+void CardReader::ls()  {
106
+  lsAction = LS_SerialPrint;
140 107
   root.rewind();
141
-  lsDive("",root);
108
+  lsDive("", root);
142 109
 }
143 110
 
144
-
145
-void CardReader::initsd()
146
-{
111
+void CardReader::initsd() {
147 112
   cardOK = false;
148
-  if(root.isOpen())
149
-    root.close();
150
-#ifdef SDSLOW
151
-  if (!card.init(SPI_HALF_SPEED,SDSS)
152
-  #if defined(LCD_SDSS) && (LCD_SDSS != SDSS)
153
-    && !card.init(SPI_HALF_SPEED,LCD_SDSS)
154
-  #endif
155
-    )
156
-#else
157
-  if (!card.init(SPI_FULL_SPEED,SDSS)
158
-  #if defined(LCD_SDSS) && (LCD_SDSS != SDSS)
159
-    && !card.init(SPI_FULL_SPEED,LCD_SDSS)
113
+  if (root.isOpen()) root.close();
114
+
115
+  #ifdef SDSLOW
116
+    #define SPI_SPEED SPI_HALF_SPEED
117
+  #else
118
+    #define SPI_SPEED SPI_FULL_SPEED
160 119
   #endif
161
-    )
162
-#endif
163
-  {
120
+
121
+  if (!card.init(SPI_SPEED,SDSS)
122
+    #if defined(LCD_SDSS) && (LCD_SDSS != SDSS)
123
+      && !card.init(SPI_SPEED, LCD_SDSS)
124
+    #endif
125
+  ) {
164 126
     //if (!card.init(SPI_HALF_SPEED,SDSS))
165 127
     SERIAL_ECHO_START;
166 128
     SERIAL_ECHOLNPGM(MSG_SD_INIT_FAIL);
167 129
   }
168
-  else if (!volume.init(&card))
169
-  {
130
+  else if (!volume.init(&card)) {
170 131
     SERIAL_ERROR_START;
171 132
     SERIAL_ERRORLNPGM(MSG_SD_VOL_INIT_FAIL);
172 133
   }
173
-  else if (!root.openRoot(&volume)) 
174
-  {
134
+  else if (!root.openRoot(&volume)) {
175 135
     SERIAL_ERROR_START;
176 136
     SERIAL_ERRORLNPGM(MSG_SD_OPENROOT_FAIL);
177 137
   }
178
-  else 
179
-  {
138
+  else {
180 139
     cardOK = true;
181 140
     SERIAL_ECHO_START;
182 141
     SERIAL_ECHOLNPGM(MSG_SD_CARD_OK);
183 142
   }
184
-  workDir=root;
185
-  curDir=&root;
143
+  workDir = root;
144
+  curDir = &root;
186 145
   /*
187
-  if(!workDir.openRoot(&volume))
188
-  {
146
+  if (!workDir.openRoot(&volume)) {
189 147
     SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL);
190 148
   }
191 149
   */
192
-  
193 150
 }
194 151
 
195
-void CardReader::setroot()
196
-{
197
-  /*if(!workDir.openRoot(&volume))
198
-  {
152
+void CardReader::setroot() {
153
+  /*if (!workDir.openRoot(&volume)) {
199 154
     SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL);
200 155
   }*/
201
-  workDir=root;
202
-  
203
-  curDir=&workDir;
156
+  workDir = root;
157
+  curDir = &workDir;
204 158
 }
205
-void CardReader::release()
206
-{
159
+
160
+void CardReader::release() {
207 161
   sdprinting = false;
208 162
   cardOK = false;
209 163
 }
210 164
 
211
-void CardReader::startFileprint()
212
-{
213
-  if(cardOK)
214
-  {
165
+void CardReader::startFileprint() {
166
+  if (cardOK) {
215 167
     sdprinting = true;
216 168
   }
217 169
 }
218 170
 
219
-void CardReader::pauseSDPrint()
220
-{
221
-  if(sdprinting)
222
-  {
223
-    sdprinting = false;
224
-  }
171
+void CardReader::pauseSDPrint() {
172
+  if (sdprinting) sdprinting = false;
225 173
 }
226 174
 
227
-
228
-void CardReader::openLogFile(char* name)
229
-{
175
+void CardReader::openLogFile(char* name) {
230 176
   logging = true;
231 177
   openFile(name, false);
232 178
 }
233 179
 
234
-void CardReader::getAbsFilename(char *t)
235
-{
236
-  uint8_t cnt=0;
237
-  *t='/';t++;cnt++;
238
-  for(uint8_t i=0;i<workDirDepth;i++)
239
-  {
180
+void CardReader::getAbsFilename(char *t) {
181
+  uint8_t cnt = 0;
182
+  *t = '/'; t++; cnt++;
183
+  for (uint8_t i = 0; i < workDirDepth; i++) {
240 184
     workDirParents[i].getFilename(t); //SDBaseFile.getfilename!
241
-    while(*t!=0 && cnt< MAXPATHNAMELENGTH) 
242
-    {t++;cnt++;}  //crawl counter forward.
185
+    while(*t && cnt < MAXPATHNAMELENGTH) { t++; cnt++; } //crawl counter forward.
243 186
   }
244
-  if(cnt<MAXPATHNAMELENGTH-FILENAME_LENGTH)
187
+  if (cnt < MAXPATHNAMELENGTH - FILENAME_LENGTH)
245 188
     file.getFilename(t);
246 189
   else
247
-    t[0]=0;
190
+    t[0] = 0;
248 191
 }
249 192
 
250
-void CardReader::openFile(char* name,bool read, bool replace_current/*=true*/)
251
-{
252
-  if(!cardOK)
253
-    return;
254
-  if(file.isOpen())  //replacing current file by new file, or subfile call
255
-  {
256
-    if(!replace_current)
257
-    {
258
-     if((int)file_subcall_ctr>(int)SD_PROCEDURE_DEPTH-1)
259
-     {
193
+void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/) {
194
+  if (!cardOK) return;
195
+  if (file.isOpen()) { //replacing current file by new file, or subfile call
196
+    if (!replace_current) {
197
+     if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) {
260 198
        SERIAL_ERROR_START;
261 199
        SERIAL_ERRORPGM("trying to call sub-gcode files with too many levels. MAX level is:");
262 200
        SERIAL_ERRORLN(SD_PROCEDURE_DEPTH);
263 201
        kill();
264 202
        return;
265 203
      }
266
-     
204
+
267 205
      SERIAL_ECHO_START;
268 206
      SERIAL_ECHOPGM("SUBROUTINE CALL target:\"");
269 207
      SERIAL_ECHO(name);
270 208
      SERIAL_ECHOPGM("\" parent:\"");
271
-     
209
+
272 210
      //store current filename and position
273 211
      getAbsFilename(filenames[file_subcall_ctr]);
274
-     
212
+
275 213
      SERIAL_ECHO(filenames[file_subcall_ctr]);
276 214
      SERIAL_ECHOPGM("\" pos");
277 215
      SERIAL_ECHOLN(sdpos);
278
-     filespos[file_subcall_ctr]=sdpos;
216
+     filespos[file_subcall_ctr] = sdpos;
279 217
      file_subcall_ctr++;
280 218
     }
281
-    else
282
-    {
219
+    else {
283 220
      SERIAL_ECHO_START;
284 221
      SERIAL_ECHOPGM("Now doing file: ");
285 222
      SERIAL_ECHOLN(name);
286 223
     }
287 224
     file.close();
288 225
   }
289
-  else //opening fresh file
290
-  {
291
-    file_subcall_ctr=0; //resetting procedure depth in case user cancels print while in procedure
226
+  else { //opening fresh file
227
+    file_subcall_ctr = 0; //resetting procedure depth in case user cancels print while in procedure
292 228
     SERIAL_ECHO_START;
293 229
     SERIAL_ECHOPGM("Now fresh file: ");
294 230
     SERIAL_ECHOLN(name);
295 231
   }
296 232
   sdprinting = false;
297
-  
298
- 
233
+
299 234
   SdFile myDir;
300
-  curDir=&root;
301
-  char *fname=name;
302
-  
303
-  char *dirname_start,*dirname_end;
304
-  if(name[0]=='/')
305
-  {
306
-    dirname_start=strchr(name,'/')+1;
307
-    while(dirname_start>0)
308
-    {
309
-      dirname_end=strchr(dirname_start,'/');
310
-      //SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name));
311
-      //SERIAL_ECHO("end  :");SERIAL_ECHOLN((int)(dirname_end-name));
312
-      if(dirname_end>0 && dirname_end>dirname_start)
313
-      {
235
+  curDir = &root;
236
+  char *fname = name;
237
+
238
+  char *dirname_start, *dirname_end;
239
+  if (name[0] == '/') {
240
+    dirname_start = &name[1];
241
+    while(dirname_start > 0) {
242
+      dirname_end = strchr(dirname_start, '/');
243
+      //SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start - name));
244
+      //SERIAL_ECHO("end  :");SERIAL_ECHOLN((int)(dirname_end - name));
245
+      if (dirname_end > 0 && dirname_end > dirname_start) {
314 246
         char subdirname[FILENAME_LENGTH];
315
-        strncpy(subdirname, dirname_start, dirname_end-dirname_start);
316
-        subdirname[dirname_end-dirname_start]=0;
247
+        strncpy(subdirname, dirname_start, dirname_end - dirname_start);
248
+        subdirname[dirname_end - dirname_start] = 0;
317 249
         SERIAL_ECHOLN(subdirname);
318
-        if(!myDir.open(curDir,subdirname,O_READ))
319
-        {
250
+        if (!myDir.open(curDir, subdirname, O_READ)) {
320 251
           SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
321 252
           SERIAL_PROTOCOL(subdirname);
322 253
           SERIAL_PROTOCOLLNPGM(".");
323 254
           return;
324 255
         }
325
-        else
326
-        {
256
+        else {
327 257
           //SERIAL_ECHOLN("dive ok");
328 258
         }
329
-          
330
-        curDir=&myDir; 
331
-        dirname_start=dirname_end+1;
259
+
260
+        curDir = &myDir;
261
+        dirname_start = dirname_end + 1;
332 262
       }
333
-      else // the reminder after all /fsa/fdsa/ is the filename
334
-      {
335
-        fname=dirname_start;
336
-        //SERIAL_ECHOLN("remaider");
263
+      else { // the remainder after all /fsa/fdsa/ is the filename
264
+        fname = dirname_start;
265
+        //SERIAL_ECHOLN("remainder");
337 266
         //SERIAL_ECHOLN(fname);
338 267
         break;
339 268
       }
340
-      
341 269
     }
342 270
   }
343
-  else //relative path
344
-  {
345
-    curDir=&workDir;
271
+  else { //relative path
272
+    curDir = &workDir;
346 273
   }
347
-  if(read)
348
-  {
349
-    if (file.open(curDir, fname, O_READ)) 
350
-    {
274
+
275
+  if (read) {
276
+    if (file.open(curDir, fname, O_READ)) {
351 277
       filesize = file.fileSize();
352 278
       SERIAL_PROTOCOLPGM(MSG_SD_FILE_OPENED);
353 279
       SERIAL_PROTOCOL(fname);
354 280
       SERIAL_PROTOCOLPGM(MSG_SD_SIZE);
355 281
       SERIAL_PROTOCOLLN(filesize);
356 282
       sdpos = 0;
357
-      
283
+
358 284
       SERIAL_PROTOCOLLNPGM(MSG_SD_FILE_SELECTED);
359 285
       getfilename(0, fname);
360 286
       lcd_setstatus(longFilename[0] ? longFilename : fname);
361 287
     }
362
-    else
363
-    {
288
+    else {
364 289
       SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
365 290
       SERIAL_PROTOCOL(fname);
366 291
       SERIAL_PROTOCOLLNPGM(".");
367 292
     }
368 293
   }
369
-  else 
370
-  { //write
371
-    if (!file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC))
372
-    {
294
+  else { //write
295
+    if (!file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) {
373 296
       SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
374 297
       SERIAL_PROTOCOL(fname);
375 298
       SERIAL_PROTOCOLLNPGM(".");
376 299
     }
377
-    else
378
-    {
300
+    else {
379 301
       saving = true;
380 302
       SERIAL_PROTOCOLPGM(MSG_SD_WRITE_TO_FILE);
381 303
       SERIAL_PROTOCOLLN(name);
382 304
       lcd_setstatus(fname);
383 305
     }
384 306
   }
385
-  
386 307
 }
387 308
 
388
-void CardReader::removeFile(char* name)
389
-{
390
-  if(!cardOK)
391
-    return;
309
+void CardReader::removeFile(char* name) {
310
+  if (!cardOK) return;
311
+
392 312
   file.close();
393 313
   sdprinting = false;
394
-  
395
-  
314
+
396 315
   SdFile myDir;
397
-  curDir=&root;
398
-  char *fname=name;
399
-  
400
-  char *dirname_start,*dirname_end;
401
-  if(name[0]=='/')
402
-  {
403
-    dirname_start=strchr(name,'/')+1;
404
-    while(dirname_start>0)
405
-    {
406
-      dirname_end=strchr(dirname_start,'/');
407
-      //SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name));
408
-      //SERIAL_ECHO("end  :");SERIAL_ECHOLN((int)(dirname_end-name));
409
-      if(dirname_end>0 && dirname_end>dirname_start)
410
-      {
316
+  curDir = &root;
317
+  char *fname = name;
318
+
319
+  char *dirname_start, *dirname_end;
320
+  if (name[0] == '/') {
321
+    dirname_start = strchr(name, '/') + 1;
322
+    while (dirname_start > 0) {
323
+      dirname_end = strchr(dirname_start, '/');
324
+      //SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start - name));
325
+      //SERIAL_ECHO("end  :");SERIAL_ECHOLN((int)(dirname_end - name));
326
+      if (dirname_end > 0 && dirname_end > dirname_start) {
411 327
         char subdirname[FILENAME_LENGTH];
412
-        strncpy(subdirname, dirname_start, dirname_end-dirname_start);
413
-        subdirname[dirname_end-dirname_start]=0;
328
+        strncpy(subdirname, dirname_start, dirname_end - dirname_start);
329
+        subdirname[dirname_end - dirname_start] = 0;
414 330
         SERIAL_ECHOLN(subdirname);
415
-        if(!myDir.open(curDir,subdirname,O_READ))
416
-        {
331
+        if (!myDir.open(curDir, subdirname, O_READ)) {
417 332
           SERIAL_PROTOCOLPGM("open failed, File: ");
418 333
           SERIAL_PROTOCOL(subdirname);
419 334
           SERIAL_PROTOCOLLNPGM(".");
420 335
           return;
421 336
         }
422
-        else
423
-        {
337
+        else {
424 338
           //SERIAL_ECHOLN("dive ok");
425 339
         }
426
-          
427
-        curDir=&myDir; 
428
-        dirname_start=dirname_end+1;
340
+
341
+        curDir = &myDir;
342
+        dirname_start = dirname_end + 1;
429 343
       }
430
-      else // the reminder after all /fsa/fdsa/ is the filename
431
-      {
432
-        fname=dirname_start;
433
-        //SERIAL_ECHOLN("remaider");
344
+      else { // the remainder after all /fsa/fdsa/ is the filename
345
+        fname = dirname_start;
346
+        //SERIAL_ECHOLN("remainder");
434 347
         //SERIAL_ECHOLN(fname);
435 348
         break;
436 349
       }
437
-      
438 350
     }
439 351
   }
440
-  else //relative path
441
-  {
442
-    curDir=&workDir;
352
+  else { // relative path
353
+    curDir = &workDir;
354
+  }
355
+
356
+  if (file.remove(curDir, fname)) {
357
+    SERIAL_PROTOCOLPGM("File deleted:");
358
+    SERIAL_PROTOCOLLN(fname);
359
+    sdpos = 0;
360
+  }
361
+  else {
362
+    SERIAL_PROTOCOLPGM("Deletion failed, File: ");
363
+    SERIAL_PROTOCOL(fname);
364
+    SERIAL_PROTOCOLLNPGM(".");
443 365
   }
444
-    if (file.remove(curDir, fname)) 
445
-    {
446
-      SERIAL_PROTOCOLPGM("File deleted:");
447
-      SERIAL_PROTOCOLLN(fname);
448
-      sdpos = 0;
449
-    }
450
-    else
451
-    {
452
-      SERIAL_PROTOCOLPGM("Deletion failed, File: ");
453
-      SERIAL_PROTOCOL(fname);
454
-      SERIAL_PROTOCOLLNPGM(".");
455
-    }
456
-  
457 366
 }
458 367
 
459
-void CardReader::getStatus()
460
-{
461
-  if(cardOK){
368
+void CardReader::getStatus() {
369
+  if (cardOK) {
462 370
     SERIAL_PROTOCOLPGM(MSG_SD_PRINTING_BYTE);
463 371
     SERIAL_PROTOCOL(sdpos);
464 372
     SERIAL_PROTOCOLPGM("/");
465 373
     SERIAL_PROTOCOLLN(filesize);
466 374
   }
467
-  else{
375
+  else {
468 376
     SERIAL_PROTOCOLLNPGM(MSG_SD_NOT_PRINTING);
469 377
   }
470 378
 }
471
-void CardReader::write_command(char *buf)
472
-{
379
+
380
+void CardReader::write_command(char *buf) {
473 381
   char* begin = buf;
474 382
   char* npos = 0;
475 383
   char* end = buf + strlen(buf) - 1;
476 384
 
477 385
   file.writeError = false;
478
-  if((npos = strchr(buf, 'N')) != NULL)
479
-  {
386
+  if ((npos = strchr(buf, 'N')) != NULL) {
480 387
     begin = strchr(npos, ' ') + 1;
481 388
     end = strchr(npos, '*') - 1;
482 389
   }
@@ -484,162 +391,129 @@ void CardReader::write_command(char *buf)
484 391
   end[2] = '\n';
485 392
   end[3] = '\0';
486 393
   file.write(begin);
487
-  if (file.writeError)
488
-  {
394
+  if (file.writeError) {
489 395
     SERIAL_ERROR_START;
490 396
     SERIAL_ERRORLNPGM(MSG_SD_ERR_WRITE_TO_FILE);
491 397
   }
492 398
 }
493 399
 
400
+void CardReader::checkautostart(bool force) {
401
+  if (!force && (!autostart_stilltocheck || autostart_atmillis < millis()))
402
+    return;
494 403
 
495
-void CardReader::checkautostart(bool force)
496
-{
497
-  if(!force)
498
-  {
499
-    if(!autostart_stilltocheck)
500
-      return;
501
-    if(autostart_atmillis<millis())
502
-      return;
503
-  }
504
-  autostart_stilltocheck=false;
505
-  if(!cardOK)
506
-  {
404
+  autostart_stilltocheck = false;
405
+
406
+  if (!cardOK) {
507 407
     initsd();
508
-    if(!cardOK) //fail
509
-      return;
408
+    if (!cardOK) return; // fail
510 409
   }
511
-  
410
+
512 411
   char autoname[30];
513 412
   sprintf_P(autoname, PSTR("auto%i.g"), autostart_index);
514
-  for(int8_t i=0;i<(int8_t)strlen(autoname);i++)
515
-    autoname[i]=tolower(autoname[i]);
413
+  for (int8_t i = 0; i < (int8_t)strlen(autoname); i++) autoname[i] = tolower(autoname[i]);
414
+
516 415
   dir_t p;
517 416
 
518 417
   root.rewind();
519
-  
520
-  bool found=false;
521
-  while (root.readDir(p, NULL) > 0) 
522
-  {
523
-    for(int8_t i=0;i<(int8_t)strlen((char*)p.name);i++)
524
-    p.name[i]=tolower(p.name[i]);
525
-    //Serial.print((char*)p.name);
526
-    //Serial.print(" ");
527
-    //Serial.println(autoname);
528
-    if(p.name[9]!='~') //skip safety copies
529
-    if(strncmp((char*)p.name,autoname,5)==0)
530
-    {
531
-      char cmd[30];
532 418
 
419
+  bool found = false;
420
+  while (root.readDir(p, NULL) > 0) {
421
+    for (int8_t i = 0; i < (int8_t)strlen((char*)p.name); i++) p.name[i] = tolower(p.name[i]);
422
+    if (p.name[9] != '~' && strncmp((char*)p.name, autoname, 5) == 0) {
423
+      char cmd[30];
533 424
       sprintf_P(cmd, PSTR("M23 %s"), autoname);
534 425
       enquecommand(cmd);
535 426
       enquecommands_P(PSTR("M24"));
536
-      found=true;
427
+      found = true;
537 428
     }
538 429
   }
539
-  if(!found)
540
-    autostart_index=-1;
430
+  if (!found)
431
+    autostart_index = -1;
541 432
   else
542 433
     autostart_index++;
543 434
 }
544 435
 
545
-void CardReader::closefile(bool store_location)
546
-{
436
+void CardReader::closefile(bool store_location) {
547 437
   file.sync();
548 438
   file.close();
549
-  saving = false; 
550
-  logging = false;
551
-  
552
-  if(store_location)
553
-  {
439
+  saving = logging = false;
440
+
441
+  if (store_location) {
554 442
     //future: store printer state, filename and position for continuing a stopped print
555 443
     // so one can unplug the printer and continue printing the next day.
556
-    
557 444
   }
558
-
559
-  
560 445
 }
561 446
 
562
-void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/)
563
-{
564
-  curDir=&workDir;
565
-  lsAction=LS_GetFilename;
566
-  nrFiles=nr;
447
+/**
448
+ * Get the name of a file in the current directory by index
449
+ */
450
+void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) {
451
+  curDir = &workDir;
452
+  lsAction = LS_GetFilename;
453
+  nrFiles = nr;
567 454
   curDir->rewind();
568
-  lsDive("",*curDir,match);
569
-  
455
+  lsDive("", *curDir, match);
570 456
 }
571 457
 
572
-uint16_t CardReader::getnrfilenames()
573
-{
574
-  curDir=&workDir;
575
-  lsAction=LS_Count;
576
-  nrFiles=0;
458
+uint16_t CardReader::getnrfilenames() {
459
+  curDir = &workDir;
460
+  lsAction = LS_Count;
461
+  nrFiles = 0;
577 462
   curDir->rewind();
578
-  lsDive("",*curDir);
463
+  lsDive("", *curDir);
579 464
   //SERIAL_ECHOLN(nrFiles);
580 465
   return nrFiles;
581 466
 }
582 467
 
583
-void CardReader::chdir(const char * relpath)
584
-{
468
+void CardReader::chdir(const char * relpath) {
585 469
   SdFile newfile;
586
-  SdFile *parent=&root;
587
-  
588
-  if(workDir.isOpen())
589
-    parent=&workDir;
590
-  
591
-  if(!newfile.open(*parent,relpath, O_READ))
592
-  {
593
-   SERIAL_ECHO_START;
594
-   SERIAL_ECHOPGM(MSG_SD_CANT_ENTER_SUBDIR);
595
-   SERIAL_ECHOLN(relpath);
470
+  SdFile *parent = &root;
471
+
472
+  if (workDir.isOpen()) parent = &workDir;
473
+
474
+  if (!newfile.open(*parent, relpath, O_READ)) {
475
+    SERIAL_ECHO_START;
476
+    SERIAL_ECHOPGM(MSG_SD_CANT_ENTER_SUBDIR);
477
+    SERIAL_ECHOLN(relpath);
596 478
   }
597
-  else
598
-  {
479
+  else {
599 480
     if (workDirDepth < MAX_DIR_DEPTH) {
600
-      for (int d = ++workDirDepth; d--;)
601
-        workDirParents[d+1] = workDirParents[d];
602
-      workDirParents[0]=*parent;
481
+      ++workDirDepth;
482
+      for (int d = workDirDepth; d--;) workDirParents[d + 1] = workDirParents[d];
483
+      workDirParents[0] = *parent;
603 484
     }
604
-    workDir=newfile;
485
+    workDir = newfile;
605 486
   }
606 487
 }
607 488
 
608
-void CardReader::updir()
609
-{
610
-  if(workDirDepth > 0)
611
-  {
489
+void CardReader::updir() {
490
+  if (workDirDepth > 0) {
612 491
     --workDirDepth;
613 492
     workDir = workDirParents[0];
614
-    int d;
615 493
     for (int d = 0; d < workDirDepth; d++)
616 494
       workDirParents[d] = workDirParents[d+1];
617 495
   }
618 496
 }
619 497
 
620
-
621
-void CardReader::printingHasFinished()
622
-{
623
-    st_synchronize();
624
-    if(file_subcall_ctr>0) //heading up to a parent file that called current as a procedure.
625
-    {
626
-      file.close();
627
-      file_subcall_ctr--;
628
-      openFile(filenames[file_subcall_ctr],true,true);
629
-      setIndex(filespos[file_subcall_ctr]);
630
-      startFileprint();
631
-    }
632
-    else
633
-    {
634
-      quickStop();
635
-      file.close();
636
-      sdprinting = false;
637
-      if(SD_FINISHED_STEPPERRELEASE)
638
-      {
639
-          //finishAndDisableSteppers();
640
-          enquecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
641
-      }
642
-      autotempShutdown();
498
+void CardReader::printingHasFinished() {
499
+  st_synchronize();
500
+  if (file_subcall_ctr > 0) { // Heading up to a parent file that called current as a procedure.
501
+    file.close();
502
+    file_subcall_ctr--;
503
+    openFile(filenames[file_subcall_ctr], true, true);
504
+    setIndex(filespos[file_subcall_ctr]);
505
+    startFileprint();
506
+  }
507
+  else {
508
+    quickStop();
509
+    file.close();
510
+    sdprinting = false;
511
+    if (SD_FINISHED_STEPPERRELEASE) {
512
+      //finishAndDisableSteppers();
513
+      enquecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
643 514
     }
515
+    autotempShutdown();
516
+  }
644 517
 }
518
+
645 519
 #endif //SDSUPPORT

+ 30
- 34
Marlin/cardreader.h View File

@@ -3,21 +3,21 @@
3 3
 
4 4
 #ifdef SDSUPPORT
5 5
 
6
-#define MAX_DIR_DEPTH 10
6
+#define MAX_DIR_DEPTH 10          // Maximum folder depth
7 7
 
8 8
 #include "SdFile.h"
9
-enum LsAction {LS_SerialPrint,LS_Count,LS_GetFilename};
10
-class CardReader
11
-{
9
+enum LsAction { LS_SerialPrint, LS_Count, LS_GetFilename };
10
+
11
+class CardReader {
12 12
 public:
13 13
   CardReader();
14
-  
14
+
15 15
   void initsd();
16 16
   void write_command(char *buf);
17 17
   //files auto[0-9].g on the sd card are performed in a row
18 18
   //this is to delay autostart and hence the initialisaiton of the sd card to some seconds after the normal init, so the device is available quick after a reset
19 19
 
20
-  void checkautostart(bool x); 
20
+  void checkautostart(bool x);
21 21
   void openFile(char* name,bool read,bool replace_current=true);
22 22
   void openLogFile(char* name);
23 23
   void removeFile(char* name);
@@ -30,9 +30,8 @@ public:
30 30
 
31 31
   void getfilename(uint16_t nr, const char* const match=NULL);
32 32
   uint16_t getnrfilenames();
33
-  
33
+
34 34
   void getAbsFilename(char *t);
35
-  
36 35
 
37 36
   void ls();
38 37
   void chdir(const char * relpath);
@@ -41,56 +40,52 @@ public:
41 40
 
42 41
 
43 42
   FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
44
-  FORCE_INLINE bool eof() { return sdpos>=filesize ;};
45
-  FORCE_INLINE int16_t get() {  sdpos = file.curPosition();return (int16_t)file.read();};
46
-  FORCE_INLINE void setIndex(long index) {sdpos = index;file.seekSet(index);};
47
-  FORCE_INLINE uint8_t percentDone(){if(!isFileOpen()) return 0; if(filesize) return sdpos/((filesize+99)/100); else return 0;};
48
-  FORCE_INLINE char* getWorkDirName(){workDir.getFilename(filename);return filename;};
43
+  FORCE_INLINE bool eof() { return sdpos >= filesize; }
44
+  FORCE_INLINE int16_t get() { sdpos = file.curPosition(); return (int16_t)file.read(); }
45
+  FORCE_INLINE void setIndex(long index) { sdpos = index; file.seekSet(index); }
46
+  FORCE_INLINE uint8_t percentDone() { return (isFileOpen() && filesize) ? sdpos / ((filesize + 99) / 100) : 0; }
47
+  FORCE_INLINE char* getWorkDirName() { workDir.getFilename(filename); return filename; }
49 48
 
50 49
 public:
51
-  bool saving;
52
-  bool logging;
53
-  bool sdprinting;  
54
-  bool cardOK;
55
-  char filename[FILENAME_LENGTH];
56
-  char longFilename[LONG_FILENAME_LENGTH];
57
-  bool filenameIsDir;
50
+  bool saving, logging, sdprinting, cardOK, filenameIsDir;
51
+  char filename[FILENAME_LENGTH], longFilename[LONG_FILENAME_LENGTH];
58 52
   int autostart_index;
59 53
 private:
60
-  SdFile root,*curDir,workDir,workDirParents[MAX_DIR_DEPTH];
54
+  SdFile root, *curDir, workDir, workDirParents[MAX_DIR_DEPTH];
61 55
   uint16_t workDirDepth;
62 56
   Sd2Card card;
63 57
   SdVolume volume;
64 58
   SdFile file;
65 59
   #define SD_PROCEDURE_DEPTH 1
66
-  #define MAXPATHNAMELENGTH (FILENAME_LENGTH*MAX_DIR_DEPTH+MAX_DIR_DEPTH+1)
60
+  #define MAXPATHNAMELENGTH (FILENAME_LENGTH*MAX_DIR_DEPTH + MAX_DIR_DEPTH + 1)
67 61
   uint8_t file_subcall_ctr;
68 62
   uint32_t filespos[SD_PROCEDURE_DEPTH];
69 63
   char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
70 64
   uint32_t filesize;
71
-  //int16_t n;
72 65
   unsigned long autostart_atmillis;
73
-  uint32_t sdpos ;
66
+  uint32_t sdpos;
74 67
 
75 68
   bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
76
-  
69
+
77 70
   LsAction lsAction; //stored for recursion.
78
-  int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory.
71
+  uint16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory.
79 72
   char* diveDirName;
80 73
   void lsDive(const char *prepend, SdFile parent, const char * const match=NULL);
81 74
 };
75
+
82 76
 extern CardReader card;
77
+
83 78
 #define IS_SD_PRINTING (card.sdprinting)
84 79
 
85 80
 #if (SDCARDDETECT > -1)
86
-# ifdef SDCARDDETECTINVERTED 
87
-#  define IS_SD_INSERTED (READ(SDCARDDETECT)!=0)
88
-# else
89
-#  define IS_SD_INSERTED (READ(SDCARDDETECT)==0)
90
-# endif //SDCARDTETECTINVERTED
81
+  #ifdef SDCARDDETECTINVERTED
82
+    #define IS_SD_INSERTED (READ(SDCARDDETECT) != 0)
83
+  #else
84
+    #define IS_SD_INSERTED (READ(SDCARDDETECT) == 0)
85
+  #endif
91 86
 #else
92
-//If we don't have a card detect line, aways asume the card is inserted
93
-# define IS_SD_INSERTED true
87
+  //No card detect line? Assume the card is inserted.
88
+  #define IS_SD_INSERTED true
94 89
 #endif
95 90
 
96 91
 #else
@@ -98,4 +93,5 @@ extern CardReader card;
98 93
 #define IS_SD_PRINTING (false)
99 94
 
100 95
 #endif //SDSUPPORT
101
-#endif
96
+
97
+#endif //__CARDREADER_H

+ 38
- 39
Marlin/digipot_mcp4451.cpp View File

@@ -1,59 +1,58 @@
1 1
 #include "Configuration.h"
2 2
 
3 3
 #ifdef DIGIPOT_I2C
4
+
4 5
 #include "Stream.h"
5 6
 #include "utility/twi.h"
6 7
 #include "Wire.h"
7 8
 
8 9
 // Settings for the I2C based DIGIPOT (MCP4451) on Azteeg X3 Pro
9 10
 #if MB(5DPRINT)
10
-#define DIGIPOT_I2C_FACTOR 117.96
11
-#define DIGIPOT_I2C_MAX_CURRENT 1.736
11
+  #define DIGIPOT_I2C_FACTOR 117.96
12
+  #define DIGIPOT_I2C_MAX_CURRENT 1.736
12 13
 #else
13
-#define DIGIPOT_I2C_FACTOR 106.7
14
-#define DIGIPOT_I2C_MAX_CURRENT 2.5
14
+  #define DIGIPOT_I2C_FACTOR 106.7
15
+  #define DIGIPOT_I2C_MAX_CURRENT 2.5
15 16
 #endif
16 17
 
17
-static byte current_to_wiper( float current ){
18
-    return byte(ceil(float((DIGIPOT_I2C_FACTOR*current))));
18
+static byte current_to_wiper(float current) {
19
+  return byte(ceil(float((DIGIPOT_I2C_FACTOR*current))));
19 20
 }
20 21
 
21
-static void i2c_send(byte addr, byte a, byte b)
22
-{
23
-	Wire.beginTransmission(addr);
24
-    Wire.write(a);
25
-    Wire.write(b);
26
-    Wire.endTransmission();
22
+static void i2c_send(byte addr, byte a, byte b) {
23
+  Wire.beginTransmission(addr);
24
+  Wire.write(a);
25
+  Wire.write(b);
26
+  Wire.endTransmission();
27 27
 }
28 28
 
29 29
 // This is for the MCP4451 I2C based digipot
30
-void digipot_i2c_set_current( int channel, float current )
31
-{
32
-    current = min( (float) max( current, 0.0f ), DIGIPOT_I2C_MAX_CURRENT);
33
-    // these addresses are specific to Azteeg X3 Pro, can be set to others,
34
-    // In this case first digipot is at address A0=0, A1= 0, second one is at A0=0, A1= 1
35
-    byte addr= 0x2C; // channel 0-3
36
-    if(channel >= 4) {
37
-    	addr= 0x2E; // channel 4-7
38
-    	channel-= 4;
39
-    }
40
-
41
-    // Initial setup
42
-    i2c_send( addr, 0x40, 0xff );
43
-    i2c_send( addr, 0xA0, 0xff );
44
-
45
-    // Set actual wiper value
46
-    byte addresses[4] = { 0x00, 0x10, 0x60, 0x70 };
47
-    i2c_send( addr, addresses[channel], current_to_wiper(current) );
30
+void digipot_i2c_set_current(int channel, float current) {
31
+  current = min( (float) max( current, 0.0f ), DIGIPOT_I2C_MAX_CURRENT);
32
+  // these addresses are specific to Azteeg X3 Pro, can be set to others,
33
+  // In this case first digipot is at address A0=0, A1= 0, second one is at A0=0, A1= 1
34
+  byte addr = 0x2C; // channel 0-3
35
+  if (channel >= 4) {
36
+  	addr = 0x2E; // channel 4-7
37
+  	channel -= 4;
38
+  }
39
+
40
+  // Initial setup
41
+  i2c_send(addr, 0x40, 0xff);
42
+  i2c_send(addr, 0xA0, 0xff);
43
+
44
+  // Set actual wiper value
45
+  byte addresses[4] = { 0x00, 0x10, 0x60, 0x70 };
46
+  i2c_send(addr, addresses[channel], current_to_wiper(current));
48 47
 }
49 48
 
50
-void digipot_i2c_init()
51
-{
52
-    const float digipot_motor_current[] = DIGIPOT_I2C_MOTOR_CURRENTS;
53
-    Wire.begin();
54
-    // setup initial currents as defined in Configuration_adv.h
55
-    for(int i=0;i<=sizeof(digipot_motor_current)/sizeof(float);i++) {
56
-        digipot_i2c_set_current(i, digipot_motor_current[i]);
57
-    }
49
+void digipot_i2c_init() {
50
+  const float digipot_motor_current[] = DIGIPOT_I2C_MOTOR_CURRENTS;
51
+  Wire.begin();
52
+  // setup initial currents as defined in Configuration_adv.h
53
+  for(int i = 0; i <= sizeof(digipot_motor_current) / sizeof(float); i++) {
54
+    digipot_i2c_set_current(i, digipot_motor_current[i]);
55
+  }
58 56
 }
59
-#endif
57
+
58
+#endif //DIGIPOT_I2C

+ 37
- 0
Marlin/language.h View File

@@ -159,6 +159,43 @@
159 159
 
160 160
 #define MSG_ERR_EEPROM_WRITE                "Error writing to EEPROM!"
161 161
 
162
+// temperature.cpp strings
163
+#define MSG_PID_AUTOTUNE                    "PID Autotune"
164
+#define MSG_PID_AUTOTUNE_START              MSG_PID_AUTOTUNE " start"
165
+#define MSG_PID_AUTOTUNE_FAILED             MSG_PID_AUTOTUNE " failed!"
166
+#define MSG_PID_BAD_EXTRUDER_NUM            MSG_PID_AUTOTUNE_FAILED " Bad extruder number"
167
+#define MSG_PID_TEMP_TOO_HIGH               MSG_PID_AUTOTUNE_FAILED " Temperature too high"
168
+#define MSG_PID_TIMEOUT                     MSG_PID_AUTOTUNE_FAILED " timeout"
169
+#define MSG_BIAS                            " bias: "
170
+#define MSG_D                               " d: "
171
+#define MSG_MIN                             " min: "
172
+#define MSG_MAX                             " max: "
173
+#define MSG_KU                              " Ku: "
174
+#define MSG_TU                              " Tu: "
175
+#define MSG_CLASSIC_PID                     " Classic PID "
176
+#define MSG_KP                              " Kp: "
177
+#define MSG_KI                              " Ki: "
178
+#define MSG_KD                              " Kd: "
179
+#define MSG_OK_B                            "ok B:"
180
+#define MSG_OK_T                            "ok T:"
181
+#define MSG_AT                              " @:"
182
+#define MSG_PID_AUTOTUNE_FINISHED           MSG_PID_AUTOTUNE " finished! Put the last Kp, Ki and Kd constants from above into Configuration.h"
183
+#define MSG_PID_DEBUG                       " PID_DEBUG "
184
+#define MSG_PID_DEBUG_INPUT                 ": Input "
185
+#define MSG_PID_DEBUG_OUTPUT                " Output "
186
+#define MSG_PID_DEBUG_PTERM                 " pTerm "
187
+#define MSG_PID_DEBUG_ITERM                 " iTerm "
188
+#define MSG_PID_DEBUG_DTERM                 " dTerm "
189
+#define MSG_HEATING_FAILED                  "Heating failed"
190
+#define MSG_EXTRUDER_SWITCHED_OFF           "Extruder switched off. Temperature difference between temp sensors is too high !"
191
+
192
+#define MSG_INVALID_EXTRUDER_NUM            " - Invalid extruder number !"
193
+#define MSG_THERMAL_RUNAWAY_STOP            "Thermal Runaway, system stopped! Heater_ID: "
194
+#define MSG_SWITCHED_OFF_MAX                " switched off. MAXTEMP triggered !!"
195
+#define MSG_MINTEMP_EXTRUDER_OFF            ": Extruder switched off. MINTEMP triggered !"
196
+#define MSG_MAXTEMP_EXTRUDER_OFF            ": Extruder" MSG_SWITCHED_OFF_MAX
197
+#define MSG_MAXTEMP_BED_OFF                 "Heated bed" MSG_SWITCHED_OFF_MAX
198
+
162 199
 // LCD Menu Messages
163 200
 
164 201
 // Add your own character. Reference: https://github.com/MarlinFirmware/Marlin/pull/1434 photos

+ 34
- 16
Marlin/language_en.h View File

@@ -255,7 +255,7 @@
255 255
 #define MSG_VOLUMETRIC                      "Filament"
256 256
 #endif
257 257
 #ifndef MSG_VOLUMETRIC_ENABLED
258
-#define MSG_VOLUMETRIC_ENABLED		        "E in mm" STR_h3
258
+#define MSG_VOLUMETRIC_ENABLED              "E in mm" STR_h3
259 259
 #endif
260 260
 #ifndef MSG_FILAMENT_SIZE_EXTRUDER_0
261 261
 #define MSG_FILAMENT_SIZE_EXTRUDER_0        "Fil. Dia. 1"
@@ -383,23 +383,41 @@
383 383
 #ifndef MSG_ENDSTOP_ABORT
384 384
 #define MSG_ENDSTOP_ABORT                   "Endstop abort"
385 385
 #endif
386
+#ifndef MSG_HEATING_FAILED_LCD
387
+#define MSG_HEATING_FAILED_LCD              "Heating failed"
388
+#endif
389
+#ifndef MSG_ERR_REDUNDANT_TEMP
390
+#define MSG_ERR_REDUNDANT_TEMP              "Err: REDUNDANT TEMP ERROR"
391
+#endif
392
+#ifndef MSG_THERMAL_RUNAWAY
393
+#define MSG_THERMAL_RUNAWAY                 "THERMAL RUNAWAY"
394
+#endif
395
+#ifndef MSG_ERR_MAXTEMP
396
+#define MSG_ERR_MAXTEMP                     "Err: MAXTEMP"
397
+#endif
398
+#ifndef MSG_ERR_MINTEMP
399
+#define MSG_ERR_MINTEMP                     "Err: MINTEMP"
400
+#endif
401
+#ifndef MSG_ERR_MAXTEMP_BED
402
+#define MSG_ERR_MAXTEMP_BED                 "Err: MAXTEMP BED"
403
+#endif
386 404
 
387 405
 #ifdef DELTA_CALIBRATION_MENU
388
-    #ifndef MSG_DELTA_CALIBRATE
389
-    #define MSG_DELTA_CALIBRATE             "Delta Calibration"
390
-    #endif
391
-    #ifndef MSG_DELTA_CALIBRATE_X
392
-    #define MSG_DELTA_CALIBRATE_X           "Calibrate X"
393
-    #endif
394
-    #ifndef MSG_DELTA_CALIBRATE_Y
395
-    #define MSG_DELTA_CALIBRATE_Y           "Calibrate Y"
396
-    #endif
397
-    #ifndef MSG_DELTA_CALIBRATE_Z
398
-    #define MSG_DELTA_CALIBRATE_Z           "Calibrate Z"
399
-    #endif
400
-    #ifndef MSG_DELTA_CALIBRATE_CENTER
401
-    #define MSG_DELTA_CALIBRATE_CENTER      "Calibrate Center"
402
-    #endif
406
+  #ifndef MSG_DELTA_CALIBRATE
407
+  #define MSG_DELTA_CALIBRATE             "Delta Calibration"
408
+  #endif
409
+  #ifndef MSG_DELTA_CALIBRATE_X
410
+  #define MSG_DELTA_CALIBRATE_X           "Calibrate X"
411
+  #endif
412
+  #ifndef MSG_DELTA_CALIBRATE_Y
413
+  #define MSG_DELTA_CALIBRATE_Y           "Calibrate Y"
414
+  #endif
415
+  #ifndef MSG_DELTA_CALIBRATE_Z
416
+  #define MSG_DELTA_CALIBRATE_Z           "Calibrate Z"
417
+  #endif
418
+  #ifndef MSG_DELTA_CALIBRATE_CENTER
419
+  #define MSG_DELTA_CALIBRATE_CENTER      "Calibrate Center"
420
+  #endif
403 421
 #endif // DELTA_CALIBRATION_MENU
404 422
 
405 423
 #endif // LANGUAGE_EN_H

+ 4
- 0
Marlin/pins_RUMBA.h View File

@@ -6,6 +6,10 @@
6 6
   #error Oops!  Make sure you have 'Arduino Mega' selected from the 'Tools -> Boards' menu.
7 7
 #endif
8 8
 
9
+#if EXTRUDERS > 3
10
+  #error RUMBA supports up to 3 extruders. Comment this line to keep going.
11
+#endif
12
+
9 13
 #define X_STEP_PIN         17
10 14
 #define X_DIR_PIN          16
11 15
 #define X_ENABLE_PIN       48

+ 71
- 76
Marlin/stepper.cpp View File

@@ -399,89 +399,84 @@ ISR(TIMER1_COMPA_vect)
399 399
       count_direction[Y_AXIS]=1;
400 400
     }
401 401
 
402
-    // Set direction en check limit switches
403
-    #ifndef COREXY
404
-    if ((out_bits & (1<<X_AXIS)) != 0)   // stepping along -X axis
405
-    #else
406
-    if ((out_bits & (1<<X_HEAD)) != 0)   //AlexBorro: Head direction in -X axis for CoreXY bots.
407
-    #endif
402
+    if(check_endstops) // check X and Y Endstops
408 403
     {
409
-      CHECK_ENDSTOPS
410
-      {
411
-        #ifdef DUAL_X_CARRIAGE
412
-        // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
413
-        if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) 
414
-            || (current_block->active_extruder != 0 && X2_HOME_DIR == -1))
415
-        #endif          
416
-        {
417
-          #if defined(X_MIN_PIN) && X_MIN_PIN > -1
418
-            bool x_min_endstop=(READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING);
419
-            if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) {
420
-              endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
421
-              endstop_x_hit=true;
422
-              step_events_completed = current_block->step_event_count;
404
+        #ifndef COREXY
405
+        if ((out_bits & (1<<X_AXIS)) != 0)   // stepping along -X axis (regular cartesians bot)
406
+        #else
407
+        if (!((current_block->steps_x == current_block->steps_y) && ((out_bits & (1<<X_AXIS))>>X_AXIS != (out_bits & (1<<Y_AXIS))>>Y_AXIS))) // AlexBorro: If DeltaX == -DeltaY, the movement is only in Y axis
408
+        if ((out_bits & (1<<X_HEAD)) != 0) //AlexBorro: Head direction in -X axis for CoreXY bots.
409
+        #endif
410
+        { // -direction
411
+            #ifdef DUAL_X_CARRIAGE
412
+            // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
413
+            if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) || (current_block->active_extruder != 0 && X2_HOME_DIR == -1))
414
+            #endif          
415
+            {
416
+                #if defined(X_MIN_PIN) && X_MIN_PIN > -1
417
+                bool x_min_endstop=(READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING);
418
+                if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0))
419
+                {
420
+                    endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
421
+                    endstop_x_hit=true;
422
+                    step_events_completed = current_block->step_event_count;
423
+                }
424
+                old_x_min_endstop = x_min_endstop;
425
+                #endif
423 426
             }
424
-            old_x_min_endstop = x_min_endstop;
425
-          #endif
426 427
         }
427
-      }
428
-    }
429
-    else 
430
-    { // +direction
431
-      CHECK_ENDSTOPS
432
-      {
433
-        #ifdef DUAL_X_CARRIAGE
434
-        // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
435
-        if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) 
436
-            || (current_block->active_extruder != 0 && X2_HOME_DIR == 1))
437
-        #endif          
438
-        {
439
-          #if defined(X_MAX_PIN) && X_MAX_PIN > -1
440
-            bool x_max_endstop=(READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING);
441
-            if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){
442
-              endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
443
-              endstop_x_hit=true;
444
-              step_events_completed = current_block->step_event_count;
428
+        else 
429
+        { // +direction
430
+            #ifdef DUAL_X_CARRIAGE
431
+            // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
432
+            if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) || (current_block->active_extruder != 0 && X2_HOME_DIR == 1))
433
+            #endif          
434
+            {
435
+                #if defined(X_MAX_PIN) && X_MAX_PIN > -1
436
+                bool x_max_endstop=(READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING);
437
+                if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0))
438
+                {
439
+                    endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
440
+                    endstop_x_hit=true;
441
+                    step_events_completed = current_block->step_event_count;
442
+                }
443
+                old_x_max_endstop = x_max_endstop;
444
+                #endif
445 445
             }
446
-            old_x_max_endstop = x_max_endstop;
447
-          #endif
448 446
         }
449
-      }
450
-    }
451 447
 
452
-    #ifndef COREXY
453
-    if ((out_bits & (1<<Y_AXIS)) != 0)   // -direction
454
-    #else
455
-    if ((out_bits & (1<<Y_HEAD)) != 0)  //AlexBorro: Head direction in -Y axis for CoreXY bots.
456
-    #endif
457
-    {
458
-      CHECK_ENDSTOPS
459
-      {
460
-        #if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
461
-          bool y_min_endstop=(READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING);
462
-          if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) {
463
-            endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
464
-            endstop_y_hit=true;
465
-            step_events_completed = current_block->step_event_count;
466
-          }
467
-          old_y_min_endstop = y_min_endstop;
468
-        #endif
469
-      }
470
-    }
471
-    else 
472
-    { // +direction
473
-      CHECK_ENDSTOPS
474
-      {
475
-        #if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
476
-          bool y_max_endstop=(READ(Y_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING);
477
-          if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){
478
-            endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
479
-            endstop_y_hit=true;
480
-            step_events_completed = current_block->step_event_count;
481
-          }
482
-          old_y_max_endstop = y_max_endstop;
448
+        #ifndef COREXY
449
+        if ((out_bits & (1<<Y_AXIS)) != 0)   // -direction
450
+        #else
451
+        if (!((current_block->steps_x == current_block->steps_y) && ((out_bits & (1<<X_AXIS))>>X_AXIS == (out_bits & (1<<Y_AXIS))>>Y_AXIS))) // AlexBorro: If DeltaX == DeltaY, the movement is only in X axis
452
+        if ((out_bits & (1<<Y_HEAD)) != 0)  //AlexBorro: Head direction in -Y axis for CoreXY bots.
483 453
         #endif
484
-      }
454
+        { // -direction
455
+            #if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
456
+            bool y_min_endstop=(READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING);
457
+            if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0))
458
+            {
459
+                endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
460
+                endstop_y_hit=true;
461
+                step_events_completed = current_block->step_event_count;
462
+            }
463
+            old_y_min_endstop = y_min_endstop;
464
+            #endif
465
+        }
466
+        else 
467
+        { // +direction
468
+            #if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
469
+            bool y_max_endstop=(READ(Y_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING);
470
+            if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0))
471
+            {
472
+                endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
473
+                endstop_y_hit=true;
474
+                step_events_completed = current_block->step_event_count;
475
+            }
476
+            old_y_max_endstop = y_max_endstop;
477
+            #endif
478
+
479
+        }
485 480
     }
486 481
 
487 482
     if ((out_bits & (1<<Z_AXIS)) != 0) {   // -direction

+ 39
- 72
Marlin/temperature.h View File

@@ -85,55 +85,25 @@ extern float current_temperature_bed;
85 85
 //inline so that there is no performance decrease.
86 86
 //deg=degreeCelsius
87 87
 
88
-FORCE_INLINE float degHotend(uint8_t extruder) {  
89
-  return current_temperature[extruder];
90
-};
88
+FORCE_INLINE float degHotend(uint8_t extruder) { return current_temperature[extruder]; }
89
+FORCE_INLINE float degBed() { return current_temperature_bed; }
91 90
 
92 91
 #ifdef SHOW_TEMP_ADC_VALUES
93
-  FORCE_INLINE float rawHotendTemp(uint8_t extruder) {  
94
-    return current_temperature_raw[extruder];
95
-  };
96
-
97
-  FORCE_INLINE float rawBedTemp() {  
98
-    return current_temperature_bed_raw;
99
-  };
92
+  FORCE_INLINE float rawHotendTemp(uint8_t extruder) { return current_temperature_raw[extruder]; }
93
+  FORCE_INLINE float rawBedTemp() { return current_temperature_bed_raw; }
100 94
 #endif
101 95
 
102
-FORCE_INLINE float degBed() {
103
-  return current_temperature_bed;
104
-};
105
-
106
-FORCE_INLINE float degTargetHotend(uint8_t extruder) {  
107
-  return target_temperature[extruder];
108
-};
109
-
110
-FORCE_INLINE float degTargetBed() {   
111
-  return target_temperature_bed;
112
-};
113
-
114
-FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) {  
115
-  target_temperature[extruder] = celsius;
116
-};
117
-
118
-FORCE_INLINE void setTargetBed(const float &celsius) {  
119
-  target_temperature_bed = celsius;
120
-};
96
+FORCE_INLINE float degTargetHotend(uint8_t extruder) { return target_temperature[extruder]; }
97
+FORCE_INLINE float degTargetBed() { return target_temperature_bed; }
121 98
 
122
-FORCE_INLINE bool isHeatingHotend(uint8_t extruder){  
123
-  return target_temperature[extruder] > current_temperature[extruder];
124
-};
99
+FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { target_temperature[extruder] = celsius; }
100
+FORCE_INLINE void setTargetBed(const float &celsius) { target_temperature_bed = celsius; }
125 101
 
126
-FORCE_INLINE bool isHeatingBed() {
127
-  return target_temperature_bed > current_temperature_bed;
128
-};
102
+FORCE_INLINE bool isHeatingHotend(uint8_t extruder) { return target_temperature[extruder] > current_temperature[extruder]; }
103
+FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }
129 104
 
130
-FORCE_INLINE bool isCoolingHotend(uint8_t extruder) {  
131
-  return target_temperature[extruder] < current_temperature[extruder];
132
-};
133
-
134
-FORCE_INLINE bool isCoolingBed() {
135
-  return target_temperature_bed < current_temperature_bed;
136
-};
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; }
137 107
 
138 108
 #define degHotend0() degHotend(0)
139 109
 #define degTargetHotend0() degTargetHotend(0)
@@ -141,38 +111,36 @@ FORCE_INLINE bool isCoolingBed() {
141 111
 #define isHeatingHotend0() isHeatingHotend(0)
142 112
 #define isCoolingHotend0() isCoolingHotend(0)
143 113
 #if EXTRUDERS > 1
144
-#define degHotend1() degHotend(1)
145
-#define degTargetHotend1() degTargetHotend(1)
146
-#define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1)
147
-#define isHeatingHotend1() isHeatingHotend(1)
148
-#define isCoolingHotend1() isCoolingHotend(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)
149 119
 #else
150
-#define setTargetHotend1(_celsius) do{}while(0)
120
+  #define setTargetHotend1(_celsius) do{}while(0)
151 121
 #endif
152 122
 #if EXTRUDERS > 2
153
-#define degHotend2() degHotend(2)
154
-#define degTargetHotend2() degTargetHotend(2)
155
-#define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2)
156
-#define isHeatingHotend2() isHeatingHotend(2)
157
-#define isCoolingHotend2() isCoolingHotend(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)
158 128
 #else
159
-#define setTargetHotend2(_celsius) do{}while(0)
129
+  #define setTargetHotend2(_celsius) do{}while(0)
160 130
 #endif
161 131
 #if EXTRUDERS > 3
162
-#define degHotend3() degHotend(3)
163
-#define degTargetHotend3() degTargetHotend(3)
164
-#define setTargetHotend3(_celsius) setTargetHotend((_celsius), 3)
165
-#define isHeatingHotend3() isHeatingHotend(3)
166
-#define isCoolingHotend3() isCoolingHotend(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)
167 137
 #else
168
-#define setTargetHotend3(_celsius) do{}while(0)
138
+  #define setTargetHotend3(_celsius) do{}while(0)
169 139
 #endif
170 140
 #if EXTRUDERS > 4
171
-#error Invalid number of extruders
141
+  #error Invalid number of extruders
172 142
 #endif
173 143
 
174
-
175
-
176 144
 int getHeaterPower(int heater);
177 145
 void disable_heater();
178 146
 void setWatch();
@@ -189,15 +157,14 @@ static bool thermal_runaway = false;
189 157
 #endif
190 158
 #endif
191 159
 
192
-FORCE_INLINE void autotempShutdown(){
193
-#ifdef AUTOTEMP
194
-  if(autotemp_enabled)
195
-  {
196
-    autotemp_enabled=false;
197
-    if(degTargetHotend(active_extruder)>autotemp_min)
198
-      setTargetHotend(0,active_extruder);
199
-  }
200
-#endif
160
+FORCE_INLINE void autotempShutdown() {
161
+  #ifdef AUTOTEMP
162
+    if (autotemp_enabled) {
163
+      autotemp_enabled = false;
164
+      if (degTargetHotend(active_extruder) > autotemp_min)
165
+        setTargetHotend(0, active_extruder);
166
+    }
167
+  #endif
201 168
 }
202 169
 
203 170
 void PID_autotune(float temp, int extruder, int ncycles);

+ 12
- 2
README.md View File

@@ -1,4 +1,14 @@
1
-# Marlin 3D Printer Firmware
1
+# Marlin 3D Printer Firmware Package for Felix 2.0/3.0
2
+
3
+## Felix Modifications
4
+
5
+This is a snapshot of upstream Marlin from 20150301 modified to be
6
+used directly with Felix Electronic Boards and Printers. Dual-Head
7
+has been activated but is not tested. Neither are LCD and SDCARD
8
+since Ocotprint is in use here. A pull-request to have direct
9
+upstream hardware support has already been submitted.
10
+
11
+
2 12
 <img align="right" src="Documentation/Logo/Marlin%20Logo%20GitHub.png" />
3 13
 
4 14
   * [Configuration & Compilation](/Documentation/Compilation.md)
@@ -41,7 +51,7 @@ The current Marlin dev team consists of:
41 51
 
42 52
  - Erik van der Zalm ([@ErikZalm](https://github.com/ErikZalm))
43 53
  - [@daid](https://github.com/daid)
44
- 
54
+
45 55
 Sprinters lead developers are Kliment and caru.
46 56
 Grbls lead developer is Simen Svale Skogsrud.
47 57
 Sonney Jeon (Chamnit) improved some parts of grbl

Loading…
Cancel
Save