Browse Source

Merge remote-tracking branch 'remotes/upstream/Development' into Development

domonoky 9 years ago
parent
commit
4a7aca2736

+ 1
- 1
ArduinoAddons/Arduino_1.5.x/hardware/marlin/avr/boards.txt View File

33
 ########################################
33
 ########################################
34
 sanguino.name=Sanguino
34
 sanguino.name=Sanguino
35
 
35
 
36
-sanguino.upload.tool=ardunio:avrdude
36
+sanguino.upload.tool=arduino:avrdude
37
 sanguino.upload.protocol=stk500
37
 sanguino.upload.protocol=stk500
38
 sanguino.upload.maximum_size=131072
38
 sanguino.upload.maximum_size=131072
39
 sanguino.upload.speed=57600
39
 sanguino.upload.speed=57600

+ 1
- 8
Marlin/BlinkM.cpp View File

5
 #include "Marlin.h"
5
 #include "Marlin.h"
6
 #ifdef BLINKM
6
 #ifdef BLINKM
7
 
7
 
8
-#if (ARDUINO >= 100)
9
-  # include "Arduino.h"
10
-#else
11
-  # include "WProgram.h"
12
-#endif
13
-
14
 #include "BlinkM.h"
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
   Wire.begin(); 
11
   Wire.begin(); 
19
   Wire.beginTransmission(0x09);
12
   Wire.beginTransmission(0x09);
20
   Wire.write('o');                    //to disable ongoing script, only needs to be used once
13
   Wire.write('o');                    //to disable ongoing script, only needs to be used once

+ 3
- 4
Marlin/BlinkM.h View File

2
   BlinkM.h
2
   BlinkM.h
3
   Library header file for BlinkM library
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
 #else
7
 #else
8
-  # include "WProgram.h"
8
+  #include "WProgram.h"
9
 #endif
9
 #endif
10
 
10
 
11
 #include "Wire.h"
11
 #include "Wire.h"
12
 
12
 
13
 void SendColors(byte red, byte grn, byte blu);
13
 void SendColors(byte red, byte grn, byte blu);
14
-

+ 12
- 1
Marlin/Configuration.h View File

118
 // 1010 is Pt1000 with 1k pullup (non standard)
118
 // 1010 is Pt1000 with 1k pullup (non standard)
119
 // 147 is Pt100 with 4k7 pullup
119
 // 147 is Pt100 with 4k7 pullup
120
 // 110 is Pt100 with 1k pullup (non standard)
120
 // 110 is Pt100 with 1k pullup (non standard)
121
-// 999 is a Dummy Table. It will ALWAYS read 25C.. Use it for Testing or Development purposes. NEVER for production machine.
121
+// 998 and 999 are Dummy Tables. They will ALWAYS read 25°C or the temperature defined below. 
122
+//     Use it for Testing or Development purposes. NEVER for production machine.
123
+//     #define DUMMY_THERMISTOR_998_VALUE 25
124
+//     #define DUMMY_THERMISTOR_999_VALUE 100
122
 
125
 
123
 #define TEMP_SENSOR_0 -1
126
 #define TEMP_SENSOR_0 -1
124
 #define TEMP_SENSOR_1 -1
127
 #define TEMP_SENSOR_1 -1
582
 //#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
585
 //#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
583
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
586
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
584
 
587
 
588
+// PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
589
+// http://reprap.org/wiki/PanelOne
590
+//#define PANEL_ONE
591
+
585
 // The MaKr3d Makr-Panel with graphic controller and SD support
592
 // The MaKr3d Makr-Panel with graphic controller and SD support
586
 // http://reprap.org/wiki/MaKr3d_MaKrPanel
593
 // http://reprap.org/wiki/MaKr3d_MaKrPanel
587
 //#define MAKRPANEL
594
 //#define MAKRPANEL
640
  #define ENCODER_STEPS_PER_MENU_ITEM 1
647
  #define ENCODER_STEPS_PER_MENU_ITEM 1
641
 #endif
648
 #endif
642
 
649
 
650
+#if defined (PANEL_ONE)
651
+ #define SDSUPPORT
652
+ #define ULTIMAKERCONTROLLER
653
+#endif
643
 
654
 
644
 #if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
655
 #if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
645
  #define DOGLCD
656
  #define DOGLCD

+ 3
- 3
Marlin/ConfigurationStore.h View File

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

+ 2
- 2
Marlin/Marlin.h View File

180
   #define disable_e3() /* nothing */
180
   #define disable_e3() /* nothing */
181
 #endif
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
 void FlushSerialRequestResend();
186
 void FlushSerialRequestResend();
187
 void ClearToSend();
187
 void ClearToSend();

+ 32
- 27
Marlin/Marlin_main.cpp View File

1720
 
1720
 
1721
 #ifdef ENABLE_AUTO_BED_LEVELING
1721
 #ifdef ENABLE_AUTO_BED_LEVELING
1722
     case 29: // G29 Detailed Z-Probe, probes the bed at 3 or more points.
1722
     case 29: // G29 Detailed Z-Probe, probes the bed at 3 or more points.
