Browse Source

Merge remote-tracking branch 'origin/Marlin_v1' into Marlin_v1

Erik van der Zalm 13 years ago
parent
commit
ac82411c73
16 changed files with 1434 additions and 1147 deletions
  1. 161
    107
      Marlin/Configuration.h
  2. 107
    59
      Marlin/EEPROMwrite.h
  3. 46
    5
      Marlin/Marlin.h
  4. 158
    97
      Marlin/Marlin.pde
  5. 31
    2
      Marlin/cardreader.h
  6. 26
    21
      Marlin/cardreader.pde
  7. 693
    693
      Marlin/pins.h
  8. 36
    2
      Marlin/planner.cpp
  9. 4
    2
      Marlin/planner.h
  10. 56
    4
      Marlin/stepper.cpp
  11. 7
    0
      Marlin/stepper.h
  12. 0
    84
      Marlin/streaming.h
  13. 19
    11
      Marlin/temperature.cpp
  14. 1
    0
      Marlin/ultralcd.h
  15. 85
    57
      Marlin/ultralcd.pde
  16. 4
    3
      Marlin/watchdog.pde

+ 161
- 107
Marlin/Configuration.h View File

1
 #ifndef __CONFIGURATION_H
1
 #ifndef __CONFIGURATION_H
2
 #define __CONFIGURATION_H
2
 #define __CONFIGURATION_H
3
 
3
 
4
-//#define DEBUG_STEPS
5
 
4
 
6
-#define MM_PER_ARC_SEGMENT 1
7
-#define N_ARC_CORRECTION 25
5
+
6
+// This determines the communication speed of the printer
7
+//#define BAUDRATE 250000
8
+#define BAUDRATE 115200
9
+//#define BAUDRATE 230400
10
+
8
 
11
 
9
 // Frequency limit
12
 // Frequency limit
10
 // See nophead's blog for more info
13
 // See nophead's blog for more info
26
 // Teensylu = 8
29
 // Teensylu = 8
27
 #define MOTHERBOARD 7
30
 #define MOTHERBOARD 7
28
 
31
 
29
-
32
+//===========================================================================
33
+//=============================Thermal Settings  ============================
34
+//===========================================================================
30
 
35
 
31
 //// Thermistor settings:
36
 //// Thermistor settings:
32
 // 1 is 100k thermistor
37
 // 1 is 100k thermistor
49
 //#define BED_USES_THERMISTOR
54
 //#define BED_USES_THERMISTOR
50
 //#define BED_USES_AD595
55
 //#define BED_USES_AD595
51
 
56
 
52
-#define HEATER_CHECK_INTERVAL 50
53
-#define BED_CHECK_INTERVAL 5000
57
+#define HEATER_CHECK_INTERVAL 50 //ms
58
+#define BED_CHECK_INTERVAL 5000 //ms
54
 
59
 
60
+//// Experimental watchdog and minimal temp
61
+// The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
62
+// If the temperature has not increased at the end of that period, the target temperature is set to zero. It can be reset with another M104/M109
63
+/// CURRENTLY NOT IMPLEMENTED AND UNUSEABLE
64
+//#define WATCHPERIOD 5000 //5 seconds
55
 
65
 
56
-//// Endstop Settings
57
-#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
58
-// The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
59
-const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
60
-// For optos H21LOB set to true, for Mendel-Parts newer optos TCST2103 set to false
66
+// Actual temperature must be close to target for this long before M109 returns success
67
+//#define TEMP_RESIDENCY_TIME 20  // (seconds)
68
+//#define TEMP_HYSTERESIS 5       // (C°) range of +/- temperatures considered "close" to the target one
61
 
69
 
62
-// This determines the communication speed of the printer
63
-#define BAUDRATE 250000
64
-//#define BAUDRATE 115200
65
-//#define BAUDRATE 230400
70
+//// The minimal temperature defines the temperature below which the heater will not be enabled
71
+#define HEATER_0_MINTEMP 5
72
+//#define HEATER_1_MINTEMP 5
73
+//#define BED_MINTEMP 5
66
 
74
 
67
-// Comment out (using // at the start of the line) to disable SD support:
68
 
75
 
69
-// #define ULTRA_LCD  //any lcd 
76
+// When temperature exceeds max temp, your heater will be switched off.
77
+// This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure!
78
+// You should use MINTEMP for thermistor short/failure protection.
79
+#define HEATER_0_MAXTEMP 275
80
+//#define_HEATER_1_MAXTEMP 275
81
+//#define BED_MAXTEMP 150
70
 
82
 
71
-#define ULTIPANEL
72
-#ifdef ULTIPANEL
73
-  //#define NEWPANEL  //enable this if you have a click-encoder panel
74
-  #define SDSUPPORT
75
-  #define ULTRA_LCD
76
-  #define LCD_WIDTH 20
77
-  #define LCD_HEIGHT 4
78
-#else //no panel but just lcd 
79
-  #ifdef ULTRA_LCD
80
-    #define LCD_WIDTH 16
81
-    #define LCD_HEIGHT 2
83
+
84
+
85
+// PID settings:
86
+// Uncomment the following line to enable PID support.
87
+  
88
+#define PIDTEMP
89
+#ifdef PIDTEMP
90
+  //#define PID_DEBUG // Sends debug data to the serial port. 
91
+  //#define PID_OPENLOOP 1 // Puts PID in open loop. M104 sets the output power in %
92
+  
93
+  #define PID_MAX 255 // limits current to nozzle; 255=full current
94
+  #define PID_INTEGRAL_DRIVE_MAX 255  //limit for the integral term
95
+  #define K1 0.95 //smoothing factor withing the PID
96
+  #define PID_dT 0.1 //sampling period of the PID
97
+
98
+  //To develop some PID settings for your machine, you can initiall follow 
99
+  // the Ziegler-Nichols method.
100
+  // set Ki and Kd to zero. 
101
+  // heat with a defined Kp and see if the temperature stabilizes
102
+  // ideally you do this graphically with repg.
103
+  // the PID_CRITIAL_GAIN should be the Kp at which temperature oscillatins are not dampned out/decreas in amplitutde
104
+  // PID_SWING_AT_CRITIAL is the time for a full period of the oscillations at the critical Gain
105
+  // usually further manual tunine is necessary.
106
+
107
+  #define PID_CRITIAL_GAIN 3000
108
+  #define PID_SWING_AT_CRITIAL 45 //seconds
109
+  
110
+  #define PID_PI    //no differentail term
111
+  //#define PID_PID //normal PID
112
+
113
+  #ifdef PID_PID
114
+    //PID according to Ziegler-Nichols method
115
+    #define  DEFAULT_Kp  (0.6*PID_CRITIAL_GAIN)
116
+    #define  DEFAULT_Ki (2*Kp/PID_SWING_AT_CRITIAL*PID_dT)  
117
+    #define  DEFAULT_Kd (PID_SWING_AT_CRITIAL/8./PID_dT)  
82
   #endif
118
   #endif
83
-#endif
119
+ 
120
+  #ifdef PID_PI
121
+    //PI according to Ziegler-Nichols method
122
+    #define  DEFAULT_Kp (PID_CRITIAL_GAIN/2.2) 
123
+    #define  DEFAULT_Ki (1.2*Kp/PID_SWING_AT_CRITIAL*PID_dT)
124
+    #define  DEFAULT_Kd (0)
125
+  #endif
126
+  
127
+  // this adds an experimental additional term to the heatingpower, proportional to the extrusion speed.
128
+  // if Kc is choosen well, the additional required power due to increased melting should be compensated.
129
+  #define PID_ADD_EXTRUSION_RATE  
130
+  #ifdef PID_ADD_EXTRUSION_RATE
131
+    #define  DEFAULT_Kc (3) //heatingpower=Kc*(e_speed)
132
+  #endif
133
+#endif // PIDTEMP
84
 
134
 
85
 
135
 
86
-//#define SDSUPPORT // Enable SD Card Support in Hardware Console
87
 
136
 
88
 
137
 
89
 
138
 
90
-const int dropsegments=5; //everything with this number of steps  will be ignored as move
91
 
139
 
92
-//// ADVANCED SETTINGS - to tweak parameters
93
 
140
 
94
-#include "thermistortables.h"
141
+
142
+
143
+//===========================================================================
144
+//=============================Mechanical Settings===========================
145
+//===========================================================================
146
+
147
+
148
+// Endstop Settings
149
+#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
150
+// The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
151
+const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
152
+// For optos H21LOB set to true, for Mendel-Parts newer optos TCST2103 set to false
153
+
95
 
154
 
96
 // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
155
 // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
97
 #define X_ENABLE_ON 0
156
 #define X_ENABLE_ON 0
156
 #define DEFAULT_ZJERK                 0.4     // (mm/sec)
215
 #define DEFAULT_ZJERK                 0.4     // (mm/sec)
157
 
216
 
158
 
217
 
159
-// The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
160
-//this enables the watchdog interrupt.
161
-#define USE_WATCHDOG
162
-//you cannot reboot on a mega2560 due to a bug in he bootloader. Hence, you have to reset manually, and this is done hereby:
163
-#define RESET_MANUAL
164
-
165
-#define WATCHDOG_TIMEOUT 4
166
-
167
-
168
 
218
 
169
-//// Experimental watchdog and minimal temp
170
-// The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
171
-// If the temperature has not increased at the end of that period, the target temperature is set to zero. It can be reset with another M104/M109
172
-/// CURRENTLY NOT IMPLEMENTED AND UNUSEABLE
173
-//#define WATCHPERIOD 5000 //5 seconds
174
-
175
-// Actual temperature must be close to target for this long before M109 returns success
176
-//#define TEMP_RESIDENCY_TIME 20  // (seconds)
177
-//#define TEMP_HYSTERESIS 5       // (C°) range of +/- temperatures considered "close" to the target one
178
 
219
 
179
-//// The minimal temperature defines the temperature below which the heater will not be enabled
180
-//#define HEATER_0_MINTEMP 5
181
-//#define HEATER_1_MINTEMP 5
182
-//#define BED_MINTEMP 5
220
+//===========================================================================
221
+//=============================Additional Features===========================
222
+//===========================================================================
183
 
223
 
224
+// EEPROM
225
+// the microcontroller can store settings in the EEPROM, e.g. max velocity...
226
+// M500 - stores paramters in EEPROM
227
+// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).  
228
+// M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
229
+//define this to enable eeprom support
230
+#define EEPROM_SETTINGS
231
+//to disable EEPROM Serial responses and decrease program space by ~1700 byte: comment this out:
232
+// please keep turned on if you can.
233
+#define EEPROM_CHITCHAT
184
 
234
 
185
-// When temperature exceeds max temp, your heater will be switched off.
186
-// This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure!
187
-// You should use MINTEMP for thermistor short/failure protection.
188
-//#define HEATER_0_MAXTEMP 275
189
-//#define_HEATER_1_MAXTEMP 275
190
-//#define BED_MAXTEMP 150
191
 
235
 
192
-/// PID settings:
193
-// Uncomment the following line to enable PID support.
194
-  
195
-#define PIDTEMP
196
-#ifdef PIDTEMP
197
-  //#define PID_DEBUG // Sends debug data to the serial port. 
198
-  //#define PID_OPENLOOP 1 // Puts PID in open loop. M104 sets the output power in %
199
-  
200
-  #define PID_MAX 255 // limits current to nozzle; 255=full current
201
-  #define PID_INTEGRAL_DRIVE_MAX 255  //limit for the integral term
202
-  #define K1 0.95 //smoothing factor withing the PID
203
-  #define PID_dT 0.1 //sampling period of the PID
236
+// The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
237
+// this enables the watchdog interrupt.
238
+#define USE_WATCHDOG
239
+// you cannot reboot on a mega2560 due to a bug in he bootloader. Hence, you have to reset manually, and this is done hereby:
240
+#define RESET_MANUAL
241
+#define WATCHDOG_TIMEOUT 4  //seconds
204
 
242
 
205
-  //To develop some PID settings for your machine, you can initiall follow 
206
-  // the Ziegler-Nichols method.
207
-  // set Ki and Kd to zero. 
208
-  // heat with a defined Kp and see if the temperature stabilizes
209
-  // ideally you do this graphically with repg.
210
-  // the PID_CRITIAL_GAIN should be the Kp at which temperature oscillatins are not dampned out/decreas in amplitutde
211
-  // PID_SWING_AT_CRITIAL is the time for a full period of the oscillations at the critical Gain
212
-  // usually further manual tunine is necessary.
213
 
243
 
214
-  #define PID_CRITIAL_GAIN 3000
215
-  #define PID_SWING_AT_CRITIAL 45 //seconds
216
-  
217
-  #define PID_PI    //no differentail term
218
-  //#define PID_PID //normal PID
219
 
244
 
220
-  #ifdef PID_PID
221
-    //PID according to Ziegler-Nichols method
222
-    #define  DEFAULT_Kp  (0.6*PID_CRITIAL_GAIN)
223
-    #define  DEFAULT_Ki (2*Kp/PID_SWING_AT_CRITIAL*PID_dT)  
224
-    #define  DEFAULT_Kd (PID_SWING_AT_CRITIAL/8./PID_dT)  
225
-  #endif
226
- 
227
-  #ifdef PID_PI
228
-    //PI according to Ziegler-Nichols method
229
-    #define  DEFAULT_Kp (PID_CRITIAL_GAIN/2.2) 
230
-    #define  DEFAULT_Ki (1.2*Kp/PID_SWING_AT_CRITIAL*PID_dT)
231
-    #define  DEFAULT_Kd (0)
232
-  #endif
233
-  
234
-  // this adds an experimental additional term to the heatingpower, proportional to the extrusion speed.
235
-  // if Kc is choosen well, the additional required power due to increased melting should be compensated.
236
-  #define PID_ADD_EXTRUSION_RATE  
237
-  #ifdef PID_ADD_EXTRUSION_RATE
238
-    #define  DEFAULT_Kc (5) //heatingpower=Kc*(e_speed)
239
-  #endif
240
-#endif // PIDTEMP
241
 
245
 
242
 // extruder advance constant (s2/mm3)
246
 // extruder advance constant (s2/mm3)
243
 //
247
 //
258
 
262
 
259
 #endif // ADVANCE
263
 #endif // ADVANCE
260
 
264
 