1723
+    	     // Override probing area by providing [F]ront [B]ack [L]eft [R]ight Grid[P]oints values
1723
         {
1724
         {
1724
             #if Z_MIN_PIN == -1
1725
             #if Z_MIN_PIN == -1
1725
             #error "You must have a Z_MIN endstop in order to enable Auto Bed Leveling feature!!! Z_MIN_PIN must point to a valid hardware pin."
1726
             #error "You must have a Z_MIN endstop in order to enable Auto Bed Leveling feature!!! Z_MIN_PIN must point to a valid hardware pin."
1753
             feedrate = homing_feedrate[Z_AXIS];
1754
             feedrate = homing_feedrate[Z_AXIS];
1754
 #ifdef AUTO_BED_LEVELING_GRID
1755
 #ifdef AUTO_BED_LEVELING_GRID
1755
             // probe at the points of a lattice grid
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();
1756
 
1767
 
1757
-            int xGridSpacing = (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION) / (AUTO_BED_LEVELING_GRID_POINTS-1);
1758
-            int yGridSpacing = (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION) / (AUTO_BED_LEVELING_GRID_POINTS-1);
1768
+            int xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (auto_bed_leveling_grid_points-1);
1769
+            int yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (auto_bed_leveling_grid_points-1);
1759
 
1770
 
1760
 
1771
 
1761
             // solve the plane equation ax + by + d = z
1772
             // solve the plane equation ax + by + d = z
1765
             // so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
1776
             // so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
1766
 
1777
 
1767
             // "A" matrix of the linear system of equations
1778
             // "A" matrix of the linear system of equations
1768
-            double eqnAMatrix[AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS*3];
1779
+            double eqnAMatrix[auto_bed_leveling_grid_points*auto_bed_leveling_grid_points*3];
1780
+
1769
             // "B" vector of Z points
1781
             // "B" vector of Z points
1770
-            double eqnBVector[AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS];
1782
+            double eqnBVector[auto_bed_leveling_grid_points*auto_bed_leveling_grid_points];
1783
+
1771
 
1784
 
1772
 
1785
 
1773
             int probePointCounter = 0;
1786
             int probePointCounter = 0;
1774
             bool zig = true;
1787
             bool zig = true;
1775
 
1788
 
1776
-            for (int yProbe=FRONT_PROBE_BED_POSITION; yProbe <= BACK_PROBE_BED_POSITION; yProbe += yGridSpacing)
1789
+            for (int yProbe=front_probe_bed_position; yProbe <= back_probe_bed_position; yProbe += yGridSpacing)
1790
+
1777
             {
1791
             {
1778
               int xProbe, xInc;
1792
               int xProbe, xInc;
1779
               if (zig)
1793
               if (zig)
1780
               {
1794
               {
1781
-                xProbe = LEFT_PROBE_BED_POSITION;
1782
-                //xEnd = RIGHT_PROBE_BED_POSITION;
1795
+                xProbe = left_probe_bed_position;
1796
+                //xEnd = right_probe_bed_position;
1783
                 xInc = xGridSpacing;
1797
                 xInc = xGridSpacing;
1784
                 zig = false;
1798
                 zig = false;
1785
               } else // zag
1799
               } else // zag
1786
               {
1800
               {
1787
-                xProbe = RIGHT_PROBE_BED_POSITION;
1788
-                //xEnd = LEFT_PROBE_BED_POSITION;
1801
+                xProbe = right_probe_bed_position;
1802
+                //xEnd = left_probe_bed_position;
1789
                 xInc = -xGridSpacing;
1803
                 xInc = -xGridSpacing;
1790
                 zig = true;
1804
                 zig = true;
1791
               }
1805
               }
1792
 
1806
 
1793
-              for (int xCount=0; xCount < AUTO_BED_LEVELING_GRID_POINTS; xCount++)
1807
+              for (int xCount=0; xCount < auto_bed_leveling_grid_points; xCount++)
1794
               {
1808
               {
1795
                 float z_before;
1809
                 float z_before;
1796
                 if (probePointCounter == 0)
1810
                 if (probePointCounter == 0)
1822
 
1836
 
1823
                 eqnBVector[probePointCounter] = measured_z;
1837
                 eqnBVector[probePointCounter] = measured_z;
1824
 
1838
 
1825
-                eqnAMatrix[probePointCounter + 0*AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS] = xProbe;
1826
-                eqnAMatrix[probePointCounter + 1*AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS] = yProbe;
1827
-                eqnAMatrix[probePointCounter + 2*AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS] = 1;
1839
+                eqnAMatrix[probePointCounter + 0*auto_bed_leveling_grid_points*auto_bed_leveling_grid_points] = xProbe;
1840
+                eqnAMatrix[probePointCounter + 1*auto_bed_leveling_grid_points*auto_bed_leveling_grid_points] = yProbe;
1841
+                eqnAMatrix[probePointCounter + 2*auto_bed_leveling_grid_points*auto_bed_leveling_grid_points] = 1;
1828
                 probePointCounter++;
1842
                 probePointCounter++;
1829
                 xProbe += xInc;
1843
                 xProbe += xInc;
1830
               }
1844
               }
1832
             clean_up_after_endstop_move();
1846
             clean_up_after_endstop_move();
1833
 
1847
 
1834
             // solve lsq problem
1848
             // solve lsq problem
1835
-            double *plane_equation_coefficients = qr_solve(AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS, 3, eqnAMatrix, eqnBVector);
1849
+            double *plane_equation_coefficients = qr_solve(auto_bed_leveling_grid_points*auto_bed_leveling_grid_points, 3, eqnAMatrix, eqnBVector);
1836
 
1850
 
1837
             SERIAL_PROTOCOLPGM("Eqn coefficients: a: ");
1851
             SERIAL_PROTOCOLPGM("Eqn coefficients: a: ");
1838
             SERIAL_PROTOCOL(plane_equation_coefficients[0]);
1852
             SERIAL_PROTOCOL(plane_equation_coefficients[0]);
4695
 
4709
 
4696
 
4710
 
4697
 float calculate_volumetric_multiplier(float diameter) {
4711
 float calculate_volumetric_multiplier(float diameter) {
4698
-	float area = .0;
4699
-	float radius = .0;
4700
-
4701
-	radius = diameter * .5;
4702
-	if (! volumetric_enabled || radius == 0) {
4703
-		area = 1;
4704
-	}
4705
-	else {
4706
-		area = M_PI * pow(radius, 2);
4707
-	}
4708
-
4709
-	return 1.0 / area;
4712
+  if (!volumetric_enabled || diameter == 0) return 1.0;
4713
+  float d2 = diameter * 0.5;
4714
+  return 1.0 / (M_PI * d2 * d2);
4710
 }
4715
 }
4711
 
4716
 
4712
 void calculate_volumetric_multipliers() {
4717
 void calculate_volumetric_multipliers() {
4713
   for (int i=0; i<EXTRUDERS; i++)
4718
   for (int i=0; i<EXTRUDERS; i++)
4714
-  	volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
4719
+    volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
4715
 }
4720
 }

+ 252
- 378
Marlin/cardreader.cpp View File

7
 
7
 
8
 #ifdef SDSUPPORT
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
   //power to SD reader
23
   //power to SD reader
28
   #if SDPOWER > -1
24
   #if SDPOWER > -1
29
-    SET_OUTPUT(SDPOWER); 
30
-    WRITE(SDPOWER,HIGH);
25
+    SET_OUTPUT(SDPOWER);
26
+    WRITE(SDPOWER, HIGH);
31
   #endif //SDPOWER
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
   return buffer;
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
   dir_t p;
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
       char path[FILENAME_LENGTH*2];
49
       char path[FILENAME_LENGTH*2];
64
       char lfilename[FILENAME_LENGTH];
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
       //Serial.print(path);
59
       //Serial.print(path);
77
-      
60
+
78
       SdFile dir;
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
           SERIAL_ECHO_START;
64
           SERIAL_ECHO_START;
84
           SERIAL_ECHOLN(MSG_SD_CANT_OPEN_SUBDIR);
65
           SERIAL_ECHOLN(MSG_SD_CANT_OPEN_SUBDIR);
85
           SERIAL_ECHOLN(lfilename);
66
           SERIAL_ECHOLN(lfilename);
86
         }
67
         }
87
       }
68
       }
88
-      lsDive(path,dir);
69
+      lsDive(path, dir);
89
       //close done automatically by destructor of SdFile
70
       //close done automatically by destructor of SdFile
90
-
91
-      
92
     }
71
     }
93
-    else
94
-    {
72
+    else {
95
       char pn0 = p.name[0];
73
       char pn0 = p.name[0];
96
       if (pn0 == DIR_NAME_FREE) break;
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
       char lf0 = longFilename[0];
76
       char lf0 = longFilename[0];
99
-      if (lf0 == '.' || lf0 == '_') continue;
77
+      if (lf0 == '.') continue;
100
 
78
 
101
       if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
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
         SERIAL_PROTOCOL(prepend);
88
         SERIAL_PROTOCOL(prepend);
115
         SERIAL_PROTOCOLLN(filename);
89
         SERIAL_PROTOCOLLN(filename);
116
       }
90
       }
117
-      else if(lsAction==LS_Count)
118
-      {
91
+      else if (lsAction == LS_Count) {
119
         nrFiles++;
92
         nrFiles++;
120
-      } 
121
-      else if(lsAction==LS_GetFilename)
122
-      {
93
+      }
94
+      else if (lsAction == LS_GetFilename) {
123
         if (match != NULL) {
95
         if (match != NULL) {
124
           if (strcasecmp(match, filename) == 0) return;
96
           if (strcasecmp(match, filename) == 0) return;
125
         }
97
         }
126
         else if (cnt == nrFiles) return;
98
         else if (cnt == nrFiles) return;
127
         cnt++;
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
   root.rewind();
107
   root.rewind();
141
-  lsDive("",root);
108
+  lsDive("", root);
142
 }
109
 }
143
 
110
 
144
-
145
-void CardReader::initsd()
146
-{
111
+void CardReader::initsd() {
147
   cardOK = false;
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
   #endif
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
     //if (!card.init(SPI_HALF_SPEED,SDSS))
126
     //if (!card.init(SPI_HALF_SPEED,SDSS))
165
     SERIAL_ECHO_START;
127
     SERIAL_ECHO_START;
166
     SERIAL_ECHOLNPGM(MSG_SD_INIT_FAIL);
128
     SERIAL_ECHOLNPGM(MSG_SD_INIT_FAIL);
167
   }
129
   }
168
-  else if (!volume.init(&card))
169
-  {
130
+  else if (!volume.init(&card)) {
170
     SERIAL_ERROR_START;
131
     SERIAL_ERROR_START;
171
     SERIAL_ERRORLNPGM(MSG_SD_VOL_INIT_FAIL);
132
     SERIAL_ERRORLNPGM(MSG_SD_VOL_INIT_FAIL);
172
   }
133
   }
173
-  else if (!root.openRoot(&volume)) 
174
-  {
134
+  else if (!root.openRoot(&volume)) {
175
     SERIAL_ERROR_START;
135
     SERIAL_ERROR_START;
176
     SERIAL_ERRORLNPGM(MSG_SD_OPENROOT_FAIL);
136
     SERIAL_ERRORLNPGM(MSG_SD_OPENROOT_FAIL);
177
   }
137
   }
178
-  else 
179
-  {
138
+  else {
180
     cardOK = true;
139
     cardOK = true;
181
     SERIAL_ECHO_START;
140
     SERIAL_ECHO_START;
182
     SERIAL_ECHOLNPGM(MSG_SD_CARD_OK);
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
     SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL);
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
     SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL);
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
   sdprinting = false;
161
   sdprinting = false;
208
   cardOK = false;
162
   cardOK = false;
209
 }
163
 }
210
 
164
 
211
-void CardReader::startFileprint()
212
-{
213
-  if(cardOK)
214
-  {
165
+void CardReader::startFileprint() {
166
+  if (cardOK) {
215
     sdprinting = true;
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
   logging = true;
176
   logging = true;
231
   openFile(name, false);
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
     workDirParents[i].getFilename(t); //SDBaseFile.getfilename!
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
     file.getFilename(t);
188
     file.getFilename(t);
246
   else
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
        SERIAL_ERROR_START;
198
        SERIAL_ERROR_START;
261
        SERIAL_ERRORPGM("trying to call sub-gcode files with too many levels. MAX level is:");
199
        SERIAL_ERRORPGM("trying to call sub-gcode files with too many levels. MAX level is:");
262
        SERIAL_ERRORLN(SD_PROCEDURE_DEPTH);
200
        SERIAL_ERRORLN(SD_PROCEDURE_DEPTH);
263
        kill();
201
        kill();
264
        return;
202
        return;
265
      }
203
      }
266
-     
204
+
267
      SERIAL_ECHO_START;
205
      SERIAL_ECHO_START;
268
      SERIAL_ECHOPGM("SUBROUTINE CALL target:\"");
206
      SERIAL_ECHOPGM("SUBROUTINE CALL target:\"");
269
      SERIAL_ECHO(name);
207
      SERIAL_ECHO(name);
270
      SERIAL_ECHOPGM("\" parent:\"");
208
      SERIAL_ECHOPGM("\" parent:\"");
271
-     
209
+
272
      //store current filename and position
210
      //store current filename and position
273
      getAbsFilename(filenames[file_subcall_ctr]);
211
      getAbsFilename(filenames[file_subcall_ctr]);
274
-     
212
+
275
      SERIAL_ECHO(filenames[file_subcall_ctr]);
213
      SERIAL_ECHO(filenames[file_subcall_ctr]);
276
      SERIAL_ECHOPGM("\" pos");
214
      SERIAL_ECHOPGM("\" pos");
277
      SERIAL_ECHOLN(sdpos);
215
      SERIAL_ECHOLN(sdpos);
278
-     filespos[file_subcall_ctr]=sdpos;
216
+     filespos[file_subcall_ctr] = sdpos;
279
      file_subcall_ctr++;
217
      file_subcall_ctr++;
280
     }
218
     }
281
-    else
282
-    {
219
+    else {
283
      SERIAL_ECHO_START;
220
      SERIAL_ECHO_START;
284
      SERIAL_ECHOPGM("Now doing file: ");
221
      SERIAL_ECHOPGM("Now doing file: ");
285
      SERIAL_ECHOLN(name);
222
      SERIAL_ECHOLN(name);
286
     }
223
     }
287
     file.close();
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
     SERIAL_ECHO_START;
228
     SERIAL_ECHO_START;
293
     SERIAL_ECHOPGM("Now fresh file: ");
229
     SERIAL_ECHOPGM("Now fresh file: ");
294
     SERIAL_ECHOLN(name);
230
     SERIAL_ECHOLN(name);
295
   }
231
   }
296
   sdprinting = false;
232
   sdprinting = false;
297
-  
298
- 
233
+
299
   SdFile myDir;
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
         char subdirname[FILENAME_LENGTH];
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
         SERIAL_ECHOLN(subdirname);
249
         SERIAL_ECHOLN(subdirname);
318
-        if(!myDir.open(curDir,subdirname,O_READ))
319
-        {
250
+        if (!myDir.open(curDir, subdirname, O_READ)) {
320
           SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
251
           SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
321
           SERIAL_PROTOCOL(subdirname);
252
           SERIAL_PROTOCOL(subdirname);
322
           SERIAL_PROTOCOLLNPGM(".");
253
           SERIAL_PROTOCOLLNPGM(".");
323
           return;
254
           return;
324
         }
255
         }