265
+
266
+//LCD and SD support
267
+//#define ULTRA_LCD  //general lcd support, also 16x2
268
+//#define SDSUPPORT // Enable SD Card Support in Hardware Console
269
+
270
+#define ULTIPANEL
271
+#ifdef ULTIPANEL
272
+  #define NEWPANEL  //enable this if you have a click-encoder panel
273
+  #define SDSUPPORT
274
+  #define ULTRA_LCD
275
+  #define LCD_WIDTH 20
276
+  #define LCD_HEIGHT 4
277
+#else //no panel but just lcd 
278
+  #ifdef ULTRA_LCD
279
+    #define LCD_WIDTH 16
280
+    #define LCD_HEIGHT 2
281
+  #endif
282
+#endif
283
+
284
+// A debugging feature to compare calculated vs performed steps, to see if steps are lost by the software.
285
+//#define DEBUG_STEPS
286
+
287
+
288
+// Arc interpretation settings:
289
+#define MM_PER_ARC_SEGMENT 1
290
+#define N_ARC_CORRECTION 25
291
+
292
+
293
+//automatic temperature: just for testing, this is very dangerous, keep disabled!
294
+// not working yet.
295
+//Erik: the settings currently depend dramatically on skeinforge39 or 41.
296
+//#define AUTOTEMP
297
+#define AUTOTEMP_MIN 190
298
+#define AUTOTEMP_MAX 260
299
+#define AUTOTEMP_FACTOR 1000.  //current target temperature= min+largest buffered espeeds)*FACTOR
300
+
301
+
302
+
303
+const int dropsegments=0; //everything with less than this number of steps  will be ignored as move and joined with the next movement
304
+
305
+//===========================================================================
306
+//=============================Buffers           ============================
307
+//===========================================================================
308
+
309
+
310
+
261
 // The number of linear motions that can be in the plan at any give time.  
311
 // The number of linear motions that can be in the plan at any give time.  
262
 // THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ringbuffering.
312
 // THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ringbuffering.
263
 #if defined SDSUPPORT
313
 #if defined SDSUPPORT
266
   #define BLOCK_BUFFER_SIZE 8 // maximize block buffer
316
   #define BLOCK_BUFFER_SIZE 8 // maximize block buffer
267
 #endif
317
 #endif
268
 
318
 
319
+
269
 //The ASCII buffer for recieving from the serial:
320
 //The ASCII buffer for recieving from the serial:
270
 #define MAX_CMD_SIZE 96
321
 #define MAX_CMD_SIZE 96
271
 #define BUFSIZE 4
322
 #define BUFSIZE 4
272
 
323
 
324
+
325
+#include "thermistortables.h"
326
+
273
 #endif //__CONFIGURATION_H
327
 #endif //__CONFIGURATION_H

+ 107
- 59
Marlin/EEPROMwrite.h View File

25
 }
25
 }
26
 //======================================================================================
26
 //======================================================================================
27
 
27
 
28
+
29
+
30
+
28
 #define EEPROM_OFFSET 100
31
 #define EEPROM_OFFSET 100
29
 
32
 
30
 
33
 
35
 // ALSO:  always make sure the variables in the Store and retrieve sections are in the same order.
38
 // ALSO:  always make sure the variables in the Store and retrieve sections are in the same order.
36
 #define EEPROM_VERSION "V04"  
39
 #define EEPROM_VERSION "V04"  
37
 
40
 
38
-void StoreSettings() 
41
+inline void StoreSettings() 
39
 {
42
 {
43
+#ifdef EEPROM_SETTINGS
40
   char ver[4]= "000";
44
   char ver[4]= "000";
41
   int i=EEPROM_OFFSET;
45
   int i=EEPROM_OFFSET;
42
   EEPROM_writeAnything(i,ver); // invalidate data first 
46
   EEPROM_writeAnything(i,ver); // invalidate data first 
62
   char ver2[4]=EEPROM_VERSION;
66
   char ver2[4]=EEPROM_VERSION;
63
   i=EEPROM_OFFSET;
67
   i=EEPROM_OFFSET;
64
   EEPROM_writeAnything(i,ver2); // validate data
68
   EEPROM_writeAnything(i,ver2); // validate data
65
-  SERIAL_ECHOLN("Settings Stored");
69
+  SERIAL_ECHO_START;
70
+  SERIAL_ECHOLNPGM("Settings Stored");
71
+#endif //EEPROM_SETTINGS
66
 }
72
 }
67
 
73
 
68
-void RetrieveSettings(bool def=false)
74
+inline void RetrieveSettings(bool def=false)
69
 {  // if def=true, the default values will be used
75
 {  // if def=true, the default values will be used
70
-  int i=EEPROM_OFFSET;
71
-  char stored_ver[4];
72
-  char ver[4]=EEPROM_VERSION;
73
-  EEPROM_readAnything(i,stored_ver); //read stored version
74
-  //  SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
75
-  if ((!def)&&(strncmp(ver,stored_ver,3)==0)) 
76
-  {   // version number match
77
-    EEPROM_readAnything(i,axis_steps_per_unit);  
78
-    EEPROM_readAnything(i,max_feedrate);  
79
-    EEPROM_readAnything(i,max_acceleration_units_per_sq_second);
80
-    EEPROM_readAnything(i,acceleration);
81
-    EEPROM_readAnything(i,retract_acceleration);
82
-    EEPROM_readAnything(i,minimumfeedrate);
83
-    EEPROM_readAnything(i,mintravelfeedrate);
84
-    EEPROM_readAnything(i,minsegmenttime);
85
-    EEPROM_readAnything(i,max_xy_jerk);
86
-    EEPROM_readAnything(i,max_z_jerk);
87
-    #ifndef PIDTEMP
88
-      float Kp,Ki,Kd;
89
-    #endif
90
-    EEPROM_readAnything(i,Kp);
91
-    EEPROM_readAnything(i,Ki);
92
-    EEPROM_readAnything(i,Kd);
76
+  #ifdef EEPROM_SETTINGS
77
+    int i=EEPROM_OFFSET;
78
+    char stored_ver[4];
79
+    char ver[4]=EEPROM_VERSION;
80
+    EEPROM_readAnything(i,stored_ver); //read stored version
81
+    //  SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
82
+    if ((!def)&&(strncmp(ver,stored_ver,3)==0)) 
83
+    {   // version number match
84
+      EEPROM_readAnything(i,axis_steps_per_unit);  
85
+      EEPROM_readAnything(i,max_feedrate);  
86
+      EEPROM_readAnything(i,max_acceleration_units_per_sq_second);
87
+      EEPROM_readAnything(i,acceleration);
88
+      EEPROM_readAnything(i,retract_acceleration);
89
+      EEPROM_readAnything(i,minimumfeedrate);
90
+      EEPROM_readAnything(i,mintravelfeedrate);
91
+      EEPROM_readAnything(i,minsegmenttime);
92
+      EEPROM_readAnything(i,max_xy_jerk);
93
+      EEPROM_readAnything(i,max_z_jerk);
94
+      #ifndef PIDTEMP
95
+        float Kp,Ki,Kd;
96
+      #endif
97
+      EEPROM_readAnything(i,Kp);
98
+      EEPROM_readAnything(i,Ki);
99
+      EEPROM_readAnything(i,Kd);
93
 
100
 
94
-    SERIAL_ECHOLN("Stored settings retreived:");
95
-  }
96
-  else 
97
-  {
98
-    float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
99
-    float tmp2[]=DEFAULT_MAX_FEEDRATE;
100
-    long tmp3[]=DEFAULT_MAX_ACCELERATION;
101
-    for (short i=0;i<4;i++) 
101
+      SERIAL_ECHO_START;
102
+      SERIAL_ECHOLNPGM("Stored settings retreived:");
103
+    }
104
+    else 
102
     {
105
     {
103
-      axis_steps_per_unit[i]=tmp1[i];  
104
-      max_feedrate[i]=tmp2[i];  
105
-      max_acceleration_units_per_sq_second[i]=tmp3[i];
106
+      float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
107
+      float tmp2[]=DEFAULT_MAX_FEEDRATE;
108
+      long tmp3[]=DEFAULT_MAX_ACCELERATION;
109
+      for (short i=0;i<4;i++) 
110
+      {
111
+        axis_steps_per_unit[i]=tmp1[i];  
112
+        max_feedrate[i]=tmp2[i];  
113
+        max_acceleration_units_per_sq_second[i]=tmp3[i];
114
+      }
115
+      acceleration=DEFAULT_ACCELERATION;
116
+      retract_acceleration=DEFAULT_RETRACT_ACCELERATION;
117
+      minimumfeedrate=DEFAULT_MINIMUMFEEDRATE;
118
+      minsegmenttime=DEFAULT_MINSEGMENTTIME;       
119
+      mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE;
120
+      max_xy_jerk=DEFAULT_XYJERK;
121
+      max_z_jerk=DEFAULT_ZJERK;
122
+      SERIAL_ECHO_START;
123
+      SERIAL_ECHOLN("Using Default settings:");
106
     }
124
     }
107
-    acceleration=DEFAULT_ACCELERATION;
108
-    retract_acceleration=DEFAULT_RETRACT_ACCELERATION;
109
-    minimumfeedrate=DEFAULT_MINIMUMFEEDRATE;
110
-    minsegmenttime=DEFAULT_MINSEGMENTTIME;       
111
-    mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE;
112
-    max_xy_jerk=DEFAULT_XYJERK;
113
-    max_z_jerk=DEFAULT_ZJERK;
114
-    SERIAL_ECHOLN("Using Default settings:");
115
-  }
116
-  SERIAL_ECHOLN("Steps per unit:");
117
-  SERIAL_ECHOLN("   M92 X"   <<_FLOAT(axis_steps_per_unit[0],3) << " Y" <<  _FLOAT(axis_steps_per_unit[1],3) << " Z" << _FLOAT(axis_steps_per_unit[2],3) << " E" << _FLOAT(axis_steps_per_unit[3],3));
118
-  SERIAL_ECHOLN("Maximum feedrates (mm/s):");
119
-  SERIAL_ECHOLN("   M203 X"  <<_FLOAT(max_feedrate[0]/60,2)<<" Y" << _FLOAT(max_feedrate[1]/60,2) << " Z" << _FLOAT(max_feedrate[2]/60,2) << " E" << _FLOAT(max_feedrate[3]/60,2));
120
-  SERIAL_ECHOLN("Maximum Acceleration (mm/s2):");
121
-  SERIAL_ECHOLN("   M201 X"  <<_FLOAT(max_acceleration_units_per_sq_second[0],0) << " Y" << _FLOAT(max_acceleration_units_per_sq_second[1],0) << " Z" << _FLOAT(max_acceleration_units_per_sq_second[2],0) << " E" << _FLOAT(max_acceleration_units_per_sq_second[3],0));
122
-  SERIAL_ECHOLN("Acceleration: S=acceleration, T=retract acceleration");
123
-  SERIAL_ECHOLN("   M204 S"  <<_FLOAT(acceleration,2) << " T" << _FLOAT(retract_acceleration,2));
124
-  SERIAL_ECHOLN("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum xY jerk (mm/s),  Z=maximum Z jerk (mm/s)");
125
-  SERIAL_ECHOLN("   M205 S"  <<_FLOAT(minimumfeedrate/60,2) << " T" << _FLOAT(mintravelfeedrate/60,2) << " B" << _FLOAT(minsegmenttime,2) << " X" << _FLOAT(max_xy_jerk/60,2) << " Z" << _FLOAT(max_z_jerk/60,2));
126
-  #ifdef PIDTEMP
127
-    SERIAL_ECHOLN("PID settings:");
128
-    SERIAL_ECHOLN("   M301 P"  << _FLOAT(Kp,3) << " I" << _FLOAT(Ki,3) << " D" << _FLOAT(Kd,3));  
125
+  #ifdef EEPROM_CHITCHAT
126
+    SERIAL_ECHO_START;
127
+      SERIAL_ECHOLNPGM("Steps per unit:");
128
+      SERIAL_ECHO_START;
129
+      SERIAL_ECHOPAIR("  M92 X",axis_steps_per_unit[0]);
130
+      SERIAL_ECHOPAIR(" Y",axis_steps_per_unit[1]);
131
+      SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[2]);
132
+      SERIAL_ECHOPAIR(" E",axis_steps_per_unit[3]);
133
+      SERIAL_ECHOLN("");
134
+      
135
+    SERIAL_ECHO_START;
136
+      SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
137
+      SERIAL_ECHO_START;
138
+      SERIAL_ECHOPAIR("  M203 X",max_feedrate[0]/60);
139
+      SERIAL_ECHOPAIR(" Y",max_feedrate[1]/60 ); 
140
+      SERIAL_ECHOPAIR(" Z", max_feedrate[2]/60 ); 
141
+      SERIAL_ECHOPAIR(" E", max_feedrate[3]/60);
142
+      SERIAL_ECHOLN("");
143
+    SERIAL_ECHO_START;
144
+      SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
145
+      SERIAL_ECHO_START;
146
+      SERIAL_ECHOPAIR("  M201 X" ,max_acceleration_units_per_sq_second[0] ); 
147
+      SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[1] ); 
148
+      SERIAL_ECHOPAIR(" Z" ,max_acceleration_units_per_sq_second[2] );
149
+      SERIAL_ECHOPAIR(" E" ,max_acceleration_units_per_sq_second[3]);
150
+      SERIAL_ECHOLN("");
151
+    SERIAL_ECHO_START;
152
+      SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration");
153
+      SERIAL_ECHO_START;
154
+      SERIAL_ECHOPAIR("  M204 S",acceleration ); 
155
+      SERIAL_ECHOPAIR(" T" ,retract_acceleration);
156
+      SERIAL_ECHOLN("");
157
+    SERIAL_ECHO_START;
158
+      SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum xY jerk (mm/s),  Z=maximum Z jerk (mm/s)");
159
+      SERIAL_ECHO_START;
160
+      SERIAL_ECHOPAIR("  M205 S",minimumfeedrate/60 ); 
161
+      SERIAL_ECHOPAIR(" T" ,mintravelfeedrate/60 ); 
162
+      SERIAL_ECHOPAIR(" B" ,minsegmenttime ); 
163
+      SERIAL_ECHOPAIR(" X" ,max_xy_jerk/60 ); 
164
+      SERIAL_ECHOPAIR(" Z" ,max_z_jerk/60);
165
+      SERIAL_ECHOLN(""); 
166
+    #ifdef PIDTEMP
167
+      SERIAL_ECHO_START;
168
+      SERIAL_ECHOLNPGM("PID settings:");
169
+      SERIAL_ECHO_START;
170
+      SERIAL_ECHOPAIR("   M301 P",Kp ); 
171
+      SERIAL_ECHOPAIR(" I" ,Ki ); 
172
+      SERIAL_ECHOPAIR(" D" ,Kd);
173
+      SERIAL_ECHOLN(""); 
174
+    #endif
129
   #endif
175
   #endif
176
+    
177
+  #endif //EEPROM_SETTINGS
130
 }  
178
 }  
131
 
179
 