325
-        else
326
-        {
256
+        else {
327
           //SERIAL_ECHOLN("dive ok");
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
         //SERIAL_ECHOLN(fname);
266
         //SERIAL_ECHOLN(fname);
338
         break;
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
       filesize = file.fileSize();
277
       filesize = file.fileSize();
352
       SERIAL_PROTOCOLPGM(MSG_SD_FILE_OPENED);
278
       SERIAL_PROTOCOLPGM(MSG_SD_FILE_OPENED);
353
       SERIAL_PROTOCOL(fname);
279
       SERIAL_PROTOCOL(fname);
354
       SERIAL_PROTOCOLPGM(MSG_SD_SIZE);
280
       SERIAL_PROTOCOLPGM(MSG_SD_SIZE);
355
       SERIAL_PROTOCOLLN(filesize);
281
       SERIAL_PROTOCOLLN(filesize);
356
       sdpos = 0;
282
       sdpos = 0;
357
-      
283
+
358
       SERIAL_PROTOCOLLNPGM(MSG_SD_FILE_SELECTED);
284
       SERIAL_PROTOCOLLNPGM(MSG_SD_FILE_SELECTED);
359
       getfilename(0, fname);
285
       getfilename(0, fname);
360
       lcd_setstatus(longFilename[0] ? longFilename : fname);
286
       lcd_setstatus(longFilename[0] ? longFilename : fname);
361
     }
287
     }
362
-    else
363
-    {
288
+    else {
364
       SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
289
       SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
365
       SERIAL_PROTOCOL(fname);
290
       SERIAL_PROTOCOL(fname);
366
       SERIAL_PROTOCOLLNPGM(".");
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
       SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
296
       SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
374
       SERIAL_PROTOCOL(fname);
297
       SERIAL_PROTOCOL(fname);
375
       SERIAL_PROTOCOLLNPGM(".");
298
       SERIAL_PROTOCOLLNPGM(".");
376
     }
299
     }