132
 #endif
180
 #endif

+ 46
- 5
Marlin/Marlin.h View File

5
 // Licence: GPL
5
 // Licence: GPL
6
 #include <WProgram.h>
6
 #include <WProgram.h>
7
 #include "fastio.h"
7
 #include "fastio.h"
8
+#include <avr/pgmspace.h>
9
+#include "Configuration.h"
10
+
11
+//#define SERIAL_ECHO(x) Serial << "echo: " << x;
12
+//#define SERIAL_ECHOLN(x) Serial << "echo: "<<x<<endl;
13
+//#define SERIAL_ERROR(x) Serial << "Error: " << x;
14
+//#define SERIAL_ERRORLN(x) Serial << "Error: " << x<<endl;
15
+//#define SERIAL_PROTOCOL(x) Serial << x;
16
+//#define SERIAL_PROTOCOLLN(x) Serial << x<<endl;
17
+
18
+
19
+
20
+#define SERIAL_PROTOCOL(x) Serial.print(x);
21
+#define SERIAL_PROTOCOLPGM(x) serialprintPGM(PSTR(x));
22
+#define SERIAL_PROTOCOLLN(x) {Serial.print(x);Serial.write('\n');}
23
+#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(PSTR(x));Serial.write('\n');}
24
+
25
+const char errormagic[] PROGMEM ="Error:";
26
+const char echomagic[] PROGMEM ="echo:";
27
+#define SERIAL_ERROR_START serialprintPGM(errormagic);
28
+#define SERIAL_ERROR(x) SERIAL_PROTOCOL(x)
29
+#define SERIAL_ERRORPGM(x) SERIAL_PROTOCOLPGM(x)
30
+#define SERIAL_ERRORLN(x) SERIAL_PROTOCOLLN(x)
31
+#define SERIAL_ERRORLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
32
+
33
+#define SERIAL_ECHO_START serialprintPGM(echomagic);
34
+#define SERIAL_ECHO(x) SERIAL_PROTOCOL(x)
35
+#define SERIAL_ECHOPGM(x) SERIAL_PROTOCOLPGM(x)
36
+#define SERIAL_ECHOLN(x) SERIAL_PROTOCOLLN(x)
37
+#define SERIAL_ECHOLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
38
+
39
+#define SERIAL_ECHOPAIR(name,value) {SERIAL_ECHOPGM(name);SERIAL_ECHO(value);}
40
+
41
+
42
+//things to write to serial from Programmemory. saves 400 to 2k of RAM.
43
+#define SerialprintPGM(x) serialprintPGM(PSTR(x))
44
+inline void serialprintPGM(const char *str)
45
+{
46
+  char ch=pgm_read_byte(str);
47
+  while(ch)
48
+  {
49
+    Serial.write(ch);
50
+    ch=pgm_read_byte(++str);
51
+  }
52
+}
8
 
53
 
9
-#include "streaming.h"
10
-#define SERIAL_ECHO(x) Serial << "echo: " << x;
11
-#define SERIAL_ECHOLN(x) Serial << "echo: "<<x<<endl;
12
-#define SERIAL_ERROR(x) Serial << "echo: ERROR: " << x;
13
-#define SERIAL_ERRORLN(x) Serial << "echo: ERROR: " << x<<endl;
14
 
54
 
15
 void get_command();
55
 void get_command();
16
 void process_commands();
56
 void process_commands();
69
 
109
 
70
 extern float homing_feedrate[];
110
 extern float homing_feedrate[];
71
 extern bool axis_relative_modes[];
111
 extern bool axis_relative_modes[];
112
+extern float current_position[NUM_AXIS] ;
72
 
113
 
73
 #endif
114
 #endif

+ 158
- 97
Marlin/Marlin.pde View File

32
 #include "pins.h"
32
 #include "pins.h"
33
 #include "Marlin.h"
33
 #include "Marlin.h"
34
 #include "ultralcd.h"
34
 #include "ultralcd.h"
35
-#include "streaming.h"
36
 #include "planner.h"
35
 #include "planner.h"
37
 #include "stepper.h"
36
 #include "stepper.h"
38
 #include "temperature.h"
37
 #include "temperature.h"
40
 #include "cardreader.h"
39
 #include "cardreader.h"
41
 
40
 
42
 
41
 
43
-char version_string[] = "1.0.0 Alpha 1";
42
+#define VERSION_STRING  "1.0.0 Alpha 1"
43
+
44
 
44
 
45
 
45
 
46
 
46
 
99
 // M205 -  advanced settings:  minimum travel speed S=while printing T=travel only,  B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk
99
 // M205 -  advanced settings:  minimum travel speed S=while printing T=travel only,  B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk
100
 // M220 - set speed factor override percentage S:factor in percent
100
 // M220 - set speed factor override percentage S:factor in percent
101
 // M301 - Set PID parameters P I and D
101
 // M301 - Set PID parameters P I and D
102
+// M400 - Finish all moves
102
 // M500 - stores paramters in EEPROM
103
 // M500 - stores paramters in EEPROM
103
-// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).  D
104
+// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).  
104
 // M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
105
 // M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
105
 
106
 
106
 //Stepper Movement Variables
107
 //Stepper Movement Variables
122
 volatile int feedmultiply=100; //100->1 200->2
123
 volatile int feedmultiply=100; //100->1 200->2
123
 int saved_feedmultiply;
124
 int saved_feedmultiply;
124
 volatile bool feedmultiplychanged=false;
125
 volatile bool feedmultiplychanged=false;
126
+float current_position[NUM_AXIS] = {  0.0, 0.0, 0.0, 0.0};
127
+
125
 
128
 
126
 //===========================================================================
129
 //===========================================================================
127
 //=============================private variables=============================
130
 //=============================private variables=============================
128
 //===========================================================================
131
 //===========================================================================
129
 const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
132
 const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
130
 static float destination[NUM_AXIS] = {  0.0, 0.0, 0.0, 0.0};
133
 static float destination[NUM_AXIS] = {  0.0, 0.0, 0.0, 0.0};
131
-static float current_position[NUM_AXIS] = {  0.0, 0.0, 0.0, 0.0};
132
 static float offset[3] = {0.0, 0.0, 0.0};
134
 static float offset[3] = {0.0, 0.0, 0.0};
133
 static bool home_all_axis = true;
135
 static bool home_all_axis = true;
134
 static float feedrate = 1500.0, next_feedrate, saved_feedrate;
136
 static float feedrate = 1500.0, next_feedrate, saved_feedrate;
173
 //===========================================================================
175
 //===========================================================================
174
 
176
 
175
 
177
 
178
+extern "C"{
179
+  extern unsigned int __bss_end;
180
+  extern unsigned int __heap_start;
181
+  extern void *__brkval;
182
+
183
+  int freeMemory() {
184
+    int free_memory;
185
+
186
+    if((int)__brkval == 0)
187
+      free_memory = ((int)&free_memory) - ((int)&__bss_end);
188
+    else
189
+      free_memory = ((int)&free_memory) - ((int)__brkval);
190
+
191
+    return free_memory;
192
+  }
193
+}
194
+
176
 
195
 
177
 //adds an command to the main command buffer
196
 //adds an command to the main command buffer
178
 //thats really done in a non-safe way.
197
 //thats really done in a non-safe way.
183
   {
202
   {
184
     //this is dangerous if a mixing of serial and this happsens
203
     //this is dangerous if a mixing of serial and this happsens
185
     strcpy(&(cmdbuffer[bufindw][0]),cmd);
204
     strcpy(&(cmdbuffer[bufindw][0]),cmd);
186
-    SERIAL_ECHOLN("enqueing \""<<cmdbuffer[bufindw]<<"\"");
205
+    SERIAL_ECHO_START;
206
+    SERIAL_ECHOPGM("enqueing \"");
207
+    SERIAL_ECHO(cmdbuffer[bufindw]);
208
+    SERIAL_ECHOLNPGM("\"");
187
     bufindw= (bufindw + 1)%BUFSIZE;
209
     bufindw= (bufindw + 1)%BUFSIZE;
188
     buflen += 1;
210
     buflen += 1;
189
   }
211
   }
192
 void setup()
214
 void setup()
193
 { 
215
 { 
194
   Serial.begin(BAUDRATE);
216
   Serial.begin(BAUDRATE);
195
-  SERIAL_ECHOLN("Marlin "<<version_string);
196
-  Serial.println("start");
217
+  SERIAL_ECHO_START;
218
+  SERIAL_ECHOLNPGM(VERSION_STRING);
219
+  SERIAL_PROTOCOLLNPGM("start");
220
+  SERIAL_ECHO_START;
221
+  SERIAL_ECHOPGM("Free Memory:");
222
+  SERIAL_ECHOLN(freeMemory());
197
   for(int8_t i = 0; i < BUFSIZE; i++)
223
   for(int8_t i = 0; i < BUFSIZE; i++)
198
   {
224
   {
199
     fromsd[i] = false;
225
     fromsd[i] = false;
228
 	if(strstr(cmdbuffer[bufindr],"M29") == NULL)
254
 	if(strstr(cmdbuffer[bufindr],"M29") == NULL)
229
 	{
255
 	{
230
 	  card.write_command(cmdbuffer[bufindr]);
256
 	  card.write_command(cmdbuffer[bufindr]);
231
-	  Serial.println("ok");
257
+	  SERIAL_PROTOCOLLNPGM("ok");
232
 	}
258
 	}
233
 	else
259
 	else
234
 	{
260
 	{
235
 	  card.closefile();
261
 	  card.closefile();
236
-	  Serial.println("Done saving file.");
262
+	  SERIAL_PROTOCOLLNPGM("Done saving file.");
237
 	}
263
 	}
238
       }
264
       }
239
       else
265
       else
249
   //check heater every n milliseconds
275
   //check heater every n milliseconds
250
   manage_heater();
276
   manage_heater();
251
   manage_inactivity(1);
277
   manage_inactivity(1);
278
+  checkHitEndstops();
252
   LCD_STATUS;
279
   LCD_STATUS;
253
 }
280
 }
254
 
281
 
268
           strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
295
           strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
269
           gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10));
296
           gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10));
270
           if(gcode_N != gcode_LastN+1 && (strstr(cmdbuffer[bufindw], "M110") == NULL) ) {
297
           if(gcode_N != gcode_LastN+1 && (strstr(cmdbuffer[bufindw], "M110") == NULL) ) {
271
-            Serial.print("Serial Error: Line Number is not Last Line Number+1, Last Line:");
272
-            Serial.println(gcode_LastN);
298
+            SERIAL_ERROR_START;
299
+            SERIAL_ERRORPGM("Line Number is not Last Line Number+1, Last Line:");
300
+            SERIAL_ERRORLN(gcode_LastN);
273
             //Serial.println(gcode_N);
301
             //Serial.println(gcode_N);
274
             FlushSerialRequestResend();
302
             FlushSerialRequestResend();
275
             serial_count = 0;
303
             serial_count = 0;
284
             strchr_pointer = strchr(cmdbuffer[bufindw], '*');
312
             strchr_pointer = strchr(cmdbuffer[bufindw], '*');
285
 
313
 
286
             if( (int)(strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)) != checksum) {
314
             if( (int)(strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)) != checksum) {
287
-              Serial.print("Error: checksum mismatch, Last Line:");
288
-              Serial.println(gcode_LastN);
315
+              SERIAL_ERROR_START;
316
+              SERIAL_ERRORPGM("checksum mismatch, Last Line:");
317
+              SERIAL_ERRORLN(gcode_LastN);
289
               FlushSerialRequestResend();
318
               FlushSerialRequestResend();
290
               serial_count = 0;
319
               serial_count = 0;
291
               return;
320
               return;
294
           }
323
           }
295
           else 
324
           else 
296
           {
325
           {
297
-            Serial.print("Error: No Checksum with line number, Last Line:");
298
-            Serial.println(gcode_LastN);
326
+            SERIAL_ERROR_START;
327
+            SERIAL_ERRORPGM("No Checksum with line number, Last Line:");
328
+            SERIAL_ERRORLN(gcode_LastN);
299
             FlushSerialRequestResend();
329
             FlushSerialRequestResend();
300
             serial_count = 0;
330
             serial_count = 0;
301
             return;
331
             return;
308
         {
338
         {
309
           if((strstr(cmdbuffer[bufindw], "*") != NULL))
339
           if((strstr(cmdbuffer[bufindw], "*") != NULL))
310
           {
340
           {
311
-            Serial.print("Error: No Line Number with checksum, Last Line:");
312
-            Serial.println(gcode_LastN);
341
+            SERIAL_ERROR_START;
342
+            SERIAL_ERRORPGM("No Line Number with checksum, Last Line:");
343
+            SERIAL_ERRORLN(gcode_LastN);
313
             serial_count = 0;
344
             serial_count = 0;
314
             return;
345
             return;
315
           }
346
           }
325
             if(card.saving)
356
             if(card.saving)
326
               break;
357
               break;
327
 	    #endif //SDSUPPORT
358
 	    #endif //SDSUPPORT
328
-            Serial.println("ok"); 
359
+            SERIAL_PROTOCOLLNPGM("ok"); 
329
             break;
360
             break;
330
           default:
361
           default:
331
             break;
362
             break;
350
     return;
381
     return;
351
   }
382
   }
352
   while( !card.eof()  && buflen < BUFSIZE) {
383
   while( !card.eof()  && buflen < BUFSIZE) {
353
-    
354
-    serial_char = card.get();
355
-    if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1)) 
384
+    int16_t n=card.get();
385
+    serial_char = (char)n;
386
+    if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1)||n==-1) 
356
     {
387
     {
357
      
388
      
358
       if(card.eof()){
389
       if(card.eof()){
359
         card.sdprinting = false;
390
         card.sdprinting = false;
360
-        Serial.println("echo: Done printing file");
391
+        SERIAL_PROTOCOLLNPGM("Done printing file");
361
         stoptime=millis();
392
         stoptime=millis();
362
         char time[30];
393
         char time[30];
363
         unsigned long t=(stoptime-starttime)/1000;
394
         unsigned long t=(stoptime-starttime)/1000;
364
         int sec,min;
395
         int sec,min;
365
         min=t/60;
396
         min=t/60;
366
         sec=t%60;
397
         sec=t%60;
367
-        sprintf(time,"echo: %i min, %i sec",min,sec);
368
-        Serial.println(time);
398
+        sprintf(time,"%i min, %i sec",min,sec);
399
+        SERIAL_ECHO_START;
400
+        SERIAL_ECHOLN(time);
369
         LCD_MESSAGE(time);
401
         LCD_MESSAGE(time);
370
         card.checkautostart(true);
402
         card.checkautostart(true);
371
       }
403
       }
386
       if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
418
       if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
387
     }
419
     }