377
-    else
378
-    {
300
+    else {
379
       saving = true;
301
       saving = true;
380
       SERIAL_PROTOCOLPGM(MSG_SD_WRITE_TO_FILE);
302
       SERIAL_PROTOCOLPGM(MSG_SD_WRITE_TO_FILE);
381
       SERIAL_PROTOCOLLN(name);
303
       SERIAL_PROTOCOLLN(name);
382
       lcd_setstatus(fname);
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
   file.close();
312
   file.close();
393
   sdprinting = false;
313
   sdprinting = false;
394
-  
395
-  
314
+
396
   SdFile myDir;
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
         char subdirname[FILENAME_LENGTH];
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
         SERIAL_ECHOLN(subdirname);
330
         SERIAL_ECHOLN(subdirname);
415
-        if(!myDir.open(curDir,subdirname,O_READ))
416
-        {
331
+        if (!myDir.open(curDir, subdirname, O_READ)) {
417
           SERIAL_PROTOCOLPGM("open failed, File: ");
332
           SERIAL_PROTOCOLPGM("open failed, File: ");
418
           SERIAL_PROTOCOL(subdirname);
333
           SERIAL_PROTOCOL(subdirname);
419
           SERIAL_PROTOCOLLNPGM(".");
334
           SERIAL_PROTOCOLLNPGM(".");
420
           return;
335
           return;
421
         }
336
         }
422
-        else
423
-        {
337
+        else {
424
           //SERIAL_ECHOLN("dive ok");
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
         //SERIAL_ECHOLN(fname);
347
         //SERIAL_ECHOLN(fname);
435
         break;
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
     SERIAL_PROTOCOLPGM(MSG_SD_PRINTING_BYTE);
370
     SERIAL_PROTOCOLPGM(MSG_SD_PRINTING_BYTE);
463
     SERIAL_PROTOCOL(sdpos);
371
     SERIAL_PROTOCOL(sdpos);
464
     SERIAL_PROTOCOLPGM("/");
372
     SERIAL_PROTOCOLPGM("/");
465
     SERIAL_PROTOCOLLN(filesize);
373
     SERIAL_PROTOCOLLN(filesize);
466
   }
374
   }
467
-  else{
375
+  else {
468
     SERIAL_PROTOCOLLNPGM(MSG_SD_NOT_PRINTING);
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
   char* begin = buf;
381
   char* begin = buf;
474
   char* npos = 0;
382
   char* npos = 0;
475
   char* end = buf + strlen(buf) - 1;
383
   char* end = buf + strlen(buf) - 1;
476
 
384
 
477
   file.writeError = false;
385
   file.writeError = false;
478
-  if((npos = strchr(buf, 'N')) != NULL)
479
-  {
386
+  if ((npos = strchr(buf, 'N')) != NULL) {
480
     begin = strchr(npos, ' ') + 1;
387
     begin = strchr(npos, ' ') + 1;
481
     end = strchr(npos, '*') - 1;
388
     end = strchr(npos, '*') - 1;
482
   }
389
   }
484
   end[2] = '\n';
391
   end[2] = '\n';
485
   end[3] = '\0';
392
   end[3] = '\0';
486
   file.write(begin);
393
   file.write(begin);
487
-  if (file.writeError)
488
-  {
394
+  if (file.writeError) {
489
     SERIAL_ERROR_START;
395
     SERIAL_ERROR_START;
490
     SERIAL_ERRORLNPGM(MSG_SD_ERR_WRITE_TO_FILE);
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
     initsd();
407
     initsd();
508
-    if(!cardOK) //fail
509
-      return;
408
+    if (!cardOK) return; // fail
510
   }
409
   }
511
-  
410
+
512
   char autoname[30];
411
   char autoname[30];
513
   sprintf_P(autoname, PSTR("auto%i.g"), autostart_index);
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
   dir_t p;
415
   dir_t p;
517
 
416
 
518
   root.rewind();
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
       sprintf_P(cmd, PSTR("M23 %s"), autoname);
424
       sprintf_P(cmd, PSTR("M23 %s"), autoname);
534
       enquecommand(cmd);
425
       enquecommand(cmd);
535
       enquecommands_P(PSTR("M24"));
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
   else
432
   else
542
     autostart_index++;
433
     autostart_index++;
543
 }
434
 }
544
 
435
 
545
-void CardReader::closefile(bool store_location)
546
-{
436
+void CardReader::closefile(bool store_location) {
547
   file.sync();
437
   file.sync();
548
   file.close();
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
     //future: store printer state, filename and position for continuing a stopped print
442
     //future: store printer state, filename and position for continuing a stopped print
555
     // so one can unplug the printer and continue printing the next day.
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
   curDir->rewind();
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
   curDir->rewind();
462
   curDir->rewind();
578
-  lsDive("",*curDir);
463
+  lsDive("", *curDir);
579
   //SERIAL_ECHOLN(nrFiles);
464
   //SERIAL_ECHOLN(nrFiles);
580
   return nrFiles;
465
   return nrFiles;
581
 }
466
 }
582
 
467
 
583
-void CardReader::chdir(const char * relpath)
584
-{
468
+void CardReader::chdir(const char * relpath) {
585
   SdFile newfile;
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
     if (workDirDepth < MAX_DIR_DEPTH) {
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
     --workDirDepth;
491
     --workDirDepth;
613
     workDir = workDirParents[0];
492
     workDir = workDirParents[0];
614
-    int d;
615
     for (int d = 0; d < workDirDepth; d++)
493
     for (int d = 0; d < workDirDepth; d++)
616
       workDirParents[d] = workDirParents[d+1];
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
 #endif //SDSUPPORT
519
 #endif //SDSUPPORT

+ 30
- 34
Marlin/cardreader.h View File

3
 
3
 
4
 #ifdef SDSUPPORT
4
 #ifdef SDSUPPORT
5
 
5
 
6
-#define MAX_DIR_DEPTH 10
6
+#define MAX_DIR_DEPTH 10          // Maximum folder depth
7
 
7
 
8
 #include "SdFile.h"
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
 public:
12
 public:
13
   CardReader();
13
   CardReader();
14
-  
14
+
15
   void initsd();
15
   void initsd();
16
   void write_command(char *buf);
16
   void write_command(char *buf);
17
   //files auto[0-9].g on the sd card are performed in a row
17
   //files auto[0-9].g on the sd card are performed in a row
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
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
   void openFile(char* name,bool read,bool replace_current=true);
21
   void openFile(char* name,bool read,bool replace_current=true);
22
   void openLogFile(char* name);
22
   void openLogFile(char* name);
23
   void removeFile(char* name);
23
   void removeFile(char* name);
30
 
30
 
31
   void getfilename(uint16_t nr, const char* const match=NULL);
31
   void getfilename(uint16_t nr, const char* const match=NULL);
32
   uint16_t getnrfilenames();
32
   uint16_t getnrfilenames();
33
-  
33
+
34
   void getAbsFilename(char *t);
34
   void getAbsFilename(char *t);
35
-  
36
 
35
 
37
   void ls();
36
   void ls();
38
   void chdir(const char * relpath);
37
   void chdir(const char * relpath);
41
 
40
 
42
 
41
 
43
   FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
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
 public:
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
   int autostart_index;
52
   int autostart_index;
59
 private:
53
 private:
60
-  SdFile root,*curDir,workDir,workDirParents[MAX_DIR_DEPTH];
54
+  SdFile root, *curDir, workDir, workDirParents[MAX_DIR_DEPTH];
61
   uint16_t workDirDepth;
55
   uint16_t workDirDepth;
62
   Sd2Card card;
56
   Sd2Card card;
63
   SdVolume volume;
57
   SdVolume volume;
64
   SdFile file;
58
   SdFile file;
65
   #define SD_PROCEDURE_DEPTH 1
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
   uint8_t file_subcall_ctr;
61
   uint8_t file_subcall_ctr;
68
   uint32_t filespos[SD_PROCEDURE_DEPTH];
62
   uint32_t filespos[SD_PROCEDURE_DEPTH];
69
   char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
63
   char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
70
   uint32_t filesize;
64
   uint32_t filesize;
71
-  //int16_t n;
72
   unsigned long autostart_atmillis;
65
   unsigned long autostart_atmillis;
73
-  uint32_t sdpos ;
66
+  uint32_t sdpos;
74
 
67
 
75
   bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
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
   LsAction lsAction; //stored for recursion.
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
   char* diveDirName;
72
   char* diveDirName;
80
   void lsDive(const char *prepend, SdFile parent, const char * const match=NULL);
73
   void lsDive(const char *prepend, SdFile parent, const char * const match=NULL);
81
 };
74
 };
75
+
82
 extern CardReader card;
76
 extern CardReader card;
77
+
83
 #define IS_SD_PRINTING (card.sdprinting)
78
 #define IS_SD_PRINTING (card.sdprinting)
84
 
79
 
85
 #if (SDCARDDETECT > -1)
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
 #else
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
 #endif
89
 #endif
95
 
90
 
96
 #else
91
 #else
98
 #define IS_SD_PRINTING (false)
93
 #define IS_SD_PRINTING (false)
99
 
94
 
100
 #endif //SDSUPPORT
95
 #endif //SDSUPPORT
101
-#endif
96
+
97
+#endif //__CARDREADER_H

+ 38
- 39
Marlin/digipot_mcp4451.cpp View File

1
 #include "Configuration.h"
1
 #include "Configuration.h"
2
 
2
 
3
 #ifdef DIGIPOT_I2C
3
 #ifdef DIGIPOT_I2C
4
+
4
 #include "Stream.h"
5
 #include "Stream.h"
5
 #include "utility/twi.h"
6
 #include "utility/twi.h"
6
 #include "Wire.h"
7
 #include "Wire.h"
7
 
8
 
8
 // Settings for the I2C based DIGIPOT (MCP4451) on Azteeg X3 Pro
9
 // Settings for the I2C based DIGIPOT (MCP4451) on Azteeg X3 Pro
9
 #if MB(5DPRINT)
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
 #else
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
 #endif
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
 // This is for the MCP4451 I2C based digipot
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

+ 8
- 0
Marlin/example_configurations/Hephestos/Configuration.h View File

587
 //#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
587
 //#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
588
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
588
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
589
 
589
 
590
+// PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
591
+// http://reprap.org/wiki/PanelOne
592
+//#define PANEL_ONE
593
+
590
 // The MaKr3d Makr-Panel with graphic controller and SD support
594
 // The MaKr3d Makr-Panel with graphic controller and SD support
591
 // http://reprap.org/wiki/MaKr3d_MaKrPanel
595
 // http://reprap.org/wiki/MaKr3d_MaKrPanel
592
 //#define MAKRPANEL
596
 //#define MAKRPANEL
645
  #define ENCODER_STEPS_PER_MENU_ITEM 1
649
  #define ENCODER_STEPS_PER_MENU_ITEM 1
646
 #endif
650
 #endif
647
 
651
 
652
+#if defined (PANEL_ONE)
653
+ #define SDSUPPORT
654
+ #define ULTIMAKERCONTROLLER
655
+#endif
648
 
656
 
649
 #if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
657
 #if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
650
  #define DOGLCD
658
  #define DOGLCD

+ 8
- 0
Marlin/example_configurations/K8200/Configuration.h View File

597
 //#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
597
 //#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
598
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
598
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
599
 
599
 
600
+// PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
601
+// http://reprap.org/wiki/PanelOne
602
+//#define PANEL_ONE
603
+
600
 // The MaKr3d Makr-Panel with graphic controller and SD support
604
 // The MaKr3d Makr-Panel with graphic controller and SD support
601
 // http://reprap.org/wiki/MaKr3d_MaKrPanel
605
 // http://reprap.org/wiki/MaKr3d_MaKrPanel
602
 //#define MAKRPANEL
606
 //#define MAKRPANEL
655
  #define ENCODER_STEPS_PER_MENU_ITEM 1
659
  #define ENCODER_STEPS_PER_MENU_ITEM 1
656
 #endif
660
 #endif
657
 
661
 
662
+#if defined (PANEL_ONE)
663
+ #define SDSUPPORT
664
+ #define ULTIMAKERCONTROLLER
665
+#endif
658
 
666
 
659
 #if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
667
 #if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
660
  #define DOGLCD
668
  #define DOGLCD

+ 8
- 0
Marlin/example_configurations/SCARA/Configuration.h View File

590
 //#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
590
 //#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
591
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
591
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
592
 
592
 
593
+// PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
594
+// http://reprap.org/wiki/PanelOne
595
+//#define PANEL_ONE
596
+
593
 // The MaKr3d Makr-Panel with graphic controller and SD support
597
 // The MaKr3d Makr-Panel with graphic controller and SD support
594
 // http://reprap.org/wiki/MaKr3d_MaKrPanel
598
 // http://reprap.org/wiki/MaKr3d_MaKrPanel
595
 //#define MAKRPANEL
599
 //#define MAKRPANEL
648
  #define ENCODER_STEPS_PER_MENU_ITEM 1
652
  #define ENCODER_STEPS_PER_MENU_ITEM 1
649
 #endif
653
 #endif
650
 
654
 
655
+#if defined (PANEL_ONE)
656
+ #define SDSUPPORT
657
+ #define ULTIMAKERCONTROLLER
658
+#endif
651
 
659
 
652
 #if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
660
 #if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
653
  #define DOGLCD
661
  #define DOGLCD

+ 8
- 0
Marlin/example_configurations/WITBOX/Configuration.h View File

591
 //#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
591
 //#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
592
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
592
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
593
 
593
 
594
+// PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
595
+// http://reprap.org/wiki/PanelOne
596
+//#define PANEL_ONE
597
+
594
 // The MaKr3d Makr-Panel with graphic controller and SD support
598
 // The MaKr3d Makr-Panel with graphic controller and SD support
595
 // http://reprap.org/wiki/MaKr3d_MaKrPanel
599
 // http://reprap.org/wiki/MaKr3d_MaKrPanel
596
 //#define MAKRPANEL
600
 //#define MAKRPANEL
649
  #define ENCODER_STEPS_PER_MENU_ITEM 1
653
  #define ENCODER_STEPS_PER_MENU_ITEM 1
650
 #endif
654
 #endif
651
 
655
 
656
+#if defined (PANEL_ONE)
657
+ #define SDSUPPORT
658
+ #define ULTIMAKERCONTROLLER
659
+#endif
652
 
660
 
653
 #if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
661
 #if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
654
  #define DOGLCD
662
  #define DOGLCD

+ 8
- 0
Marlin/example_configurations/delta/Configuration.h View File

495
 //#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
495
 //#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
496
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
496
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
497
 
497
 
498
+// PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
499
+// http://reprap.org/wiki/PanelOne
500
+//#define PANEL_ONE
501
+
498
 // The MaKr3d Makr-Panel with graphic controller and SD support
502
 // The MaKr3d Makr-Panel with graphic controller and SD support
499
 // http://reprap.org/wiki/MaKr3d_MaKrPanel
503
 // http://reprap.org/wiki/MaKr3d_MaKrPanel
500
 //#define MAKRPANEL
504
 //#define MAKRPANEL
560
  #define ENCODER_STEPS_PER_MENU_ITEM 1
564
  #define ENCODER_STEPS_PER_MENU_ITEM 1
561
 #endif
565
 #endif
562
 
566
 
567
+#if defined (PANEL_ONE)
568
+ #define SDSUPPORT
569
+ #define ULTIMAKERCONTROLLER
570
+#endif
563
 
571
 
564
 #if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
572
 #if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
565
  #define DOGLCD
573
  #define DOGLCD

+ 8
- 0
Marlin/example_configurations/makibox/Configuration.h View File

565
 //#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
565
 //#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
566
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
566
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
567
 
567
 
568
+// PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
569
+// http://reprap.org/wiki/PanelOne
570
+//#define PANEL_ONE
571
+
568
 // The MaKr3d Makr-Panel with graphic controller and SD support
572
 // The MaKr3d Makr-Panel with graphic controller and SD support
569
 // http://reprap.org/wiki/MaKr3d_MaKrPanel
573
 // http://reprap.org/wiki/MaKr3d_MaKrPanel
570
 //#define MAKRPANEL
574
 //#define MAKRPANEL
623
  #define ENCODER_STEPS_PER_MENU_ITEM 1
627
  #define ENCODER_STEPS_PER_MENU_ITEM 1
624
 #endif
628
 #endif
625
 
629
 
630
+#if defined (PANEL_ONE)
631
+ #define SDSUPPORT
632
+ #define ULTIMAKERCONTROLLER
633
+#endif
626
 
634
 
627
 #if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
635
 #if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
628
  #define DOGLCD
636
  #define DOGLCD

+ 8
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration.h View File

578
 //#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
578
 //#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
579
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
579
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
580
 
580
 
581
+// PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
582
+// http://reprap.org/wiki/PanelOne
583
+//#define PANEL_ONE
584
+
581
 // The MaKr3d Makr-Panel with graphic controller and SD support
585
 // The MaKr3d Makr-Panel with graphic controller and SD support
582
 // http://reprap.org/wiki/MaKr3d_MaKrPanel
586
 // http://reprap.org/wiki/MaKr3d_MaKrPanel
583
 //#define MAKRPANEL
587
 //#define MAKRPANEL
636
  #define ENCODER_STEPS_PER_MENU_ITEM 1
640
  #define ENCODER_STEPS_PER_MENU_ITEM 1
637
 #endif
641
 #endif
638
 
642
 
643
+#if defined (PANEL_ONE)
644
+ #define SDSUPPORT
645
+ #define ULTIMAKERCONTROLLER
646
+#endif
639
 
647
 
640
 #if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
648
 #if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
641
  #define DOGLCD
649
  #define DOGLCD

+ 37
- 0
Marlin/language.h View File

159
 
159
 
160
 #define MSG_ERR_EEPROM_WRITE                "Error writing to EEPROM!"
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
 // LCD Menu Messages
199
 // LCD Menu Messages
163
 
200
 
164
 // Add your own character. Reference: https://github.com/MarlinFirmware/Marlin/pull/1434 photos
201
 // Add your own character. Reference: https://github.com/MarlinFirmware/Marlin/pull/1434 photos

+ 76
- 16
Marlin/language_en.h View File

65
 #ifndef MSG_PREHEAT_ABS_SETTINGS
65
 #ifndef MSG_PREHEAT_ABS_SETTINGS
66
 #define MSG_PREHEAT_ABS_SETTINGS            MSG_PREHEAT_ABS " conf"
66
 #define MSG_PREHEAT_ABS_SETTINGS            MSG_PREHEAT_ABS " conf"
67
 #endif
67
 #endif
68
+#ifndef MSG_H1
69
+#define MSG_H1                              "1"
70
+#endif
71
+#ifndef MSG_H2
72
+#define MSG_H2                              "2"
73
+#endif
74
+#ifndef MSG_H3
75
+#define MSG_H3                              "3"
76
+#endif
77
+#ifndef MSG_H4
78
+#define MSG_H4                              "4"
79
+#endif
68
 #ifndef MSG_COOLDOWN
80
 #ifndef MSG_COOLDOWN
69
 #define MSG_COOLDOWN                        "Cooldown"
81
 #define MSG_COOLDOWN                        "Cooldown"
70
 #endif
82
 #endif
110
 #ifndef MSG_NOZZLE
122
 #ifndef MSG_NOZZLE
111
 #define MSG_NOZZLE                          "Nozzle"
123
 #define MSG_NOZZLE                          "Nozzle"
112
 #endif
124
 #endif
125
+#ifndef MSG_N2
126
+#define MSG_N2                              " 2"
127
+#endif
128
+#ifndef MSG_N3
129
+#define MSG_N3                              " 3"
130
+#endif
131
+#ifndef MSG_N4
132
+#define MSG_N4                              " 4"
133
+#endif
113
 #ifndef MSG_BED
134
 #ifndef MSG_BED
114
 #define MSG_BED                             "Bed"
135
 #define MSG_BED                             "Bed"
115
 #endif
136
 #endif
119
 #ifndef MSG_FLOW
140
 #ifndef MSG_FLOW
120
 #define MSG_FLOW                            "Flow"
141
 #define MSG_FLOW                            "Flow"
121
 #endif
142
 #endif
143
+#ifndef MSG_F0
144
+#define MSG_F0                              " 0"
145
+#endif
146
+#ifndef MSG_F1
147
+#define MSG_F1                              " 1"
148
+#endif
149
+#ifndef MSG_F2
150
+#define MSG_F2                              " 2"
151
+#endif
152
+#ifndef MSG_F3
153
+#define MSG_F3                              " 3"
154
+#endif
122
 #ifndef MSG_CONTROL
155
 #ifndef MSG_CONTROL
123
 #define MSG_CONTROL                         "Control"
156
 #define MSG_CONTROL                         "Control"
124
 #endif
157
 #endif
152
 #ifndef MSG_PID_C
185
 #ifndef MSG_PID_C
153
 #define MSG_PID_C                           "PID-C"
186
 #define MSG_PID_C                           "PID-C"
154
 #endif
187
 #endif
188
+#ifndef MSG_E2
189
+#define MSG_E2                              " E2"
190
+#endif
191
+#ifndef MSG_E3
192
+#define MSG_E3                              " E3"
193
+#endif
194
+#ifndef MSG_E4
195
+#define MSG_E4                              " E4"
196
+#endif
155
 #ifndef MSG_ACC
197
 #ifndef MSG_ACC
156
 #define MSG_ACC                             "Accel"
198
 #define MSG_ACC                             "Accel"
157
 #endif
199
 #endif
213
 #define MSG_VOLUMETRIC                      "Filament"
255
 #define MSG_VOLUMETRIC                      "Filament"
214
 #endif
256
 #endif
215
 #ifndef MSG_VOLUMETRIC_ENABLED
257
 #ifndef MSG_VOLUMETRIC_ENABLED
216
-#define MSG_VOLUMETRIC_ENABLED		          "E in mm" STR_h3
258
+#define MSG_VOLUMETRIC_ENABLED              "E in mm" STR_h3
217
 #endif
259
 #endif
218
 #ifndef MSG_FILAMENT_SIZE_EXTRUDER_0
260
 #ifndef MSG_FILAMENT_SIZE_EXTRUDER_0
219
 #define MSG_FILAMENT_SIZE_EXTRUDER_0        "Fil. Dia. 1"
261
 #define MSG_FILAMENT_SIZE_EXTRUDER_0        "Fil. Dia. 1"
341
 #ifndef MSG_ENDSTOP_ABORT
383
 #ifndef MSG_ENDSTOP_ABORT
342
 #define MSG_ENDSTOP_ABORT                   "Endstop abort"
384
 #define MSG_ENDSTOP_ABORT                   "Endstop abort"
343
 #endif
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
344
 
404
 
345
 #ifdef DELTA_CALIBRATION_MENU
405
 #ifdef DELTA_CALIBRATION_MENU
346
-    #ifndef MSG_DELTA_CALIBRATE
347
-    #define MSG_DELTA_CALIBRATE             "Delta Calibration"
348
-    #endif
349
-    #ifndef MSG_DELTA_CALIBRATE_X
350
-    #define MSG_DELTA_CALIBRATE_X           "Calibrate X"
351
-    #endif
352
-    #ifndef MSG_DELTA_CALIBRATE_Y
353
-    #define MSG_DELTA_CALIBRATE_Y           "Calibrate Y"
354
-    #endif
355
-    #ifndef MSG_DELTA_CALIBRATE_Z
356
-    #define MSG_DELTA_CALIBRATE_Z           "Calibrate Z"
357
-    #endif
358
-    #ifndef MSG_DELTA_CALIBRATE_CENTER
359
-    #define MSG_DELTA_CALIBRATE_CENTER      "Calibrate Center"
360
-    #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
361
 #endif // DELTA_CALIBRATION_MENU
421
 #endif // DELTA_CALIBRATION_MENU
362
 
422
 
363
 #endif // LANGUAGE_EN_H
423
 #endif // LANGUAGE_EN_H

+ 20
- 6
Marlin/pins_RAMPS_13.h View File

122
 #ifdef ULTRA_LCD
122
 #ifdef ULTRA_LCD
123
 
123
 
124
   #ifdef NEWPANEL
124
   #ifdef NEWPANEL
125
-    #define LCD_PINS_RS 16
126
-    #define LCD_PINS_ENABLE 17
127
-    #define LCD_PINS_D4 23
128
-    #define LCD_PINS_D5 25
129
-    #define LCD_PINS_D6 27
130
-    #define LCD_PINS_D7 29
125
+    #ifdef PANEL_ONE
126
+      #define LCD_PINS_RS 40
127
+      #define LCD_PINS_ENABLE 42
128
+      #define LCD_PINS_D4 65
129
+      #define LCD_PINS_D5 66
130
+      #define LCD_PINS_D6 44
131
+      #define LCD_PINS_D7 64
132
+    #else
133
+      #define LCD_PINS_RS 16
134
+      #define LCD_PINS_ENABLE 17
135
+      #define LCD_PINS_D4 23
136
+      #define LCD_PINS_D5 25
137
+      #define LCD_PINS_D6 27
138
+      #define LCD_PINS_D7 29
139
+    #endif
140
+
131
 
141
 
132
     #ifdef REPRAP_DISCOUNT_SMART_CONTROLLER
142
     #ifdef REPRAP_DISCOUNT_SMART_CONTROLLER
133
       #define BEEPER 37
143
       #define BEEPER 37
162
         #define SHIFT_OUT 40 // shift register
172
         #define SHIFT_OUT 40 // shift register
163
         #define SHIFT_CLK 44 // shift register
173
         #define SHIFT_CLK 44 // shift register
164
         #define SHIFT_LD 42 // shift register
174
         #define SHIFT_LD 42 // shift register
175
+      #elif defined(PANEL_ONE)
176
+        #define BTN_EN1 59 // AUX2 PIN 3
177
+        #define BTN_EN2 63 // AUX2 PIN 4
178
+        #define BTN_ENC 49 // AUX3 PIN 7
165
       #else
179
       #else
166
         #define BTN_EN1 37
180
         #define BTN_EN1 37
167
         #define BTN_EN2 35
181
         #define BTN_EN2 35

+ 4
- 0
Marlin/pins_RUMBA.h View File

6
   #error Oops!  Make sure you have 'Arduino Mega' selected from the 'Tools -> Boards' menu.
6
   #error Oops!  Make sure you have 'Arduino Mega' selected from the 'Tools -> Boards' menu.
7
 #endif
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
 #define X_STEP_PIN         17
13
 #define X_STEP_PIN         17
10
 #define X_DIR_PIN          16
14
 #define X_DIR_PIN          16
11
 #define X_ENABLE_PIN       48
15
 #define X_ENABLE_PIN       48

+ 71
- 76
Marlin/stepper.cpp View File

399
       count_direction[Y_AXIS]=1;
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
         #endif
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
     if ((out_bits & (1<<Z_AXIS)) != 0) {   // -direction
482
     if ((out_bits & (1<<Z_AXIS)) != 0) {   // -direction

+ 912
- 1266
Marlin/temperature.cpp
File diff suppressed because it is too large
View File


+ 39
- 72
Marlin/temperature.h View File

85
 //inline so that there is no performance decrease.
85
 //inline so that there is no performance decrease.
86
 //deg=degreeCelsius
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
 #ifdef SHOW_TEMP_ADC_VALUES
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
 #endif
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
 #define degHotend0() degHotend(0)
108
 #define degHotend0() degHotend(0)
139
 #define degTargetHotend0() degTargetHotend(0)
109
 #define degTargetHotend0() degTargetHotend(0)
141
 #define isHeatingHotend0() isHeatingHotend(0)
111
 #define isHeatingHotend0() isHeatingHotend(0)
142
 #define isCoolingHotend0() isCoolingHotend(0)
112
 #define isCoolingHotend0() isCoolingHotend(0)
143
 #if EXTRUDERS > 1
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
 #else
119
 #else
150
-#define setTargetHotend1(_celsius) do{}while(0)
120
+  #define setTargetHotend1(_celsius) do{}while(0)
151
 #endif
121
 #endif
152
 #if EXTRUDERS > 2
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
 #else
128
 #else
159
-#define setTargetHotend2(_celsius) do{}while(0)
129
+  #define setTargetHotend2(_celsius) do{}while(0)
160
 #endif
130
 #endif
161
 #if EXTRUDERS > 3
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
 #else
137
 #else
168
-#define setTargetHotend3(_celsius) do{}while(0)
138
+  #define setTargetHotend3(_celsius) do{}while(0)
169
 #endif
139
 #endif
170
 #if EXTRUDERS > 4
140
 #if EXTRUDERS > 4
171
-#error Invalid number of extruders
141
+  #error Invalid number of extruders
172
 #endif
142
 #endif
173
 
143
 
174
-
175
-
176
 int getHeaterPower(int heater);
144
 int getHeaterPower(int heater);
177
 void disable_heater();
145
 void disable_heater();
178
 void setWatch();
146
 void setWatch();
189
 #endif
157
 #endif
190
 #endif
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
 void PID_autotune(float temp, int extruder, int ncycles);
170
 void PID_autotune(float temp, int extruder, int ncycles);

+ 17
- 4
Marlin/thermistortables.h View File

1096
 #endif
1096
 #endif
1097
 
1097
 
1098
 #if (THERMISTORHEATER_0 == 999) || (THERMISTORHEATER_1 == 999) || (THERMISTORHEATER_2 == 999) || (THERMISTORHEATER_3 == 999) || (THERMISTORBED == 999) //User defined table
1098
 #if (THERMISTORHEATER_0 == 999) || (THERMISTORHEATER_1 == 999) || (THERMISTORHEATER_2 == 999) || (THERMISTORHEATER_3 == 999) || (THERMISTORBED == 999) //User defined table
1099
-// Dummy Thermistor table.. It will ALWAYS read 25C.
1100
-const short temptable_999[][2] PROGMEM = {
1101
-   {1*OVERSAMPLENR, 25},
1102
-   {1023*OVERSAMPLENR, 25}
1099
+  // Dummy Thermistor table.. It will ALWAYS read a fixed value.
1100
+  #ifndef DUMMY_THERMISTOR_999_VALUE
1101
+    #define DUMMY_THERMISTOR_999_VALUE 25
1102
+  #endif
1103
+  const short temptable_999[][2] PROGMEM = {
1104
+    {1*OVERSAMPLENR, DUMMY_THERMISTOR_999_VALUE},
1105
+    {1023*OVERSAMPLENR, DUMMY_THERMISTOR_999_VALUE}
1103
 };
1106
 };
1104
 #endif
1107
 #endif
1105
 
1108
 
1109
+#if (THERMISTORHEATER_0 == 998) || (THERMISTORHEATER_1 == 998) || (THERMISTORHEATER_2 == 998) || (THERMISTORHEATER_3 == 998) || (THERMISTORBED == 998) //User defined table
1110
+  // Dummy Thermistor table.. It will ALWAYS read a fixed value.
1111
+  #ifndef DUMMY_THERMISTOR_998_VALUE
1112
+    #define DUMMY_THERMISTOR_998_VALUE 25
1113
+  #endif
1114
+  const short temptable_998[][2] PROGMEM = {
1115
+    {1*OVERSAMPLENR, DUMMY_THERMISTOR_998_VALUE},
1116
+    {1023*OVERSAMPLENR, DUMMY_THERMISTOR_998_VALUE}
1117
+};
1118
+#endif
1106
 
1119
 
1107
 
1120
 
1108
 #define _TT_NAME(_N) temptable_ ## _N
1121
 #define _TT_NAME(_N) temptable_ ## _N

+ 696
- 878
Marlin/ultralcd.cpp
File diff suppressed because it is too large
View File


Loading…
Cancel
Save