388
   }
420
   }
421
+  
389
   #endif //SDSUPPORT
422
   #endif //SDSUPPORT
390
 
423
 
391
 }
424
 }
417
     destination[LETTER##_AXIS] = 1.5 * LETTER##_MAX_LENGTH * LETTER##_HOME_DIR; \
450
     destination[LETTER##_AXIS] = 1.5 * LETTER##_MAX_LENGTH * LETTER##_HOME_DIR; \
418
     feedrate = homing_feedrate[LETTER##_AXIS]; \
451
     feedrate = homing_feedrate[LETTER##_AXIS]; \
419
     prepare_move(); \
452
     prepare_move(); \
453
+    st_synchronize();\
420
     \
454
     \
421
     current_position[LETTER##_AXIS] = 0;\
455
     current_position[LETTER##_AXIS] = 0;\
422
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
456
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
423
     destination[LETTER##_AXIS] = -5 * LETTER##_HOME_DIR;\
457
     destination[LETTER##_AXIS] = -5 * LETTER##_HOME_DIR;\
424
     prepare_move(); \
458
     prepare_move(); \
459
+    st_synchronize();\
425
     \
460
     \
426
     destination[LETTER##_AXIS] = 10 * LETTER##_HOME_DIR;\
461
     destination[LETTER##_AXIS] = 10 * LETTER##_HOME_DIR;\
427
     feedrate = homing_feedrate[LETTER##_AXIS]/2 ;  \
462
     feedrate = homing_feedrate[LETTER##_AXIS]/2 ;  \
428
     prepare_move(); \
463
     prepare_move(); \
464
+    st_synchronize();\
429
     \
465
     \
430
     current_position[LETTER##_AXIS] = (LETTER##_HOME_DIR == -1) ? 0 : LETTER##_MAX_LENGTH;\
466
     current_position[LETTER##_AXIS] = (LETTER##_HOME_DIR == -1) ? 0 : LETTER##_MAX_LENGTH;\
431
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
467
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
432
     destination[LETTER##_AXIS] = current_position[LETTER##_AXIS];\
468
     destination[LETTER##_AXIS] = current_position[LETTER##_AXIS];\
433
     feedrate = 0.0;\
469
     feedrate = 0.0;\
470
+    st_synchronize();\
471
+    endstops_hit_on_purpose();\
434
   }
472
   }
435
 
473
 
436
 inline void process_commands()
474
 inline void process_commands()
461
       previous_millis_cmd = millis();
499
       previous_millis_cmd = millis();
462
       return;
500
       return;
463
     case 4: // G4 dwell
501
     case 4: // G4 dwell
502
+      LCD_MESSAGEPGM("DWELL...");
464
       codenum = 0;
503
       codenum = 0;
465
       if(code_seen('P')) codenum = code_value(); // milliseconds to wait
504
       if(code_seen('P')) codenum = code_value(); // milliseconds to wait
466
       if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
505
       if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
495
       feedrate = saved_feedrate;
534
       feedrate = saved_feedrate;
496
       feedmultiply = saved_feedmultiply;
535
       feedmultiply = saved_feedmultiply;
497
       previous_millis_cmd = millis();
536
       previous_millis_cmd = millis();
537
+      endstops_hit_on_purpose();
498
       break;
538
       break;
499
     case 90: // G90
539
     case 90: // G90
500
       relative_mode = false;
540
       relative_mode = false;
521
     #ifdef SDSUPPORT
561
     #ifdef SDSUPPORT
522
 
562
 
523
     case 20: // M20 - list SD card
563
     case 20: // M20 - list SD card
524
-      Serial.println("Begin file list");
564
+      SERIAL_PROTOCOLLNPGM("Begin file list");
525
       card.ls();
565
       card.ls();
526
-      Serial.println("End file list");
566
+      SERIAL_PROTOCOLLNPGM("End file list");
527
       break;
567
       break;
528
     case 21: // M21 - init SD card
568
     case 21: // M21 - init SD card
529
       
569
       
530
       card.initsd();
570
       card.initsd();
571
+      
531
       break;
572
       break;
532
     case 22: //M22 - release SD card
573
     case 22: //M22 - release SD card
533
       card.release();
574
       card.release();
579
       int sec,min;
620
       int sec,min;
580
       min=t/60;
621
       min=t/60;
581
       sec=t%60;
622
       sec=t%60;
582
-      sprintf(time,"echo: time needed %i min, %i sec",min,sec);
583
-      Serial.println(time);
623
+      sprintf(time,"%i min, %i sec",min,sec);
624
+      SERIAL_ECHO_START;
625
+      SERIAL_ECHOLN(time);
584
       LCD_MESSAGE(time);
626
       LCD_MESSAGE(time);
585
     }
627
     }
586
     break;
628
     break;
617
       if (code_seen('S')) setTargetBed(code_value());
659
       if (code_seen('S')) setTargetBed(code_value());
618
       break;
660
       break;
619
     case 105: // M105
661
     case 105: // M105
662
+      //SERIAL_ECHOLN(freeMemory());
663
+          
620
       #if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
664
       #if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
621
-        tt = degHotend0();
622
-      #endif
623
-      #if TEMP_1_PIN > -1
624
-          bt = degBed();
625
-      #endif
626
-      #if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
627
-        Serial.print("ok T:");
628
-        Serial.print(tt); 
665
+        SERIAL_PROTOCOLPGM("ok T:");
666
+        SERIAL_PROTOCOL( degHotend0()); 
629
         #if TEMP_1_PIN > -1 
667
         #if TEMP_1_PIN > -1 
630
-          #ifdef PIDTEMP
631
-            Serial.print(" B:");
632
-            #if TEMP_1_PIN > -1
633
-              Serial.println(bt); 
634
-            #else
635
-              Serial.println(HeaterPower); 
636
-            #endif
637
-          #else //not PIDTEMP
638
-            Serial.println();
639
-           #endif //PIDTEMP
640
-         #else
641
-            Serial.println();
642
-          #endif //TEMP_1_PIN
643
-        #else
644
-          SERIAL_ERRORLN("No thermistors - no temp");
668
+          SERIAL_PROTOCOLPGM(" B:");  
669
+          SERIAL_PROTOCOL(degBed());
670
+        #endif //TEMP_1_PIN
671
+      #else
672
+        SERIAL_ERROR_START;
673
+        SERIAL_ERRORLNPGM("No thermistors - no temp");
674
+      #endif
675
+      #ifdef PIDTEMP
676
+        SERIAL_PROTOCOLPGM(" @:");
677
+        SERIAL_PROTOCOL( HeaterPower); 
678
+       
645
       #endif
679
       #endif
680
+        SERIAL_PROTOCOLLN("");
646
       return;
681
       return;
647
       break;
682
       break;
648
     case 109: 
683
     case 109: 
649
     {// M109 - Wait for extruder heater to reach target.
684
     {// M109 - Wait for extruder heater to reach target.
650
-        LCD_MESSAGE("Heating...");
685
+        LCD_MESSAGEPGM("Heating...");
651
         if (code_seen('S')) setTargetHotend0(code_value());
686
         if (code_seen('S')) setTargetHotend0(code_value());
652
         
687
         
653
         setWatch();
688
         setWatch();
668
         #endif //TEMP_RESIDENCY_TIME
703
         #endif //TEMP_RESIDENCY_TIME
669
         if( (millis() - codenum) > 1000 ) 
704
         if( (millis() - codenum) > 1000 ) 
670
         { //Print Temp Reading every 1 second while heating up/cooling down
705
         { //Print Temp Reading every 1 second while heating up/cooling down
671
-          Serial.print("T:");
672
-        Serial.println( degHotend0() ); 
706
+          SERIAL_PROTOCOLPGM("T:");
707
+          SERIAL_PROTOCOLLN( degHotend0() ); 
673
           codenum = millis();
708
           codenum = millis();
674
         }
709
         }
675
         manage_heater();
710
         manage_heater();
685
           }
720
           }
686
         #endif //TEMP_RESIDENCY_TIME
721
         #endif //TEMP_RESIDENCY_TIME
687
         }
722
         }
688
-        LCD_MESSAGE("Heating done.");
723
+        LCD_MESSAGEPGM("Heating done.");
689
         starttime=millis();
724
         starttime=millis();
690
       }
725
       }
691
       break;
726
       break;
692
     case 190: // M190 - Wait bed for heater to reach target.
727
     case 190: // M190 - Wait bed for heater to reach target.
693
     #if TEMP_1_PIN > -1
728
     #if TEMP_1_PIN > -1
729
+        LCD_MESSAGEPGM("Bed Heating.");
694
         if (code_seen('S')) setTargetBed(code_value());
730
         if (code_seen('S')) setTargetBed(code_value());
695
         codenum = millis(); 
731
         codenum = millis(); 
696
         while(isHeatingBed()) 
732
         while(isHeatingBed()) 
698
           if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
734
           if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
699
           {
735
           {
700
             float tt=degHotend0();
736
             float tt=degHotend0();
701
-            Serial.print("T:");
702
-            Serial.println( tt );
703
-            Serial.print("ok T:");
704
-            Serial.print( tt ); 
705
-            Serial.print(" B:");
706
-            Serial.println( degBed() ); 
737
+            SERIAL_PROTOCOLPGM("T:");
738
+            SERIAL_PROTOCOLLN(tt );
739
+            SERIAL_PROTOCOLPGM("ok T:");
740
+            SERIAL_PROTOCOL(tt );
741
+            SERIAL_PROTOCOLPGM(" B:");
742
+            SERIAL_PROTOCOLLN(degBed() ); 
707
             codenum = millis(); 
743
             codenum = millis(); 
708
           }
744
           }
709
           manage_heater();
745
           manage_heater();
710
         }
746
         }
747
+        LCD_MESSAGEPGM("Bed done.");
711
     #endif
748
     #endif
712
     break;
749
     break;
713
 
750
 
752
       else
789
       else
753
       { 
790
       { 
754
         st_synchronize(); 
791
         st_synchronize(); 
792
+        LCD_MESSAGEPGM("Free move.");
755
         disable_x(); 
793
         disable_x(); 
756
         disable_y(); 
794
         disable_y(); 
757
         disable_z(); 
795
         disable_z(); 
770
       }
808
       }
771
       break;
809
       break;
772
     case 115: // M115
810
     case 115: // M115
773
-      Serial.println("FIRMWARE_NAME:Marlin; Sprinter/grbl mashup for gen6 FIRMWARE_URL:http://www.mendel-parts.com PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1");
811
+      SerialprintPGM("FIRMWARE_NAME:Marlin; Sprinter/grbl mashup for gen6 FIRMWARE_URL:http://www.mendel-parts.com PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1");
774
       break;
812
       break;
775
     case 114: // M114
813
     case 114: // M114
776
-      Serial.print("X:");
777
-      Serial.print(current_position[X_AXIS]);
778
-      Serial.print("Y:");
779
-      Serial.print(current_position[Y_AXIS]);
780
-      Serial.print("Z:");
781
-      Serial.print(current_position[Z_AXIS]);
782
-      Serial.print("E:");      
783
-      Serial.print(current_position[E_AXIS]);
814
+      SERIAL_PROTOCOLPGM("X:");
815
+      SERIAL_PROTOCOL(current_position[X_AXIS]);
816
+      SERIAL_PROTOCOLPGM("Y:");
817
+      SERIAL_PROTOCOL(current_position[Y_AXIS]);
818
+      SERIAL_PROTOCOLPGM("Z:");
819
+      SERIAL_PROTOCOL(current_position[Z_AXIS]);
820
+      SERIAL_PROTOCOLPGM("E:");      
821
+      SERIAL_PROTOCOL(current_position[E_AXIS]);
784
       #ifdef DEBUG_STEPS
822
       #ifdef DEBUG_STEPS
785
-        Serial.print(" Count X:");
786
-        Serial.print(float(count_position[X_AXIS])/axis_steps_per_unit[X_AXIS]);
787
-        Serial.print("Y:");
788
-        Serial.print(float(count_position[Y_AXIS])/axis_steps_per_unit[Y_AXIS]);
789
-        Serial.print("Z:");
790
-        Serial.println(float(count_position[Z_AXIS])/axis_steps_per_unit[Z_AXIS]);
823
+        SERIAL_PROTOCOLPGM(" Count X:");
824
+        SERIAL_PROTOCOL(float(count_position[X_AXIS])/axis_steps_per_unit[X_AXIS]);
825
+        SERIAL_PROTOCOLPGM("Y:");
826
+        SERIAL_PROTOCOL(float(count_position[Y_AXIS])/axis_steps_per_unit[Y_AXIS]);
827
+        SERIAL_PROTOCOLPGM("Z:");
828
+        SERIAL_PROTOCOL(float(count_position[Z_AXIS])/axis_steps_per_unit[Z_AXIS]);
791
       #endif
829
       #endif
792
-      Serial.println("");
830
+      SERIAL_PROTOCOLLN("");
793
       break;
831
       break;
794
     case 119: // M119
832
     case 119: // M119
795
       #if (X_MIN_PIN > -1)
833
       #if (X_MIN_PIN > -1)
796
-        Serial.print("x_min:");
797
-        Serial.print((READ(X_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L ");
834
+        SERIAL_PROTOCOLPGM("x_min:");
835
+        SERIAL_PROTOCOL(((READ(X_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
798
       #endif
836
       #endif
799
       #if (X_MAX_PIN > -1)
837
       #if (X_MAX_PIN > -1)
800
-        Serial.print("x_max:");
801
-        Serial.print((READ(X_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L ");
838
+        SERIAL_PROTOCOLPGM("x_max:");
839
+        SERIAL_PROTOCOL(((READ(X_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
802
       #endif
840
       #endif
803
       #if (Y_MIN_PIN > -1)
841
       #if (Y_MIN_PIN > -1)
804
-        Serial.print("y_min:");
805
-        Serial.print((READ(Y_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L ");
842
+        SERIAL_PROTOCOLPGM("y_min:");
843
+        SERIAL_PROTOCOL(((READ(Y_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
806
       #endif
844
       #endif
807
       #if (Y_MAX_PIN > -1)
845
       #if (Y_MAX_PIN > -1)
808
-        Serial.print("y_max:");
809
-        Serial.print((READ(Y_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L ");
846
+        SERIAL_PROTOCOLPGM("y_max:");
847
+        SERIAL_PROTOCOL(((READ(Y_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
810
       #endif
848
       #endif
811
       #if (Z_MIN_PIN > -1)
849
       #if (Z_MIN_PIN > -1)
812
-        Serial.print("z_min:");
813
-        Serial.print((READ(Z_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L ");
850
+        SERIAL_PROTOCOLPGM("z_min:");
851
+        SERIAL_PROTOCOL(((READ(Z_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
814
       #endif
852
       #endif
815
       #if (Z_MAX_PIN > -1)
853
       #if (Z_MAX_PIN > -1)
816
-        Serial.print("z_max:");
817
-        Serial.print((READ(Z_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L ");
854
+        SERIAL_PROTOCOLPGM("z_max:");
855
+        SERIAL_PROTOCOL(((READ(Z_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
818
       #endif
856
       #endif
819
-      Serial.println("");
857
+      SERIAL_PROTOCOLLN("");
820
       break;
858
       break;
821
       //TODO: update for all axis, use for loop
859
       //TODO: update for all axis, use for loop
822
     case 201: // M201
860
     case 201: // M201
867
       if(code_seen('P')) Kp = code_value();
905
       if(code_seen('P')) Kp = code_value();
868
       if(code_seen('I')) Ki = code_value()*PID_dT;
906
       if(code_seen('I')) Ki = code_value()*PID_dT;
869
       if(code_seen('D')) Kd = code_value()/PID_dT;
907
       if(code_seen('D')) Kd = code_value()/PID_dT;
908
+      #ifdef PID_ADD_EXTRUSION_RATE
909
+      if(code_seen('C')) Kc = code_value();
910
+      #endif
911
+      SERIAL_PROTOCOL("ok p:");
912
+      SERIAL_PROTOCOL(Kp);
913
+      SERIAL_PROTOCOL(" i:");
914
+      SERIAL_PROTOCOL(Ki/PID_dT);
915
+      SERIAL_PROTOCOL(" d:");
916
+      SERIAL_PROTOCOL(Kd*PID_dT);
917
+      #ifdef PID_ADD_EXTRUSION_RATE
918
+      SERIAL_PROTOCOL(" c:");
919
+      SERIAL_PROTOCOL(Kc*PID_dT);
920
+      #endif
921
+      SERIAL_PROTOCOLLN("");
922
+      
870
       break;
923
       break;
871
     #endif //PIDTEMP
924
     #endif //PIDTEMP
925
+    case 400: // finish all moves
926
+    {
927
+      st_synchronize();
928
+    }
929
+    break;
872
     case 500: // Store settings in EEPROM
930
     case 500: // Store settings in EEPROM
873
     {
931
     {
874
         StoreSettings();
932
         StoreSettings();
889
   }
947
   }
890
   else
948
   else
891
   {
949
   {
892
-    Serial.print("echo: Unknown command:\"");
893
-    Serial.print(cmdbuffer[bufindr]);
894
-    Serial.println("\"");
950
+    SERIAL_ECHO_START;
951
+    SERIAL_ECHOPGM("Unknown command:\"");
952
+    SERIAL_ECHO(cmdbuffer[bufindr]);
953
+    SERIAL_ECHOLNPGM("\"");
895
   }
954
   }
896
 
955
 
897
   ClearToSend();
956
   ClearToSend();
901
 {
960
 {
902
   //char cmdbuffer[bufindr][100]="Resend:";
961
   //char cmdbuffer[bufindr][100]="Resend:";
903
   Serial.flush();
962
   Serial.flush();
904
-  Serial.print("Resend:");
905
-  Serial.println(gcode_LastN + 1);
963
+  SERIAL_PROTOCOLPGM("Resend:");
964
+  SERIAL_PROTOCOLLN(gcode_LastN + 1);
906
   ClearToSend();
965
   ClearToSend();
907
 }
966
 }
908
 
967
 
913
   if(fromsd[bufindr])
972
   if(fromsd[bufindr])
914
     return;
973
     return;
915
   #endif //SDSUPPORT
974
   #endif //SDSUPPORT
916
-  Serial.println("ok"); 
975
+  SERIAL_PROTOCOLLNPGM("ok"); 
917
 }
976
 }
918
 
977
 
919
 inline void get_coordinates()
978
 inline void get_coordinates()
987
   disable_e();
1046
   disable_e();
988
   
1047
   
989
   if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT);
1048
   if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT);
990
-  SERIAL_ERRORLN("Printer halted. kill() called !!");
1049
+  SERIAL_ERROR_START;
1050
+  SERIAL_ERRORLNPGM("Printer halted. kill() called !!");
1051
+  LCD_MESSAGEPGM("KILLED. ");
991
   while(1); // Wait for reset
1052
   while(1); // Wait for reset
992
 }
1053
 }
993
 
1054
 

+ 31
- 2
Marlin/cardreader.h View File

30
   
30
   
31
 
31
 
32
   inline void ls() {root.ls();};
32
   inline void ls() {root.ls();};
33
-  inline bool eof() { sdpos = file.curPosition();return sdpos>=filesize ;};
34
-  inline char get() {  int16_t n = file.read(); return (n!=-1)?(char)n:'\n';};
33
+  inline bool eof() { return sdpos>=filesize ;};
34
+  inline int16_t get() {  sdpos = file.curPosition();return (int16_t)file.read();};
35
   inline void setIndex(long index) {sdpos = index;file.seekSet(index);};
35
   inline void setIndex(long index) {sdpos = index;file.seekSet(index);};
36
 
36
 
37
 public:
37
 public:
52
   bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
52
   bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
53
 };
53
 };
54
   
54
   
55
+
56
+#else
57
+class CardReader
58
+{
59
+public:
60
+  inline CardReader(){};
61
+  
62
+  inline static void initsd(){};
63
+  inline static void write_command(char *buf){};
64
+  
65
+  inline static void checkautostart(bool x) {}; 
66
+  
67
+  inline static void closefile() {};
68
+  inline static void release(){};
69
+  inline static void startFileprint(){};
70
+  inline static void startFilewrite(char *name){};
71
+  inline static void pauseSDPrint(){};
72
+  inline static void getStatus(){};
73
+  
74
+  inline static void selectFile(char* name){};
75
+  inline static void getfilename(const uint8_t nr){};
76
+  inline static uint8_t getnrfilenames(){return 0;};
77
+  
78
+
79
+  inline static void ls() {};
80
+  inline static bool eof() {return true;};
81
+  inline static char get() {return 0;};
82
+  inline static void setIndex(){};
83
+};
55
 #endif //SDSUPPORT
84
 #endif //SDSUPPORT
56
   
85
   
57
   
86
   

+ 26
- 21
Marlin/cardreader.pde View File

29
     if (!card.init(SPI_FULL_SPEED,SDSS))
29
     if (!card.init(SPI_FULL_SPEED,SDSS))
30
     {
30
     {
31
       //if (!card.init(SPI_HALF_SPEED,SDSS))
31
       //if (!card.init(SPI_HALF_SPEED,SDSS))
32
-      SERIAL_ECHOLN("SD init fail");
32
+      SERIAL_ECHO_START;
33
+      SERIAL_ECHOLNPGM("SD init fail");
33
     }
34
     }
34
     else if (!volume.init(&card))
35
     else if (!volume.init(&card))
35
     {
36
     {
36
-      SERIAL_ERRORLN("volume.init failed");
37
+      SERIAL_ERROR_START;
38
+      SERIAL_ERRORLNPGM("volume.init failed");
37
     }
39
     }
38
     else if (!root.openRoot(&volume)) 
40
     else if (!root.openRoot(&volume)) 
39
     {
41
     {
40
-      SERIAL_ERRORLN("openRoot failed");
42
+      SERIAL_ERROR_START;
43
+      SERIAL_ERRORLNPGM("openRoot failed");
41
     }
44
     }
42
     else 
45
     else 
43
     {
46
     {
44
       cardOK = true;
47
       cardOK = true;
45
-      SERIAL_ECHOLN("SD card ok");
48
+      SERIAL_ECHO_START;
49
+      SERIAL_ECHOLNPGM("SD card ok");
46
     }
50
     }
47
   #endif //SDSS
51
   #endif //SDSS
48
 }
52
 }
76
     file.close();
80
     file.close();
77
    
81
    
78
     if (file.open(&root, name, O_READ)) {
82
     if (file.open(&root, name, O_READ)) {
79
-      Serial.print("File opened:");
80
-      Serial.print(name);
81
-      Serial.print(" Size:");
82
       filesize = file.fileSize();
83
       filesize = file.fileSize();
83
-      Serial.println(filesize);
84
+      SERIAL_PROTOCOLPGM("File opened:");
85
+      SERIAL_PROTOCOL(name);
86
+      SERIAL_PROTOCOLPGM(" Size:");
87
+      SERIAL_PROTOCOLLN(filesize);
84
       sdpos = 0;
88
       sdpos = 0;
85
       
89
       
86
-      Serial.println("File selected");
90
+      SERIAL_PROTOCOLLNPGM("File selected");
87
     }
91
     }
88
     else{
92
     else{
89
-      Serial.println("file.open failed");
93
+      SERIAL_PROTOCOLLNPGM("file.open failed");
90
     }
94
     }
91
   }
95
   }
92
 }
96
 }
101
     
105
     
102
     if (!file.open(&root, name, O_CREAT | O_APPEND | O_WRITE | O_TRUNC))
106
     if (!file.open(&root, name, O_CREAT | O_APPEND | O_WRITE | O_TRUNC))
103
     {
107
     {
104
-      Serial.print("open failed, File: ");
105
-      Serial.print(name);
106
-      Serial.print(".");
108
+      SERIAL_PROTOCOLPGM("open failed, File: ");
109
+      SERIAL_PROTOCOL(name);
110
+      SERIAL_PROTOCOLLNPGM(".");
107
     }
111
     }
108
     else{
112
     else{
109
       saving = true;
113
       saving = true;
110
-      Serial.print("Writing to file: ");
111
-      Serial.println(name);
114
+      SERIAL_PROTOCOLPGM("Writing to file: ");
115
+      SERIAL_PROTOCOLLN(name);
112
     }
116
     }
113
   }
117
   }
114
 }
118
 }
116
 void CardReader::getStatus()
120
 void CardReader::getStatus()
117
 {
121
 {
118
   if(cardOK){
122
   if(cardOK){
119
-    Serial.print("SD printing byte ");
120
-    Serial.print(sdpos);
121
-    Serial.print("/");
122
-    Serial.println(filesize);
123
+    SERIAL_PROTOCOLPGM("SD printing byte ");
124
+    SERIAL_PROTOCOL(sdpos);
125
+    SERIAL_PROTOCOLPGM("/");
126
+    SERIAL_PROTOCOLLN(filesize);
123
   }
127
   }
124
   else{
128
   else{
125
-    Serial.println("Not SD printing");
129
+    SERIAL_PROTOCOLLNPGM("Not SD printing");
126
   }
130
   }
127
 }
131
 }
128
 void CardReader::write_command(char *buf)
132
 void CardReader::write_command(char *buf)
143
   file.write(begin);
147
   file.write(begin);
144
   if (file.writeError)
148
   if (file.writeError)
145
   {
149
   {
146
-    SERIAL_ERRORLN("error writing to file");
150
+    SERIAL_ERROR_START;
151
+    SERIAL_ERRORLNPGM("error writing to file");
147
   }
152
   }
148
 }
153
 }
149
 
154
 

+ 693
- 693
Marlin/pins.h
File diff suppressed because it is too large
View File


+ 36
- 2
Marlin/planner.cpp View File

86
 static float previous_speed[4]; // Speed of previous path line segment
86
 static float previous_speed[4]; // Speed of previous path line segment
87
 static float previous_nominal_speed; // Nominal speed of previous path line segment
87
 static float previous_nominal_speed; // Nominal speed of previous path line segment
88
 
88
 
89
+#ifdef AUTOTEMP
90
+float high_e_speed=0;
91
+#endif
92
+
89
 
93
 
90
 //===========================================================================
94
 //===========================================================================
91
 //=============================private variables ============================
95
 //=============================private variables ============================
372
   return(block);
376
   return(block);
373
 }
377
 }
374
 
378
 
379
+#ifdef AUTOTEMP
380
+void getHighESpeed()
381
+{
382
+  if(degTargetHotend0()+2<AUTOTEMP_MIN)  //probably temperature set to zero.
383
+    return; //do nothing
384
+  float high=0;
385
+  char block_index = block_buffer_tail;
386
+  
387
+  while(block_index != block_buffer_head) {
388
+    float se=block_buffer[block_index].speed_e;
389
+    if(se>high)
390
+    {
391
+      high=se;
392
+    }
393
+    block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
394
+  }
395
+  high_e_speed=high*axis_steps_per_unit[E_AXIS]/(1000000.0);  //so it is independent of the esteps/mm. before 
396
+   
397
+  float g=AUTOTEMP_MIN+high_e_speed*AUTOTEMP_FACTOR;
398
+  float t=constrain(AUTOTEMP_MIN,g,AUTOTEMP_MAX);
399
+  setTargetHotend0(t);
400
+  SERIAL_ECHO_START;
401
+  SERIAL_ECHOPAIR("highe",high_e_speed);
402
+  SERIAL_ECHOPAIR(" t",t);
403
+  SERIAL_ECHOLN("");
404
+}
405
+#endif
406
+
375
 void check_axes_activity() {
407
 void check_axes_activity() {
376
   unsigned char x_active = 0;
408
   unsigned char x_active = 0;
377
   unsigned char y_active = 0;  
409
   unsigned char y_active = 0;  
686
   memcpy(position, target, sizeof(target)); // position[] = target[]
718
   memcpy(position, target, sizeof(target)); // position[] = target[]
687
 
719
 
688
   planner_recalculate();
720
   planner_recalculate();
689
-  
721
+  #ifdef AUTOTEMP
722
+    getHighESpeed();
723
+  #endif
690
   st_wake_up();
724
   st_wake_up();
691
 }
725
 }
692
 
726
 
702
   previous_speed[2] = 0.0;
736
   previous_speed[2] = 0.0;
703
   previous_speed[3] = 0.0;
737
   previous_speed[3] = 0.0;
704
 }
738
 }
705
-
739
+

+ 4
- 2
Marlin/planner.h View File

92
 extern float max_z_jerk;
92
 extern float max_z_jerk;
93
 extern float mintravelfeedrate;
93
 extern float mintravelfeedrate;
94
 extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
94
 extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
95
-
96
-#endif
95
+#ifdef AUTOTEMP
96
+extern float high_e_speed;
97
+#endif
98
+#endif

+ 56
- 4
Marlin/stepper.cpp View File

33
 #include "speed_lookuptable.h"
33
 #include "speed_lookuptable.h"
34
 
34
 
35
 
35
 
36
+
36
 //===========================================================================
37
 //===========================================================================
37
 //=============================public variables  ============================
38
 //=============================public variables  ============================
38
 //===========================================================================
39
 //===========================================================================
39
 block_t *current_block;  // A pointer to the block currently being traced
40
 block_t *current_block;  // A pointer to the block currently being traced
40
 
41
 
41
 
42
 
43
+
42
 //===========================================================================
44
 //===========================================================================
43
 //=============================private variables ============================
45
 //=============================private variables ============================
44
 //===========================================================================
46
 //===========================================================================
62
 static unsigned short acc_step_rate; // needed for deccelaration start point
64
 static unsigned short acc_step_rate; // needed for deccelaration start point
63
 static char step_loops;
65
 static char step_loops;
64
 
66
 
65
-
67
+volatile long endstops_trigsteps[3]={0,0,0};
68
+volatile long endstops_stepsTotal,endstops_stepsDone;
69
+static volatile bool endstops_hit=false;
66
 
70
 
67
 // if DEBUG_STEPS is enabled, M114 can be used to compare two methods of determining the X,Y,Z position of the printer.
71
 // if DEBUG_STEPS is enabled, M114 can be used to compare two methods of determining the X,Y,Z position of the printer.
68
 // for debugging purposes only, should be disabled by default
72
 // for debugging purposes only, should be disabled by default
152
 #define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)
156
 #define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)
153
 
157
 
154
 
158
 
159
+void endstops_triggered(const unsigned long &stepstaken)  
160
+{
161
+  //this will only work if there is no bufferig
162
+  //however, if you perform a move at which the endstops should be triggered, and wait for it to complete, i.e. by blocking command, it should work
163
+  //yes, it uses floats, but: if endstops are triggered, thats hopefully not critical anymore anyways.
164
+  //endstops_triggerpos;
165
+  
166
+  if(endstops_hit) //hitting a second time while the first hit is not reported
167
+    return;
168
+  if(current_block == NULL)
169
+    return;
170
+  endstops_stepsTotal=current_block->step_event_count;
171
+  endstops_stepsDone=stepstaken;
172
+  endstops_trigsteps[0]=current_block->steps_x;
173
+  endstops_trigsteps[1]=current_block->steps_y;
174
+  endstops_trigsteps[2]=current_block->steps_z;
175
+
176
+  endstops_hit=true;
177
+}
155
 
178
 
179
+void checkHitEndstops()
180
+{
181
+  if( !endstops_hit)
182
+   return;
183
+  float endstops_triggerpos[3]={0,0,0};
184
+  float ratiodone=endstops_stepsDone/float(endstops_stepsTotal);  //ratio of current_block thas was performed
185
+  
186
+  endstops_triggerpos[0]=current_position[0]-(endstops_trigsteps[0]*ratiodone)/float(axis_steps_per_unit[0]);
187
+  endstops_triggerpos[1]=current_position[1]-(endstops_trigsteps[1]*ratiodone)/float(axis_steps_per_unit[1]);
188
+  endstops_triggerpos[2]=current_position[2]-(endstops_trigsteps[2]*ratiodone)/float(axis_steps_per_unit[2]);
189
+ SERIAL_ECHO_START;
190
+ SERIAL_ECHOPGM("endstops hit: ");
191
+ SERIAL_ECHOPAIR(" X:",endstops_triggerpos[0]);
192
+ SERIAL_ECHOPAIR(" Y:",endstops_triggerpos[1]);
193
+ SERIAL_ECHOPAIR(" Z:",endstops_triggerpos[2]);
194
+ SERIAL_ECHOLN("");
195
+ endstops_hit=false;
196
+}
156
 
197
 
157
-
198
+void endstops_hit_on_purpose()
199
+{
200
+  endstops_hit=false;
201
+}
158
 
202
 
159
 //         __________________________
203
 //         __________________________
160
 //        /|                        |\     _________________         ^
204
 //        /|                        |\     _________________         ^
232
 ISR(TIMER1_COMPA_vect)
276
 ISR(TIMER1_COMPA_vect)
233
 {        
277
 {        
234
   if(busy){ 
278
   if(busy){ 
235
-/*    SERIAL_ERRORLN(*(unsigned short *)OCR1A<< " ISR overtaking itself.");*/
279
+    SERIAL_ERROR_START
280
+    SERIAL_ERROR(*(unsigned short *)OCR1A);
281
+    SERIAL_ERRORLNPGM(" ISR overtaking itself.");
236
     return; 
282
     return; 
237
   } // The busy-flag is used to avoid reentering this interrupt
283
   } // The busy-flag is used to avoid reentering this interrupt
238
 
284
 
294
       #endif
340
       #endif
295
       #if X_MIN_PIN > -1
341
       #if X_MIN_PIN > -1
296
             if(READ(X_MIN_PIN) != ENDSTOPS_INVERTING) {
342
             if(READ(X_MIN_PIN) != ENDSTOPS_INVERTING) {
343
+              endstops_triggered(step_events_completed);
297
               step_events_completed = current_block->step_event_count;
344
               step_events_completed = current_block->step_event_count;
298
             }
345
             }
299
       #endif
346
       #endif
305
       #endif
352
       #endif
306
       #if X_MAX_PIN > -1
353
       #if X_MAX_PIN > -1
307
         if((READ(X_MAX_PIN) != ENDSTOPS_INVERTING)  && (current_block->steps_x >0)){
354
         if((READ(X_MAX_PIN) != ENDSTOPS_INVERTING)  && (current_block->steps_x >0)){
355
+          endstops_triggered(step_events_completed);
308
           step_events_completed = current_block->step_event_count;
356
           step_events_completed = current_block->step_event_count;
309
         }
357
         }
310
         #endif
358
         #endif
317
       #endif
365
       #endif
318
       #if Y_MIN_PIN > -1
366
       #if Y_MIN_PIN > -1
319
         if(READ(Y_MIN_PIN) != ENDSTOPS_INVERTING) {
367
         if(READ(Y_MIN_PIN) != ENDSTOPS_INVERTING) {
368
+          endstops_triggered(step_events_completed);
320
           step_events_completed = current_block->step_event_count;
369
           step_events_completed = current_block->step_event_count;
321
         }
370
         }
322
       #endif
371
       #endif
328
       #endif
377
       #endif
329
       #if Y_MAX_PIN > -1
378
       #if Y_MAX_PIN > -1
330
       if((READ(Y_MAX_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_y >0)){
379
       if((READ(Y_MAX_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_y >0)){
380
+          endstops_triggered(step_events_completed);
331
           step_events_completed = current_block->step_event_count;
381
           step_events_completed = current_block->step_event_count;
332
         }
382
         }
333
       #endif
383
       #endif
340
       #endif
390
       #endif
341
       #if Z_MIN_PIN > -1
391
       #if Z_MIN_PIN > -1
342
         if(READ(Z_MIN_PIN) != ENDSTOPS_INVERTING) {
392
         if(READ(Z_MIN_PIN) != ENDSTOPS_INVERTING) {
393
+          endstops_triggered(step_events_completed);
343
           step_events_completed = current_block->step_event_count;
394
           step_events_completed = current_block->step_event_count;
344
         }
395
         }
345
       #endif
396
       #endif
351
       #endif
402
       #endif
352
       #if Z_MAX_PIN > -1
403
       #if Z_MAX_PIN > -1
353
         if((READ(Z_MAX_PIN) != ENDSTOPS_INVERTING)  && (current_block->steps_z >0)){
404
         if((READ(Z_MAX_PIN) != ENDSTOPS_INVERTING)  && (current_block->steps_z >0)){
405
+          endstops_triggered(step_events_completed);
354
           step_events_completed = current_block->step_event_count;
406
           step_events_completed = current_block->step_event_count;
355
         }
407
         }
356
       #endif
408
       #endif
614
     manage_inactivity(1);
666
     manage_inactivity(1);
615
     LCD_STATUS;
667
     LCD_STATUS;
616
   }   
668
   }   
617
-}
669
+}

+ 7
- 0
Marlin/stepper.h View File

39
   extern volatile long count_position[NUM_AXIS];
39
   extern volatile long count_position[NUM_AXIS];
40
   extern volatile int count_direction[NUM_AXIS];
40
   extern volatile int count_direction[NUM_AXIS];
41
 #endif
41
 #endif
42
+  
43
+void checkHitEndstops(); //call from somwhere to create an serial error message with the locations the endstops where hit, in case they were triggered
44
+void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after homeing and before a routine call of checkHitEndstops();
45
+
46
+
42
 
47
 
43
 extern block_t *current_block;  // A pointer to the block currently being traced
48
 extern block_t *current_block;  // A pointer to the block currently being traced
49
+
50
+
44
 #endif
51
 #endif

+ 0
- 84
Marlin/streaming.h View File

1
-/*
2
-Streaming.h - Arduino library for supporting the << streaming operator
3
-Copyright (c) 2010 Mikal Hart.  All rights reserved.
4
-
5
-This library is free software; you can redistribute it and/or
6
-modify it under the terms of the GNU Lesser General Public
7
-License as published by the Free Software Foundation; either
8
-version 2.1 of the License, or (at your option) any later version.
9
-
10
-This library is distributed in the hope that it will be useful,
11
-but WITHOUT ANY WARRANTY; without even the implied warranty of
12
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
-Lesser General Public License for more details.
14
-
15
-You should have received a copy of the GNU Lesser General Public
16
-License along with this library; if not, write to the Free Software
17
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
-*/
19
-
20
-#ifndef ARDUINO_STREAMING
21
-#define ARDUINO_STREAMING
22
-
23
-//#include <WProgram.h>
24
-
25
-#define STREAMING_LIBRARY_VERSION 4
26
-
27
-// Generic template
28
-template<class T> 
29
-inline Print &operator <<(Print &stream, T arg) 
30
-{ stream.print(arg); return stream; }
31
-
32
-struct _BASED 
33
-{ 
34
-  long val; 
35
-  int base;
36
-  _BASED(long v, int b): val(v), base(b) 
37
-  {}
38
-};
39
-
40
-#define _HEX(a)     _BASED(a, HEX)
41
-#define _DEC(a)     _BASED(a, DEC)
42
-#define _OCT(a)     _BASED(a, OCT)
43
-#define _BIN(a)     _BASED(a, BIN)
44
-#define _BYTE(a)    _BASED(a, BYTE)
45
-
46
-// Specialization for class _BASED
47
-// Thanks to Arduino forum user Ben Combee who suggested this 
48
-// clever technique to allow for expressions like
49
-//   Serial << _HEX(a);
50
-
51
-inline Print &operator <<(Print &obj, const _BASED &arg)
52
-{ obj.print(arg.val, arg.base); return obj; } 
53
-
54
-#if ARDUINO >= 18
55
-// Specialization for class _FLOAT
56
-// Thanks to Michael Margolis for suggesting a way
57
-// to accommodate Arduino 0018's floating point precision
58
-// feature like this:
59
-//   Serial << _FLOAT(gps_latitude, 6); // 6 digits of precision
60
-
61
-struct _FLOAT
62
-{
63
-  float val;
64
-  int digits;
65
-  _FLOAT(double v, int d): val(v), digits(d)
66
-  {}
67
-};
68
-
69
-inline Print &operator <<(Print &obj, const _FLOAT &arg)
70
-{ obj.print(arg.val, arg.digits); return obj; }
71
-#endif
72
-
73
-// Specialization for enum _EndLineCode
74
-// Thanks to Arduino forum user Paul V. who suggested this
75
-// clever technique to allow for expressions like
76
-//   Serial << "Hello!" << endl;
77
-
78
-enum _EndLineCode { endl };
79
-
80
-inline Print &operator <<(Print &obj, _EndLineCode arg) 
81
-{ obj.println(); return obj; }
82
-
83
-#endif
84
-

+ 19
- 11
Marlin/temperature.cpp View File

35
 #include "pins.h"
35
 #include "pins.h"
36
 #include "Marlin.h"
36
 #include "Marlin.h"
37
 #include "ultralcd.h"
37
 #include "ultralcd.h"
38
-#include "streaming.h"
39
 #include "temperature.h"
38
 #include "temperature.h"
40
 #include "watchdog.h"
39
 #include "watchdog.h"
41
 
40
 
160
 //            pTerm+=Kc*current_block->speed_e; //additional heating if extrusion speed is high
159
 //            pTerm+=Kc*current_block->speed_e; //additional heating if extrusion speed is high
161
 //          #endif
160
 //          #endif
162
           pid_output = constrain(pTerm + iTerm - dTerm, 0, PID_MAX);
161
           pid_output = constrain(pTerm + iTerm - dTerm, 0, PID_MAX);
162
+          
163
         }
163
         }
164
     #endif //PID_OPENLOOP
164
     #endif //PID_OPENLOOP
165
     #ifdef PID_DEBUG
165
     #ifdef PID_DEBUG
166
-     SERIAL_ECHOLN(" PIDDEBUG Input "<<pid_input<<" Output "<<pid_output" pTerm "<<pTerm<<" iTerm "<<iTerm<<" dTerm "<<dTerm);  
166
+     //SERIAL_ECHOLN(" PIDDEBUG Input "<<pid_input<<" Output "<<pid_output" pTerm "<<pTerm<<" iTerm "<<iTerm<<" dTerm "<<dTerm);  
167
     #endif //PID_DEBUG
167
     #endif //PID_DEBUG
168
+    HeaterPower=pid_output;
168
     analogWrite(HEATER_0_PIN, pid_output);
169
     analogWrite(HEATER_0_PIN, pid_output);
169
   #endif //PIDTEMP
170
   #endif //PIDTEMP
170
 
171
 
253
 
254
 
254
     return (1023 * OVERSAMPLENR) - raw;
255
     return (1023 * OVERSAMPLENR) - raw;
255
   #elif defined BED_USES_AD595
256
   #elif defined BED_USES_AD595
256
-    return celsius * (1024.0 / (5.0 * 100.0) ) * OVERSAMPLENR;
257
+    return lround(celsius * (1024.0 * OVERSAMPLENR/ (5.0 * 100.0) ) );
257
   #endif
258
   #endif
258
 }
259
 }
259
 
260
 
464
       temp_count++;
465
       temp_count++;
465
       break;
466
       break;
466
     default:
467
     default:
467
-      SERIAL_ERRORLN("Temp measurement error!");
468
+      SERIAL_ERROR_START;
469
+      SERIAL_ERRORLNPGM("Temp measurement error!");
468
       break;
470
       break;
469
   }
471
   }
470
     
472
     
498
         if(current_raw[TEMPSENSOR_HOTEND_0] >= maxttemp_0) {
500
         if(current_raw[TEMPSENSOR_HOTEND_0] >= maxttemp_0) {
499
           target_raw[TEMPSENSOR_HOTEND_0] = 0;
501
           target_raw[TEMPSENSOR_HOTEND_0] = 0;
500
           analogWrite(HEATER_0_PIN, 0);
502
           analogWrite(HEATER_0_PIN, 0);
501
-          SERIAL_ERRORLN("Temperature extruder 0 switched off. MAXTEMP triggered !!");
503
+          SERIAL_ERROR_START;
504
+          SERIAL_ERRORLNPGM("Temperature extruder 0 switched off. MAXTEMP triggered !!");
502
           kill();
505
           kill();
503
         }
506
         }
504
       #endif
507
       #endif
509
         target_raw[TEMPSENSOR_HOTEND_1] = 0;
512
         target_raw[TEMPSENSOR_HOTEND_1] = 0;
510
       if(current_raw[2] >= maxttemp_1) {
513
       if(current_raw[2] >= maxttemp_1) {
511
         analogWrite(HEATER_2_PIN, 0);
514
         analogWrite(HEATER_2_PIN, 0);
512
-        SERIAL_ERRORLN("Temperature extruder 1 switched off. MAXTEMP triggered !!");
515
+        SERIAL_ERROR_START;
516
+        SERIAL_ERRORLNPGM("Temperature extruder 1 switched off. MAXTEMP triggered !!");
513
         kill()
517
         kill()
514
       }
518
       }
515
     #endif
519
     #endif
520
       if(current_raw[TEMPSENSOR_HOTEND_0] <= minttemp_0) {
524
       if(current_raw[TEMPSENSOR_HOTEND_0] <= minttemp_0) {
521
         target_raw[TEMPSENSOR_HOTEND_0] = 0;
525
         target_raw[TEMPSENSOR_HOTEND_0] = 0;
522
         analogWrite(HEATER_0_PIN, 0);
526
         analogWrite(HEATER_0_PIN, 0);
523
-        SERIAL_ERRORLN("Temperature extruder 0 switched off. MINTEMP triggered !!");
527
+        SERIAL_ERROR_START;
528
+        SERIAL_ERRORLNPGM("Temperature extruder 0 switched off. MINTEMP triggered !!");
524
         kill();
529
         kill();
525
       }
530
       }
526
     #endif
531
     #endif
531
       if(current_raw[TEMPSENSOR_HOTEND_1] <= minttemp_1) {
536
       if(current_raw[TEMPSENSOR_HOTEND_1] <= minttemp_1) {
532
         target_raw[TEMPSENSOR_HOTEND_1] = 0;
537
         target_raw[TEMPSENSOR_HOTEND_1] = 0;
533
         analogWrite(HEATER_2_PIN, 0);
538
         analogWrite(HEATER_2_PIN, 0);
534
-        SERIAL_ERRORLN("Temperature extruder 1 switched off. MINTEMP triggered !!");
539
+        SERIAL_ERROR_START;
540
+        SERIAL_ERRORLNPGM("Temperature extruder 1 switched off. MINTEMP triggered !!");
535
         kill();
541
         kill();
536
       }
542
       }
537
     #endif
543
     #endif
542
       if(current_raw[1] <= bed_minttemp) {
548
       if(current_raw[1] <= bed_minttemp) {
543
         target_raw[1] = 0;
549
         target_raw[1] = 0;
544
         WRITE(HEATER_1_PIN, 0);
550
         WRITE(HEATER_1_PIN, 0);
545
-        SERIAL_ERRORLN("Temperatur heated bed switched off. MINTEMP triggered !!");
551
+        SERIAL_ERROR_START;
552
+        SERIAL_ERRORLNPGM("Temperatur heated bed switched off. MINTEMP triggered !!");
546
         kill();
553
         kill();
547
       }
554
       }
548
     #endif
555
     #endif
553
       if(current_raw[1] >= bed_maxttemp) {
560
       if(current_raw[1] >= bed_maxttemp) {
554
         target_raw[1] = 0;
561
         target_raw[1] = 0;
555
         WRITE(HEATER_1_PIN, 0);
562
         WRITE(HEATER_1_PIN, 0);
556
-        SERIAL_ERRORLN("Temperature heated bed switched off. MAXTEMP triggered !!");
563
+        SERIAL_ERROR_START;
564
+        SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !!");
557
         kill();
565
         kill();
558
       }
566
       }
559
     #endif
567
     #endif
561
   }
569
   }
562
 }
570
 }
563
 
571
 
564
-
572
+

+ 1
- 0
Marlin/ultralcd.h View File

83
 
83
 
84
 
84
 
85
   #define LCD_MESSAGE(x) lcd_status(x);
85
   #define LCD_MESSAGE(x) lcd_status(x);
86
+  #define LCD_MESSAGEPGM(x) lcd_statuspgm(PSTR(x));
86
   #define LCD_STATUS lcd_status()
87
   #define LCD_STATUS lcd_status()
87
 #else //no lcd
88
 #else //no lcd
88
   #define LCD_STATUS
89
   #define LCD_STATUS

+ 85
- 57
Marlin/ultralcd.pde View File

42
  
42
  
43
 static MainMenu menu;
43
 static MainMenu menu;
44
 
44
 
45
+#include <avr/pgmspace.h>
46
+
47
+void lcdProgMemprint(const char *str)
48
+{
49
+  char ch=pgm_read_byte(str);
50
+  while(ch)
51
+  {
52
+    lcd.print(ch);
53
+    ch=pgm_read_byte(++str);
54
+  }
55
+}
56
+#define lcdprintPGM(x) lcdProgMemprint(PSTR(x))
57
+
45
 
58
 
46
 //===========================================================================
59
 //===========================================================================
47
 //=============================functions         ============================
60
 //=============================functions         ============================
54
   strncpy(messagetext,message,LCD_WIDTH);
67
   strncpy(messagetext,message,LCD_WIDTH);
55
 }
68
 }
56
 
69
 
70
+void lcd_statuspgm(const char* message)
71
+{
72
+  char ch=pgm_read_byte(message);
73
+  char *target=messagetext;
74
+  uint8_t cnt=0;
75
+  while(ch &&cnt<LCD_WIDTH)
76
+  {
77
+    *target=ch;
78
+    target++;
79
+    cnt++;
80
+    ch=pgm_read_byte(++message);
81
+  }
82
+}
83
+
57
 inline void clear()
84
 inline void clear()
58
 {
85
 {
59
   lcd.clear();
86
   lcd.clear();
92
   lcd.createChar(2,Thermometer);
119
   lcd.createChar(2,Thermometer);
93
   lcd.createChar(3,uplevel);
120
   lcd.createChar(3,uplevel);
94
   lcd.createChar(4,refresh);
121
   lcd.createChar(4,refresh);
95
-  LCD_MESSAGE(fillto(LCD_WIDTH,"UltiMarlin ready."));
122
+  LCD_MESSAGEPGM("UltiMarlin ready.");
96
 }
123
 }
97
 
124
 
98
 
125
 
264
     feedmultiplychanged=false;
291
     feedmultiplychanged=false;
265
     encoderpos=feedmultiply;
292
     encoderpos=feedmultiply;
266
     clear();
293
     clear();
267
-    lcd.setCursor(0,0);lcd.print("\002123/567\001 ");
294
+    lcd.setCursor(0,0);lcdprintPGM("\002123/567\001 ");
268
     #if defined BED_USES_THERMISTOR || defined BED_USES_AD595 
295
     #if defined BED_USES_THERMISTOR || defined BED_USES_AD595 
269
-      lcd.setCursor(10,0);lcd.print("B123/567\001 ");
296
+      lcd.setCursor(10,0);lcdprintPGM("B123/567\001 ");
270
     #endif
297
     #endif
271
   }
298
   }
272
     
299
     
311
     
338
     
312
     if(starttime!=oldtime)
339
     if(starttime!=oldtime)
313
     {
340
     {
314
-      lcd.print(itostr2(time/60));lcd.print("h ");lcd.print(itostr2(time%60));lcd.print("m");
341
+      lcd.print(itostr2(time/60));lcdprintPGM("h ");lcd.print(itostr2(time%60));lcdprintPGM("m");
315
       oldtime=time;
342
       oldtime=time;
316
     }
343
     }
317
   }
344
   }
320
   if((currentz!=oldzpos)||force_lcd_update)
347
   if((currentz!=oldzpos)||force_lcd_update)
321
   {
348
   {
322
     lcd.setCursor(10,1);
349
     lcd.setCursor(10,1);
323
-    lcd.print("Z:");lcd.print(itostr31(currentz));
350
+    lcdprintPGM("Z:");lcd.print(itostr31(currentz));
324
     oldzpos=currentz;
351
     oldzpos=currentz;
325
   }
352
   }
326
   static int oldfeedmultiply=0;
353
   static int oldfeedmultiply=0;
339
   {
366
   {
340
    oldfeedmultiply=curfeedmultiply;
367
    oldfeedmultiply=curfeedmultiply;
341
    lcd.setCursor(0,2);
368
    lcd.setCursor(0,2);
342
-   lcd.print(itostr3(curfeedmultiply));lcd.print("% ");
369
+   lcd.print(itostr3(curfeedmultiply));lcdprintPGM("% ");
343
   }
370
   }
344
   if(messagetext[0]!='\0')
371
   if(messagetext[0]!='\0')
345
   {
372
   {
353
   if(force_lcd_update)  //initial display of content
380
   if(force_lcd_update)  //initial display of content
354
   {
381
   {
355
     encoderpos=feedmultiply;
382
     encoderpos=feedmultiply;
356
-    lcd.setCursor(0,0);lcd.print("\002123/567\001 ");
383
+    lcd.setCursor(0,0);lcdprintPGM("\002123/567\001 ");
357
     #if defined BED_USES_THERMISTOR || defined BED_USES_AD595 
384
     #if defined BED_USES_THERMISTOR || defined BED_USES_AD595 
358
-    lcd.setCursor(10,0);lcd.print("B123/567\001 ");
385
+    lcd.setCursor(10,0);lcdprintPGM("B123/567\001 ");
359
     #endif
386
     #endif
360
   }
387
   }
361
     
388
     
405
       {
432
       {
406
         if(force_lcd_update)
433
         if(force_lcd_update)
407
         {
434
         {
408
-          lcd.setCursor(0,line);lcd.print(" Prepare");
435
+          lcd.setCursor(0,line);lcdprintPGM(" Prepare");
409
         }
436
         }
410
         if((activeline==line) && CLICKED)
437
         if((activeline==line) && CLICKED)
411
         {
438
         {
418
       {
445
       {
419
         if(force_lcd_update)
446
         if(force_lcd_update)
420
         {
447
         {
421
-          lcd.setCursor(0,line);lcd.print(" Auto Home");
448
+          lcd.setCursor(0,line);lcdprintPGM(" Auto Home");
422
         }
449
         }
423
         if((activeline==line) && CLICKED)
450
         if((activeline==line) && CLICKED)
424
         {
451
         {
431
       {
458
       {
432
         if(force_lcd_update)
459
         if(force_lcd_update)
433
         {
460
         {
434
-          lcd.setCursor(0,line);lcd.print(" Set Origin");
461
+          lcd.setCursor(0,line);lcdprintPGM(" Set Origin");
435
           
462
           
436
         }
463
         }
437
         if((activeline==line) && CLICKED)
464
         if((activeline==line) && CLICKED)
445
       {
472
       {
446
         if(force_lcd_update)
473
         if(force_lcd_update)
447
         {
474
         {
448
-          lcd.setCursor(0,line);lcd.print(" Preheat"); 
475
+          lcd.setCursor(0,line);lcdprintPGM(" Preheat"); 
449
         }
476
         }
450
         if((activeline==line) && CLICKED)
477
         if((activeline==line) && CLICKED)
451
         {
478
         {
458
       {
485
       {
459
         if(force_lcd_update)
486
         if(force_lcd_update)
460
         {
487
         {
461
-          lcd.setCursor(0,line);lcd.print(" Extrude");
488
+          lcd.setCursor(0,line);lcdprintPGM(" Extrude");
462
         }
489
         }
463
         if((activeline==line) && CLICKED)
490
         if((activeline==line) && CLICKED)
464
         {
491
         {
472
       {
499
       {
473
         if(force_lcd_update)
500
         if(force_lcd_update)
474
         {
501
         {
475
-          lcd.setCursor(0,line);lcd.print(" Disable Steppers");
502
+          lcd.setCursor(0,line);lcdprintPGM(" Disable Steppers");
476
         }
503
         }
477
         if((activeline==line) && CLICKED)
504
         if((activeline==line) && CLICKED)
478
         {
505
         {
541
       {
568
       {
542
         if(force_lcd_update)
569
         if(force_lcd_update)
543
         {
570
         {
544
-          lcd.setCursor(0,line);lcd.print(" Control");
571
+          lcd.setCursor(0,line);lcdprintPGM(" Control");
545
         }
572
         }
546
         if((activeline==line) && CLICKED)
573
         if((activeline==line) && CLICKED)
547
         {
574
         {
554
       {
581
       {
555
         if(force_lcd_update)
582
         if(force_lcd_update)
556
         {
583
         {
557
-          lcd.setCursor(0,line);lcd.print(" \002Nozzle:");
584
+          lcd.setCursor(0,line);lcdprintPGM(" \002Nozzle:");
558
           lcd.setCursor(13,line);lcd.print(ftostr3(intround(degHotend0())));
585
           lcd.setCursor(13,line);lcd.print(ftostr3(intround(degHotend0())));
559
         }
586
         }
560
         
587
         
588
       {
615
       {
589
         if(force_lcd_update)
616
         if(force_lcd_update)
590
         {
617
         {
591
-          lcd.setCursor(0,line);lcd.print(" Fan speed:");
618
+          lcd.setCursor(0,line);lcdprintPGM(" Fan speed:");
592
           lcd.setCursor(13,line);lcd.print(ftostr3(fanpwm));
619
           lcd.setCursor(13,line);lcd.print(ftostr3(fanpwm));
593
         }
620
         }
594
         
621
         
625
     {
652
     {
626
       if(force_lcd_update)
653
       if(force_lcd_update)
627
         {
654
         {
628
-          lcd.setCursor(0,line);lcd.print(" Acc:");
629
-          lcd.setCursor(13,line);lcd.print(itostr3(acceleration/100));lcd.print("00");
655
+          lcd.setCursor(0,line);lcdprintPGM(" Acc:");
656
+          lcd.setCursor(13,line);lcd.print(itostr3(acceleration/100));lcdprintPGM("00");
630
         }
657
         }
631
         
658
         
632
         if((activeline==line) )
659
         if((activeline==line) )
650
           {
677
           {
651
             if(encoderpos<5) encoderpos=5;
678
             if(encoderpos<5) encoderpos=5;
652
             if(encoderpos>990) encoderpos=990;
679
             if(encoderpos>990) encoderpos=990;
653
-            lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcd.print("00");
680
+            lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
654
           }
681
           }
655
         }
682
         }
656
       }break;
683
       }break;
658
       {
685
       {
659
       if(force_lcd_update)
686
       if(force_lcd_update)
660
         {
687
         {
661
-          lcd.setCursor(0,line);lcd.print(" Vxy-jerk: ");
688
+          lcd.setCursor(0,line);lcdprintPGM(" Vxy-jerk: ");
662
           lcd.setCursor(13,line);lcd.print(itostr3(max_xy_jerk/60));
689
           lcd.setCursor(13,line);lcd.print(itostr3(max_xy_jerk/60));
663
         }
690
         }
664
         
691
         
692
       {
719
       {
693
       if(force_lcd_update)
720
       if(force_lcd_update)
694
         {
721
         {
695
-          lcd.setCursor(0,line);lcd.print(" PID-P: ");
722
+          lcd.setCursor(0,line);lcdprintPGM(" PID-P: ");
696
           lcd.setCursor(13,line);lcd.print(itostr4(Kp));
723
           lcd.setCursor(13,line);lcd.print(itostr4(Kp));
697
         }
724
         }
698
         
725
         
726
       {
753
       {
727
       if(force_lcd_update)
754
       if(force_lcd_update)
728
         {
755
         {
729
-          lcd.setCursor(0,line);lcd.print(" PID-I: ");
756
+          lcd.setCursor(0,line);lcdprintPGM(" PID-I: ");
730
           lcd.setCursor(13,line);lcd.print(ftostr51(Ki));
757
           lcd.setCursor(13,line);lcd.print(ftostr51(Ki));
731
         }
758
         }
732
         
759
         
760
       {
787
       {
761
       if(force_lcd_update)
788
       if(force_lcd_update)
762
         {
789
         {
763
-          lcd.setCursor(0,line);lcd.print(" PID-D: ");
790
+          lcd.setCursor(0,line);lcdprintPGM(" PID-D: ");
764
           lcd.setCursor(13,line);lcd.print(itostr4(Kd));
791
           lcd.setCursor(13,line);lcd.print(itostr4(Kd));
765
         }
792
         }
766
         
793
         
797
       {
824
       {
798
       if(force_lcd_update)
825
       if(force_lcd_update)
799
         {
826
         {
800
-          lcd.setCursor(0,line);lcd.print(" PID-C: ");
827
+          lcd.setCursor(0,line);lcdprintPGM(" PID-C: ");
801
           lcd.setCursor(13,line);lcd.print(itostr3(Kc));
828
           lcd.setCursor(13,line);lcd.print(itostr3(Kc));
802
         }
829
         }
803
         
830
         
834
       {
861
       {
835
       if(force_lcd_update)
862
       if(force_lcd_update)
836
         {
863
         {
837
-          lcd.setCursor(0,line);lcd.print(" Vmax ");
838
-          if(i==ItemC_vmaxx)lcd.print("x:");
839
-          if(i==ItemC_vmaxy)lcd.print("y:");
840
-          if(i==ItemC_vmaxz)lcd.print("z:");
841
-          if(i==ItemC_vmaxe)lcd.print("e:");
864
+          lcd.setCursor(0,line);lcdprintPGM(" Vmax ");
865
+          if(i==ItemC_vmaxx)lcdprintPGM("x:");
866
+          if(i==ItemC_vmaxy)lcdprintPGM("y:");
867
+          if(i==ItemC_vmaxz)lcdprintPGM("z:");
868
+          if(i==ItemC_vmaxe)lcdprintPGM("e:");
842
           lcd.setCursor(13,line);lcd.print(itostr3(max_feedrate[i-ItemC_vmaxx]/60));
869
           lcd.setCursor(13,line);lcd.print(itostr3(max_feedrate[i-ItemC_vmaxx]/60));
843
         }
870
         }
844
         
871
         
873
     {
900
     {
874
       if(force_lcd_update)
901
       if(force_lcd_update)
875
         {
902
         {
876
-          lcd.setCursor(0,line);lcd.print(" Vmin:");
903
+          lcd.setCursor(0,line);lcdprintPGM(" Vmin:");
877
           lcd.setCursor(13,line);lcd.print(itostr3(minimumfeedrate/60));
904
           lcd.setCursor(13,line);lcd.print(itostr3(minimumfeedrate/60));
878
         }
905
         }
879
         
906
         
907
     {
934
     {
908
       if(force_lcd_update)
935
       if(force_lcd_update)
909
         {
936
         {
910
-          lcd.setCursor(0,line);lcd.print(" VTrav min:");
937
+          lcd.setCursor(0,line);lcdprintPGM(" VTrav min:");
911
           lcd.setCursor(13,line);lcd.print(itostr3(mintravelfeedrate/60));
938
           lcd.setCursor(13,line);lcd.print(itostr3(mintravelfeedrate/60));
912
         }
939
         }
913
         
940
         
945
     {
972
     {
946
       if(force_lcd_update)
973
       if(force_lcd_update)
947
         {
974
         {
948
-          lcd.setCursor(0,line);lcd.print(" Amax ");
949
-          if(i==ItemC_amaxx)lcd.print("x:");
950
-          if(i==ItemC_amaxy)lcd.print("y:");
951
-          if(i==ItemC_amaxz)lcd.print("z:");
952
-          if(i==ItemC_amaxe)lcd.print("e:");
953
-          lcd.setCursor(13,line);lcd.print(itostr3(max_acceleration_units_per_sq_second[i-ItemC_amaxx]/100));lcd.print("00");
975
+          lcd.setCursor(0,line);lcdprintPGM(" Amax ");
976
+          if(i==ItemC_amaxx)lcdprintPGM("x:");
977
+          if(i==ItemC_amaxy)lcdprintPGM("y:");
978
+          if(i==ItemC_amaxz)lcdprintPGM("z:");
979
+          if(i==ItemC_amaxe)lcdprintPGM("e:");
980
+          lcd.setCursor(13,line);lcd.print(itostr3(max_acceleration_units_per_sq_second[i-ItemC_amaxx]/100));lcdprintPGM("00");
954
         }
981
         }
955
         
982
         
956
         if((activeline==line) )
983
         if((activeline==line) )
974
           {
1001
           {
975
             if(encoderpos<1) encoderpos=1;
1002
             if(encoderpos<1) encoderpos=1;
976
             if(encoderpos>990) encoderpos=990;
1003
             if(encoderpos>990) encoderpos=990;
977
-            lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcd.print("00");
1004
+            lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
978
           }
1005
           }
979
         }
1006
         }
980
       }break;
1007
       }break;
982
     {
1009
     {
983
         if(force_lcd_update)
1010
         if(force_lcd_update)
984
         {
1011
         {
985
-          lcd.setCursor(0,line);lcd.print(" A-retract:");
986
-          lcd.setCursor(13,line);lcd.print(ftostr3(retract_acceleration/100));lcd.print("00");
1012
+          lcd.setCursor(0,line);lcdprintPGM(" A-retract:");
1013
+          lcd.setCursor(13,line);lcd.print(ftostr3(retract_acceleration/100));lcdprintPGM("00");
987
         }
1014
         }
988
         
1015
         
989
         if((activeline==line) )
1016
         if((activeline==line) )
1008
           {
1035
           {
1009
             if(encoderpos<10) encoderpos=10;
1036
             if(encoderpos<10) encoderpos=10;
1010
             if(encoderpos>990) encoderpos=990;
1037
             if(encoderpos>990) encoderpos=990;
1011
-            lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcd.print("00");
1038
+            lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
1012
           }
1039
           }
1013
         }
1040
         }
1014
       }break;
1041
       }break;
1016
          {
1043
          {
1017
       if(force_lcd_update)
1044
       if(force_lcd_update)
1018
         {
1045
         {
1019
-          lcd.setCursor(0,line);lcd.print(" Esteps/mm:");
1046
+          lcd.setCursor(0,line);lcdprintPGM(" Esteps/mm:");
1020
           lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3]));
1047
           lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3]));
1021
         }
1048
         }
1022
         
1049
         
1053
     {
1080
     {
1054
       if(force_lcd_update)
1081
       if(force_lcd_update)
1055
       {
1082
       {
1056
-        lcd.setCursor(0,line);lcd.print(" Store EPROM");
1083
+        lcd.setCursor(0,line);lcdprintPGM(" Store EPROM");
1057
       }
1084
       }
1058
       if((activeline==line) && CLICKED)
1085
       if((activeline==line) && CLICKED)
1059
       {
1086
       {
1067
     {
1094
     {
1068
       if(force_lcd_update)
1095
       if(force_lcd_update)
1069
       {
1096
       {
1070
-        lcd.setCursor(0,line);lcd.print(" Load EPROM");
1097
+        lcd.setCursor(0,line);lcdprintPGM(" Load EPROM");
1071
       }
1098
       }
1072
       if((activeline==line) && CLICKED)
1099
       if((activeline==line) && CLICKED)
1073
       {
1100
       {
1081
     {
1108
     {
1082
       if(force_lcd_update)
1109
       if(force_lcd_update)
1083
       {
1110
       {
1084
-        lcd.setCursor(0,line);lcd.print(" Restore Failsafe");
1111
+        lcd.setCursor(0,line);lcdprintPGM(" Restore Failsafe");
1085
       }
1112
       }
1086
       if((activeline==line) && CLICKED)
1113
       if((activeline==line) && CLICKED)
1087
       {
1114
       {
1165
       {
1192
       {
1166
         if(force_lcd_update)
1193
         if(force_lcd_update)
1167
         {
1194
         {
1168
-          lcd.setCursor(0,line);lcd.print(" File");
1195
+          lcd.setCursor(0,line);lcdprintPGM(" File");
1169
         }
1196
         }
1170
         if((activeline==line) && CLICKED)
1197
         if((activeline==line) && CLICKED)
1171
         {
1198
         {
1185
           if(true)
1212
           if(true)
1186
           #endif
1213
           #endif
1187
           {
1214
           {
1188
-            lcd.print(" \004Refresh");
1215
+            lcdprintPGM(" \004Refresh");
1189
           }
1216
           }
1190
           else
1217
           else
1191
           {
1218
           {
1192
-            lcd.print(" \004Insert Card");
1219
+            lcdprintPGM(" \004Insert Card");
1193
           }
1220
           }
1194
           
1221
           
1195
         }
1222
         }
1210
         {
1237
         {
1211
           card.getfilename(i-2);
1238
           card.getfilename(i-2);
1212
           //Serial.print("Filenr:");Serial.println(i-2);
1239
           //Serial.print("Filenr:");Serial.println(i-2);
1213
-          lcd.setCursor(0,line);lcd.print(" ");lcd.print(card.filename);
1240
+          lcd.setCursor(0,line);lcdprintPGM(" ");lcd.print(card.filename);
1214
         }
1241
         }
1215
         if((activeline==line) && CLICKED)
1242
         if((activeline==line) && CLICKED)
1216
         {
1243
         {
1292
     { 
1319
     { 
1293
       case ItemM_watch:
1320
       case ItemM_watch:
1294
       {
1321
       {
1295
-        if(force_lcd_update) {lcd.setCursor(0,line);lcd.print(" Watch   \x7E");}
1322
+        if(force_lcd_update) {lcd.setCursor(0,line);lcdprintPGM(" Watch   \x7E");}
1296
         if((activeline==line)&&CLICKED)
1323
         if((activeline==line)&&CLICKED)
1297
         {
1324
         {
1298
           BLOCK;
1325
           BLOCK;
1302
       } break;
1329
       } break;
1303
       case ItemM_prepare:
1330
       case ItemM_prepare:
1304
       {
1331
       {
1305
-        if(force_lcd_update) {lcd.setCursor(0,line);lcd.print(" Prepare \x7E");}
1332
+        if(force_lcd_update) {lcd.setCursor(0,line);lcdprintPGM(" Prepare \x7E");}
1306
         if((activeline==line)&&CLICKED)
1333
         if((activeline==line)&&CLICKED)
1307
         {
1334
         {
1308
           BLOCK;
1335
           BLOCK;
1313
        
1340
        
1314
       case ItemM_control:
1341
       case ItemM_control:
1315
       {
1342
       {
1316
-        if(force_lcd_update) {lcd.setCursor(0,line);lcd.print(" Control \x7E");}
1343
+        if(force_lcd_update) {lcd.setCursor(0,line);lcdprintPGM(" Control \x7E");}
1317
         if((activeline==line)&&CLICKED)
1344
         if((activeline==line)&&CLICKED)
1318
         {
1345
         {
1319
           BLOCK;
1346
           BLOCK;
1334
           #endif
1361
           #endif
1335
           {
1362
           {
1336
             if(card.sdprinting)
1363
             if(card.sdprinting)
1337
-              lcd.print(" Stop Print   \x7E");
1364
+              lcdprintPGM(" Stop Print   \x7E");
1338
             else
1365
             else
1339
-              lcd.print(" Card Menu    \x7E");
1366
+              lcdprintPGM(" Card Menu    \x7E");
1340
           }
1367
           }
1341
           else
1368
           else
1342
           {
1369
           {
1343
-           lcd.print(" No Card"); 
1370
+           lcdprintPGM(" No Card"); 
1344
           }
1371
           }
1345
         }
1372
         }
1346
         #ifdef CARDINSERTED
1373
         #ifdef CARDINSERTED
1356
       }break;
1383
       }break;
1357
       #endif
1384
       #endif
1358
       default: 
1385
       default: 
1359
-        SERIAL_ERRORLN("Something is wrong in the MenuStructure.");
1386
+        SERIAL_ERROR_START;
1387
+        SERIAL_ERRORLNPGM("Something is wrong in the MenuStructure.");
1360
       break;
1388
       break;
1361
     }
1389
     }
1362
   }
1390
   }

+ 4
- 3
Marlin/watchdog.pde View File

41
   {
41
   {
42
  
42
  
43
     #ifdef RESET_MANUAL
43
     #ifdef RESET_MANUAL
44
-      LCD_MESSAGE("Please Reset!");
45
-      SERIAL_ERRORLN("Something is wrong, please turn off the printer.");
44
+      LCD_MESSAGEPGM("Please Reset!");
45
+      SERIAL_ERROR_START;
46
+      SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
46
     #else
47
     #else
47
-      LCD_MESSAGE("Timeout, resetting!");
48
+      LCD_MESSAGEPGM("Timeout, resetting!");
48
     #endif 
49
     #endif 
49
     //disable watchdog, it will survife reboot.
50
     //disable watchdog, it will survife reboot.
50
     WDTCSR |= (1<<WDCE) | (1<<WDE);
51
     WDTCSR |= (1<<WDCE) | (1<<WDE);

Loading…
Cancel
Save