浏览代码

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

Erik van der Zalm 13 年前
父节点
当前提交
ac82411c73
共有 16 个文件被更改,包括 1434 次插入1147 次删除
  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 查看文件

@@ -1,10 +1,13 @@
1 1
 #ifndef __CONFIGURATION_H
2 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 12
 // Frequency limit
10 13
 // See nophead's blog for more info
@@ -26,7 +29,9 @@
26 29
 // Teensylu = 8
27 30
 #define MOTHERBOARD 7
28 31
 
29
-
32
+//===========================================================================
33
+//=============================Thermal Settings  ============================
34
+//===========================================================================
30 35
 
31 36
 //// Thermistor settings:
32 37
 // 1 is 100k thermistor
@@ -49,49 +54,103 @@
49 54
 //#define BED_USES_THERMISTOR
50 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 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 155
 // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
97 156
 #define X_ENABLE_ON 0
@@ -156,88 +215,33 @@ const int dropsegments=5; //everything with this number of steps  will be ignore
156 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 246
 // extruder advance constant (s2/mm3)
243 247
 //
@@ -258,6 +262,52 @@ const int dropsegments=5; //everything with this number of steps  will be ignore
258 262
 
259 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 311
 // The number of linear motions that can be in the plan at any give time.  
262 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 313
 #if defined SDSUPPORT
@@ -266,8 +316,12 @@ const int dropsegments=5; //everything with this number of steps  will be ignore
266 316
   #define BLOCK_BUFFER_SIZE 8 // maximize block buffer
267 317
 #endif
268 318
 
319
+
269 320
 //The ASCII buffer for recieving from the serial:
270 321
 #define MAX_CMD_SIZE 96
271 322
 #define BUFSIZE 4
272 323
 
324
+
325
+#include "thermistortables.h"
326
+
273 327
 #endif //__CONFIGURATION_H

+ 107
- 59
Marlin/EEPROMwrite.h 查看文件

@@ -25,6 +25,9 @@ template <class T> int EEPROM_readAnything(int &ee, T& value)
25 25
 }
26 26
 //======================================================================================
27 27
 
28
+
29
+
30
+
28 31
 #define EEPROM_OFFSET 100
29 32
 
30 33
 
@@ -35,8 +38,9 @@ template <class T> int EEPROM_readAnything(int &ee, T& value)
35 38
 // ALSO:  always make sure the variables in the Store and retrieve sections are in the same order.
36 39
 #define EEPROM_VERSION "V04"  
37 40
 
38
-void StoreSettings() 
41
+inline void StoreSettings() 
39 42
 {
43
+#ifdef EEPROM_SETTINGS
40 44
   char ver[4]= "000";
41 45
   int i=EEPROM_OFFSET;
42 46
   EEPROM_writeAnything(i,ver); // invalidate data first 
@@ -62,71 +66,115 @@ void StoreSettings()
62 66
   char ver2[4]=EEPROM_VERSION;
63 67
   i=EEPROM_OFFSET;
64 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 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 175
   #endif
176
+    
177
+  #endif //EEPROM_SETTINGS
130 178
 }  
131 179
 
132 180
 #endif

+ 46
- 5
Marlin/Marlin.h 查看文件

@@ -5,12 +5,52 @@
5 5
 // Licence: GPL
6 6
 #include <WProgram.h>
7 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 55
 void get_command();
16 56
 void process_commands();
@@ -69,5 +109,6 @@ void enquecommand(const char *cmd); //put an ascii command at the end of the cur
69 109
 
70 110
 extern float homing_feedrate[];
71 111
 extern bool axis_relative_modes[];
112
+extern float current_position[NUM_AXIS] ;
72 113
 
73 114
 #endif

+ 158
- 97
Marlin/Marlin.pde 查看文件

@@ -32,7 +32,6 @@
32 32
 #include "pins.h"
33 33
 #include "Marlin.h"
34 34
 #include "ultralcd.h"
35
-#include "streaming.h"
36 35
 #include "planner.h"
37 36
 #include "stepper.h"
38 37
 #include "temperature.h"
@@ -40,7 +39,8 @@
40 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,8 +99,9 @@ char version_string[] = "1.0.0 Alpha 1";
99 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 100
 // M220 - set speed factor override percentage S:factor in percent
101 101
 // M301 - Set PID parameters P I and D
102
+// M400 - Finish all moves
102 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 105
 // M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
105 106
 
106 107
 //Stepper Movement Variables
@@ -122,13 +123,14 @@ bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
122 123
 volatile int feedmultiply=100; //100->1 200->2
123 124
 int saved_feedmultiply;
124 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 130
 //=============================private variables=============================
128 131
 //===========================================================================
129 132
 const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
130 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 134
 static float offset[3] = {0.0, 0.0, 0.0};
133 135
 static bool home_all_axis = true;
134 136
 static float feedrate = 1500.0, next_feedrate, saved_feedrate;
@@ -173,6 +175,23 @@ static unsigned long stoptime=0;
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 196
 //adds an command to the main command buffer
178 197
 //thats really done in a non-safe way.
@@ -183,7 +202,10 @@ void enquecommand(const char *cmd)
183 202
   {
184 203
     //this is dangerous if a mixing of serial and this happsens
185 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 209
     bufindw= (bufindw + 1)%BUFSIZE;
188 210
     buflen += 1;
189 211
   }
@@ -192,8 +214,12 @@ void enquecommand(const char *cmd)
192 214
 void setup()
193 215
 { 
194 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 223
   for(int8_t i = 0; i < BUFSIZE; i++)
198 224
   {
199 225
     fromsd[i] = false;
@@ -228,12 +254,12 @@ void loop()
228 254
 	if(strstr(cmdbuffer[bufindr],"M29") == NULL)
229 255
 	{
230 256
 	  card.write_command(cmdbuffer[bufindr]);
231
-	  Serial.println("ok");
257
+	  SERIAL_PROTOCOLLNPGM("ok");
232 258
 	}
233 259
 	else
234 260
 	{
235 261
 	  card.closefile();
236
-	  Serial.println("Done saving file.");
262
+	  SERIAL_PROTOCOLLNPGM("Done saving file.");
237 263
 	}
238 264
       }
239 265
       else
@@ -249,6 +275,7 @@ void loop()
249 275
   //check heater every n milliseconds
250 276
   manage_heater();
251 277
   manage_inactivity(1);
278
+  checkHitEndstops();
252 279
   LCD_STATUS;
253 280
 }
254 281
 
@@ -268,8 +295,9 @@ inline void get_command()
268 295
           strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
269 296
           gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10));
270 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 301
             //Serial.println(gcode_N);
274 302
             FlushSerialRequestResend();
275 303
             serial_count = 0;
@@ -284,8 +312,9 @@ inline void get_command()
284 312
             strchr_pointer = strchr(cmdbuffer[bufindw], '*');
285 313
 
286 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 318
               FlushSerialRequestResend();
290 319
               serial_count = 0;
291 320
               return;
@@ -294,8 +323,9 @@ inline void get_command()
294 323
           }
295 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 329
             FlushSerialRequestResend();
300 330
             serial_count = 0;
301 331
             return;
@@ -308,8 +338,9 @@ inline void get_command()
308 338
         {
309 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 344
             serial_count = 0;
314 345
             return;
315 346
           }
@@ -325,7 +356,7 @@ inline void get_command()
325 356
             if(card.saving)
326 357
               break;
327 358
 	    #endif //SDSUPPORT
328
-            Serial.println("ok"); 
359
+            SERIAL_PROTOCOLLNPGM("ok"); 
329 360
             break;
330 361
           default:
331 362
             break;
@@ -350,22 +381,23 @@ inline void get_command()
350 381
     return;
351 382
   }
352 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 389
       if(card.eof()){
359 390
         card.sdprinting = false;
360
-        Serial.println("echo: Done printing file");
391
+        SERIAL_PROTOCOLLNPGM("Done printing file");
361 392
         stoptime=millis();
362 393
         char time[30];
363 394
         unsigned long t=(stoptime-starttime)/1000;
364 395
         int sec,min;
365 396
         min=t/60;
366 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 401
         LCD_MESSAGE(time);
370 402
         card.checkautostart(true);
371 403
       }
@@ -386,6 +418,7 @@ inline void get_command()
386 418
       if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
387 419
     }
388 420
   }
421
+  
389 422
   #endif //SDSUPPORT
390 423
 
391 424
 }
@@ -417,20 +450,25 @@ inline bool code_seen(char code)
417 450
     destination[LETTER##_AXIS] = 1.5 * LETTER##_MAX_LENGTH * LETTER##_HOME_DIR; \
418 451
     feedrate = homing_feedrate[LETTER##_AXIS]; \
419 452
     prepare_move(); \
453
+    st_synchronize();\
420 454
     \
421 455
     current_position[LETTER##_AXIS] = 0;\
422 456
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
423 457
     destination[LETTER##_AXIS] = -5 * LETTER##_HOME_DIR;\
424 458
     prepare_move(); \
459
+    st_synchronize();\
425 460
     \
426 461
     destination[LETTER##_AXIS] = 10 * LETTER##_HOME_DIR;\
427 462
     feedrate = homing_feedrate[LETTER##_AXIS]/2 ;  \
428 463
     prepare_move(); \
464
+    st_synchronize();\
429 465
     \
430 466
     current_position[LETTER##_AXIS] = (LETTER##_HOME_DIR == -1) ? 0 : LETTER##_MAX_LENGTH;\
431 467
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
432 468
     destination[LETTER##_AXIS] = current_position[LETTER##_AXIS];\
433 469
     feedrate = 0.0;\
470
+    st_synchronize();\
471
+    endstops_hit_on_purpose();\
434 472
   }
435 473
 
436 474
 inline void process_commands()
@@ -461,6 +499,7 @@ inline void process_commands()
461 499
       previous_millis_cmd = millis();
462 500
       return;
463 501
     case 4: // G4 dwell
502
+      LCD_MESSAGEPGM("DWELL...");
464 503
       codenum = 0;
465 504
       if(code_seen('P')) codenum = code_value(); // milliseconds to wait
466 505
       if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
@@ -495,6 +534,7 @@ inline void process_commands()
495 534
       feedrate = saved_feedrate;
496 535
       feedmultiply = saved_feedmultiply;
497 536
       previous_millis_cmd = millis();
537
+      endstops_hit_on_purpose();
498 538
       break;
499 539
     case 90: // G90
500 540
       relative_mode = false;
@@ -521,13 +561,14 @@ inline void process_commands()
521 561
     #ifdef SDSUPPORT
522 562
 
523 563
     case 20: // M20 - list SD card
524
-      Serial.println("Begin file list");
564
+      SERIAL_PROTOCOLLNPGM("Begin file list");
525 565
       card.ls();
526
-      Serial.println("End file list");
566
+      SERIAL_PROTOCOLLNPGM("End file list");
527 567
       break;
528 568
     case 21: // M21 - init SD card
529 569
       
530 570
       card.initsd();
571
+      
531 572
       break;
532 573
     case 22: //M22 - release SD card
533 574
       card.release();
@@ -579,8 +620,9 @@ inline void process_commands()
579 620
       int sec,min;
580 621
       min=t/60;
581 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 626
       LCD_MESSAGE(time);
585 627
     }
586 628
     break;
@@ -617,37 +659,30 @@ inline void process_commands()
617 659
       if (code_seen('S')) setTargetBed(code_value());
618 660
       break;
619 661
     case 105: // M105
662
+      //SERIAL_ECHOLN(freeMemory());
663
+          
620 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 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 679
       #endif
680
+        SERIAL_PROTOCOLLN("");
646 681
       return;
647 682
       break;
648 683
     case 109: 
649 684
     {// M109 - Wait for extruder heater to reach target.
650
-        LCD_MESSAGE("Heating...");
685
+        LCD_MESSAGEPGM("Heating...");
651 686
         if (code_seen('S')) setTargetHotend0(code_value());
652 687
         
653 688
         setWatch();
@@ -668,8 +703,8 @@ inline void process_commands()
668 703
         #endif //TEMP_RESIDENCY_TIME
669 704
         if( (millis() - codenum) > 1000 ) 
670 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 708
           codenum = millis();
674 709
         }
675 710
         manage_heater();
@@ -685,12 +720,13 @@ inline void process_commands()
685 720
           }
686 721
         #endif //TEMP_RESIDENCY_TIME
687 722
         }
688
-        LCD_MESSAGE("Heating done.");
723
+        LCD_MESSAGEPGM("Heating done.");
689 724
         starttime=millis();
690 725
       }
691 726
       break;
692 727
     case 190: // M190 - Wait bed for heater to reach target.
693 728
     #if TEMP_1_PIN > -1
729
+        LCD_MESSAGEPGM("Bed Heating.");
694 730
         if (code_seen('S')) setTargetBed(code_value());
695 731
         codenum = millis(); 
696 732
         while(isHeatingBed()) 
@@ -698,16 +734,17 @@ inline void process_commands()
698 734
           if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
699 735
           {
700 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 743
             codenum = millis(); 
708 744
           }
709 745
           manage_heater();
710 746
         }
747
+        LCD_MESSAGEPGM("Bed done.");
711 748
     #endif
712 749
     break;
713 750
 
@@ -752,6 +789,7 @@ inline void process_commands()
752 789
       else
753 790
       { 
754 791
         st_synchronize(); 
792
+        LCD_MESSAGEPGM("Free move.");
755 793
         disable_x(); 
756 794
         disable_y(); 
757 795
         disable_z(); 
@@ -770,53 +808,53 @@ inline void process_commands()
770 808
       }
771 809
       break;
772 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 812
       break;
775 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 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 829
       #endif
792
-      Serial.println("");
830
+      SERIAL_PROTOCOLLN("");
793 831
       break;
794 832
     case 119: // M119
795 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 836
       #endif
799 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 840
       #endif
803 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 844
       #endif
807 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 848
       #endif
811 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 852
       #endif
815 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 856
       #endif
819
-      Serial.println("");
857
+      SERIAL_PROTOCOLLN("");
820 858
       break;
821 859
       //TODO: update for all axis, use for loop
822 860
     case 201: // M201
@@ -867,8 +905,28 @@ inline void process_commands()
867 905
       if(code_seen('P')) Kp = code_value();
868 906
       if(code_seen('I')) Ki = code_value()*PID_dT;
869 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 923
       break;
871 924
     #endif //PIDTEMP
925
+    case 400: // finish all moves
926
+    {
927
+      st_synchronize();
928
+    }
929
+    break;
872 930
     case 500: // Store settings in EEPROM
873 931
     {
874 932
         StoreSettings();
@@ -889,9 +947,10 @@ inline void process_commands()
889 947
   }
890 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 956
   ClearToSend();
@@ -901,8 +960,8 @@ void FlushSerialRequestResend()
901 960
 {
902 961
   //char cmdbuffer[bufindr][100]="Resend:";
903 962
   Serial.flush();
904
-  Serial.print("Resend:");
905
-  Serial.println(gcode_LastN + 1);
963
+  SERIAL_PROTOCOLPGM("Resend:");
964
+  SERIAL_PROTOCOLLN(gcode_LastN + 1);
906 965
   ClearToSend();
907 966
 }
908 967
 
@@ -913,7 +972,7 @@ void ClearToSend()
913 972
   if(fromsd[bufindr])
914 973
     return;
915 974
   #endif //SDSUPPORT
916
-  Serial.println("ok"); 
975
+  SERIAL_PROTOCOLLNPGM("ok"); 
917 976
 }
918 977
 
919 978
 inline void get_coordinates()
@@ -987,7 +1046,9 @@ void kill()
987 1046
   disable_e();
988 1047
   
989 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 1052
   while(1); // Wait for reset
992 1053
 }
993 1054
 

+ 31
- 2
Marlin/cardreader.h 查看文件

@@ -30,8 +30,8 @@ public:
30 30
   
31 31
 
32 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 35
   inline void setIndex(long index) {sdpos = index;file.seekSet(index);};
36 36
 
37 37
 public:
@@ -52,6 +52,35 @@ private:
52 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 84
 #endif //SDSUPPORT
56 85
   
57 86
   

+ 26
- 21
Marlin/cardreader.pde 查看文件

@@ -29,20 +29,24 @@ void CardReader::initsd()
29 29
     if (!card.init(SPI_FULL_SPEED,SDSS))
30 30
     {
31 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 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 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 45
     else 
43 46
     {
44 47
       cardOK = true;
45
-      SERIAL_ECHOLN("SD card ok");
48
+      SERIAL_ECHO_START;
49
+      SERIAL_ECHOLNPGM("SD card ok");
46 50
     }
47 51
   #endif //SDSS
48 52
 }
@@ -76,17 +80,17 @@ void CardReader::selectFile(char* name)
76 80
     file.close();
77 81
    
78 82
     if (file.open(&root, name, O_READ)) {
79
-      Serial.print("File opened:");
80
-      Serial.print(name);
81
-      Serial.print(" Size:");
82 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 88
       sdpos = 0;
85 89
       
86
-      Serial.println("File selected");
90
+      SERIAL_PROTOCOLLNPGM("File selected");
87 91
     }
88 92
     else{
89
-      Serial.println("file.open failed");
93
+      SERIAL_PROTOCOLLNPGM("file.open failed");
90 94
     }
91 95
   }
92 96
 }
@@ -101,14 +105,14 @@ void CardReader::startFilewrite(char *name)
101 105
     
102 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 112
     else{
109 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,13 +120,13 @@ void CardReader::startFilewrite(char *name)
116 120
 void CardReader::getStatus()
117 121
 {
118 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 128
   else{
125
-    Serial.println("Not SD printing");
129
+    SERIAL_PROTOCOLLNPGM("Not SD printing");
126 130
   }
127 131
 }
128 132
 void CardReader::write_command(char *buf)
@@ -143,7 +147,8 @@ void CardReader::write_command(char *buf)
143 147
   file.write(begin);
144 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
文件差异内容过多而无法显示
查看文件


+ 36
- 2
Marlin/planner.cpp 查看文件

@@ -86,6 +86,10 @@ long position[4];   //rescaled from extern when axis_steps_per_unit are changed
86 86
 static float previous_speed[4]; // Speed of previous path line segment
87 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 95
 //=============================private variables ============================
@@ -372,6 +376,34 @@ block_t *plan_get_current_block() {
372 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 407
 void check_axes_activity() {
376 408
   unsigned char x_active = 0;
377 409
   unsigned char y_active = 0;  
@@ -686,7 +718,9 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
686 718
   memcpy(position, target, sizeof(target)); // position[] = target[]
687 719
 
688 720
   planner_recalculate();
689
-  
721
+  #ifdef AUTOTEMP
722
+    getHighESpeed();
723
+  #endif
690 724
   st_wake_up();
691 725
 }
692 726
 
@@ -702,4 +736,4 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo
702 736
   previous_speed[2] = 0.0;
703 737
   previous_speed[3] = 0.0;
704 738
 }
705
-
739
+

+ 4
- 2
Marlin/planner.h 查看文件

@@ -92,5 +92,7 @@ extern float max_xy_jerk; //speed than can be stopped at once, if i understand c
92 92
 extern float max_z_jerk;
93 93
 extern float mintravelfeedrate;
94 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 查看文件

@@ -33,12 +33,14 @@
33 33
 #include "speed_lookuptable.h"
34 34
 
35 35
 
36
+
36 37
 //===========================================================================
37 38
 //=============================public variables  ============================
38 39
 //===========================================================================
39 40
 block_t *current_block;  // A pointer to the block currently being traced
40 41
 
41 42
 
43
+
42 44
 //===========================================================================
43 45
 //=============================private variables ============================
44 46
 //===========================================================================
@@ -62,7 +64,9 @@ static long acceleration_time, deceleration_time;
62 64
 static unsigned short acc_step_rate; // needed for deccelaration start point
63 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 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 72
 // for debugging purposes only, should be disabled by default
@@ -152,9 +156,49 @@ asm volatile ( \
152 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,7 +276,9 @@ inline void trapezoid_generator_reset() {
232 276
 ISR(TIMER1_COMPA_vect)
233 277
 {        
234 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 282
     return; 
237 283
   } // The busy-flag is used to avoid reentering this interrupt
238 284
 
@@ -294,6 +340,7 @@ ISR(TIMER1_COMPA_vect)
294 340
       #endif
295 341
       #if X_MIN_PIN > -1
296 342
             if(READ(X_MIN_PIN) != ENDSTOPS_INVERTING) {
343
+              endstops_triggered(step_events_completed);
297 344
               step_events_completed = current_block->step_event_count;
298 345
             }
299 346
       #endif
@@ -305,6 +352,7 @@ ISR(TIMER1_COMPA_vect)
305 352
       #endif
306 353
       #if X_MAX_PIN > -1
307 354
         if((READ(X_MAX_PIN) != ENDSTOPS_INVERTING)  && (current_block->steps_x >0)){
355
+          endstops_triggered(step_events_completed);
308 356
           step_events_completed = current_block->step_event_count;
309 357
         }
310 358
         #endif
@@ -317,6 +365,7 @@ ISR(TIMER1_COMPA_vect)
317 365
       #endif
318 366
       #if Y_MIN_PIN > -1
319 367
         if(READ(Y_MIN_PIN) != ENDSTOPS_INVERTING) {
368
+          endstops_triggered(step_events_completed);
320 369
           step_events_completed = current_block->step_event_count;
321 370
         }
322 371
       #endif
@@ -328,6 +377,7 @@ ISR(TIMER1_COMPA_vect)
328 377
       #endif
329 378
       #if Y_MAX_PIN > -1
330 379
       if((READ(Y_MAX_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_y >0)){
380
+          endstops_triggered(step_events_completed);
331 381
           step_events_completed = current_block->step_event_count;
332 382
         }
333 383
       #endif
@@ -340,6 +390,7 @@ ISR(TIMER1_COMPA_vect)
340 390
       #endif
341 391
       #if Z_MIN_PIN > -1
342 392
         if(READ(Z_MIN_PIN) != ENDSTOPS_INVERTING) {
393
+          endstops_triggered(step_events_completed);
343 394
           step_events_completed = current_block->step_event_count;
344 395
         }
345 396
       #endif
@@ -351,6 +402,7 @@ ISR(TIMER1_COMPA_vect)
351 402
       #endif
352 403
       #if Z_MAX_PIN > -1
353 404
         if((READ(Z_MAX_PIN) != ENDSTOPS_INVERTING)  && (current_block->steps_z >0)){
405
+          endstops_triggered(step_events_completed);
354 406
           step_events_completed = current_block->step_event_count;
355 407
         }
356 408
       #endif
@@ -614,4 +666,4 @@ void st_synchronize()
614 666
     manage_inactivity(1);
615 667
     LCD_STATUS;
616 668
   }   
617
-}
669
+}

+ 7
- 0
Marlin/stepper.h 查看文件

@@ -39,6 +39,13 @@ void st_wake_up();
39 39
   extern volatile long count_position[NUM_AXIS];
40 40
   extern volatile int count_direction[NUM_AXIS];
41 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 48
 extern block_t *current_block;  // A pointer to the block currently being traced
49
+
50
+
44 51
 #endif

+ 0
- 84
Marlin/streaming.h 查看文件

@@ -1,84 +0,0 @@
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 查看文件

@@ -35,7 +35,6 @@
35 35
 #include "pins.h"
36 36
 #include "Marlin.h"
37 37
 #include "ultralcd.h"
38
-#include "streaming.h"
39 38
 #include "temperature.h"
40 39
 #include "watchdog.h"
41 40
 
@@ -160,11 +159,13 @@ void manage_heater()
160 159
 //            pTerm+=Kc*current_block->speed_e; //additional heating if extrusion speed is high
161 160
 //          #endif
162 161
           pid_output = constrain(pTerm + iTerm - dTerm, 0, PID_MAX);
162
+          
163 163
         }
164 164
     #endif //PID_OPENLOOP
165 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 167
     #endif //PID_DEBUG
168
+    HeaterPower=pid_output;
168 169
     analogWrite(HEATER_0_PIN, pid_output);
169 170
   #endif //PIDTEMP
170 171
 
@@ -253,7 +254,7 @@ int temp2analogBed(int celsius) {
253 254
 
254 255
     return (1023 * OVERSAMPLENR) - raw;
255 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 258
   #endif
258 259
 }
259 260
 
@@ -464,7 +465,8 @@ ISR(TIMER0_COMPB_vect)
464 465
       temp_count++;
465 466
       break;
466 467
     default:
467
-      SERIAL_ERRORLN("Temp measurement error!");
468
+      SERIAL_ERROR_START;
469
+      SERIAL_ERRORLNPGM("Temp measurement error!");
468 470
       break;
469 471
   }
470 472
     
@@ -498,7 +500,8 @@ ISR(TIMER0_COMPB_vect)
498 500
         if(current_raw[TEMPSENSOR_HOTEND_0] >= maxttemp_0) {
499 501
           target_raw[TEMPSENSOR_HOTEND_0] = 0;
500 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 505
           kill();
503 506
         }
504 507
       #endif
@@ -509,7 +512,8 @@ ISR(TIMER0_COMPB_vect)
509 512
         target_raw[TEMPSENSOR_HOTEND_1] = 0;
510 513
       if(current_raw[2] >= maxttemp_1) {
511 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 517
         kill()
514 518
       }
515 519
     #endif
@@ -520,7 +524,8 @@ ISR(TIMER0_COMPB_vect)
520 524
       if(current_raw[TEMPSENSOR_HOTEND_0] <= minttemp_0) {
521 525
         target_raw[TEMPSENSOR_HOTEND_0] = 0;
522 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 529
         kill();
525 530
       }
526 531
     #endif
@@ -531,7 +536,8 @@ ISR(TIMER0_COMPB_vect)
531 536
       if(current_raw[TEMPSENSOR_HOTEND_1] <= minttemp_1) {
532 537
         target_raw[TEMPSENSOR_HOTEND_1] = 0;
533 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 541
         kill();
536 542
       }
537 543
     #endif
@@ -542,7 +548,8 @@ ISR(TIMER0_COMPB_vect)
542 548
       if(current_raw[1] <= bed_minttemp) {
543 549
         target_raw[1] = 0;
544 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 553
         kill();
547 554
       }
548 555
     #endif
@@ -553,7 +560,8 @@ ISR(TIMER0_COMPB_vect)
553 560
       if(current_raw[1] >= bed_maxttemp) {
554 561
         target_raw[1] = 0;
555 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 565
         kill();
558 566
       }
559 567
     #endif
@@ -561,4 +569,4 @@ ISR(TIMER0_COMPB_vect)
561 569
   }
562 570
 }
563 571
 
564
-
572
+

+ 1
- 0
Marlin/ultralcd.h 查看文件

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

+ 85
- 57
Marlin/ultralcd.pde 查看文件

@@ -42,6 +42,19 @@ static long previous_millis_buttons=0;
42 42
  
43 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 60
 //=============================functions         ============================
@@ -54,6 +67,20 @@ void lcd_status(const char* message)
54 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 84
 inline void clear()
58 85
 {
59 86
   lcd.clear();
@@ -92,7 +119,7 @@ void lcd_init()
92 119
   lcd.createChar(2,Thermometer);
93 120
   lcd.createChar(3,uplevel);
94 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,9 +291,9 @@ void MainMenu::showStatus()
264 291
     feedmultiplychanged=false;
265 292
     encoderpos=feedmultiply;
266 293
     clear();
267
-    lcd.setCursor(0,0);lcd.print("\002123/567\001 ");
294
+    lcd.setCursor(0,0);lcdprintPGM("\002123/567\001 ");
268 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 297
     #endif
271 298
   }
272 299
     
@@ -311,7 +338,7 @@ void MainMenu::showStatus()
311 338
     
312 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 342
       oldtime=time;
316 343
     }
317 344
   }
@@ -320,7 +347,7 @@ void MainMenu::showStatus()
320 347
   if((currentz!=oldzpos)||force_lcd_update)
321 348
   {
322 349
     lcd.setCursor(10,1);
323
-    lcd.print("Z:");lcd.print(itostr31(currentz));
350
+    lcdprintPGM("Z:");lcd.print(itostr31(currentz));
324 351
     oldzpos=currentz;
325 352
   }
326 353
   static int oldfeedmultiply=0;
@@ -339,7 +366,7 @@ void MainMenu::showStatus()
339 366
   {
340 367
    oldfeedmultiply=curfeedmultiply;
341 368
    lcd.setCursor(0,2);
342
-   lcd.print(itostr3(curfeedmultiply));lcd.print("% ");
369
+   lcd.print(itostr3(curfeedmultiply));lcdprintPGM("% ");
343 370
   }
344 371
   if(messagetext[0]!='\0')
345 372
   {
@@ -353,9 +380,9 @@ void MainMenu::showStatus()
353 380
   if(force_lcd_update)  //initial display of content
354 381
   {
355 382
     encoderpos=feedmultiply;
356
-    lcd.setCursor(0,0);lcd.print("\002123/567\001 ");
383
+    lcd.setCursor(0,0);lcdprintPGM("\002123/567\001 ");
357 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 386
     #endif
360 387
   }
361 388
     
@@ -405,7 +432,7 @@ void MainMenu::showPrepare()
405 432
       {
406 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 437
         if((activeline==line) && CLICKED)
411 438
         {
@@ -418,7 +445,7 @@ void MainMenu::showPrepare()
418 445
       {
419 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 450
         if((activeline==line) && CLICKED)
424 451
         {
@@ -431,7 +458,7 @@ void MainMenu::showPrepare()
431 458
       {
432 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 464
         if((activeline==line) && CLICKED)
@@ -445,7 +472,7 @@ void MainMenu::showPrepare()
445 472
       {
446 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 477
         if((activeline==line) && CLICKED)
451 478
         {
@@ -458,7 +485,7 @@ void MainMenu::showPrepare()
458 485
       {
459 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 490
         if((activeline==line) && CLICKED)
464 491
         {
@@ -472,7 +499,7 @@ void MainMenu::showPrepare()
472 499
       {
473 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 504
         if((activeline==line) && CLICKED)
478 505
         {
@@ -541,7 +568,7 @@ void MainMenu::showControl()
541 568
       {
542 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 573
         if((activeline==line) && CLICKED)
547 574
         {
@@ -554,7 +581,7 @@ void MainMenu::showControl()
554 581
       {
555 582
         if(force_lcd_update)
556 583
         {
557
-          lcd.setCursor(0,line);lcd.print(" \002Nozzle:");
584
+          lcd.setCursor(0,line);lcdprintPGM(" \002Nozzle:");
558 585
           lcd.setCursor(13,line);lcd.print(ftostr3(intround(degHotend0())));
559 586
         }
560 587
         
@@ -588,7 +615,7 @@ void MainMenu::showControl()
588 615
       {
589 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 619
           lcd.setCursor(13,line);lcd.print(ftostr3(fanpwm));
593 620
         }
594 621
         
@@ -625,8 +652,8 @@ void MainMenu::showControl()
625 652
     {
626 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 659
         if((activeline==line) )
@@ -650,7 +677,7 @@ void MainMenu::showControl()
650 677
           {
651 678
             if(encoderpos<5) encoderpos=5;
652 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 683
       }break;
@@ -658,7 +685,7 @@ void MainMenu::showControl()
658 685
       {
659 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 689
           lcd.setCursor(13,line);lcd.print(itostr3(max_xy_jerk/60));
663 690
         }
664 691
         
@@ -692,7 +719,7 @@ void MainMenu::showControl()
692 719
       {
693 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 723
           lcd.setCursor(13,line);lcd.print(itostr4(Kp));
697 724
         }
698 725
         
@@ -726,7 +753,7 @@ void MainMenu::showControl()
726 753
       {
727 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 757
           lcd.setCursor(13,line);lcd.print(ftostr51(Ki));
731 758
         }
732 759
         
@@ -760,7 +787,7 @@ void MainMenu::showControl()
760 787
       {
761 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 791
           lcd.setCursor(13,line);lcd.print(itostr4(Kd));
765 792
         }
766 793
         
@@ -797,7 +824,7 @@ void MainMenu::showControl()
797 824
       {
798 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 828
           lcd.setCursor(13,line);lcd.print(itostr3(Kc));
802 829
         }
803 830
         
@@ -834,11 +861,11 @@ void MainMenu::showControl()
834 861
       {
835 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 869
           lcd.setCursor(13,line);lcd.print(itostr3(max_feedrate[i-ItemC_vmaxx]/60));
843 870
         }
844 871
         
@@ -873,7 +900,7 @@ void MainMenu::showControl()
873 900
     {
874 901
       if(force_lcd_update)
875 902
         {
876
-          lcd.setCursor(0,line);lcd.print(" Vmin:");
903
+          lcd.setCursor(0,line);lcdprintPGM(" Vmin:");
877 904
           lcd.setCursor(13,line);lcd.print(itostr3(minimumfeedrate/60));
878 905
         }
879 906
         
@@ -907,7 +934,7 @@ void MainMenu::showControl()
907 934
     {
908 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 938
           lcd.setCursor(13,line);lcd.print(itostr3(mintravelfeedrate/60));
912 939
         }
913 940
         
@@ -945,12 +972,12 @@ void MainMenu::showControl()
945 972
     {
946 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 983
         if((activeline==line) )
@@ -974,7 +1001,7 @@ void MainMenu::showControl()
974 1001
           {
975 1002
             if(encoderpos<1) encoderpos=1;
976 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 1007
       }break;
@@ -982,8 +1009,8 @@ void MainMenu::showControl()
982 1009
     {
983 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 1016
         if((activeline==line) )
@@ -1008,7 +1035,7 @@ void MainMenu::showControl()
1008 1035
           {
1009 1036
             if(encoderpos<10) encoderpos=10;
1010 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 1041
       }break;
@@ -1016,7 +1043,7 @@ void MainMenu::showControl()
1016 1043
          {
1017 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 1047
           lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3]));
1021 1048
         }
1022 1049
         
@@ -1053,7 +1080,7 @@ void MainMenu::showControl()
1053 1080
     {
1054 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 1085
       if((activeline==line) && CLICKED)
1059 1086
       {
@@ -1067,7 +1094,7 @@ void MainMenu::showControl()
1067 1094
     {
1068 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 1099
       if((activeline==line) && CLICKED)
1073 1100
       {
@@ -1081,7 +1108,7 @@ void MainMenu::showControl()
1081 1108
     {
1082 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 1113
       if((activeline==line) && CLICKED)
1087 1114
       {
@@ -1165,7 +1192,7 @@ void MainMenu::showSD()
1165 1192
       {
1166 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 1197
         if((activeline==line) && CLICKED)
1171 1198
         {
@@ -1185,11 +1212,11 @@ void MainMenu::showSD()
1185 1212
           if(true)
1186 1213
           #endif
1187 1214
           {
1188
-            lcd.print(" \004Refresh");
1215
+            lcdprintPGM(" \004Refresh");
1189 1216
           }
1190 1217
           else
1191 1218
           {
1192
-            lcd.print(" \004Insert Card");
1219
+            lcdprintPGM(" \004Insert Card");
1193 1220
           }
1194 1221
           
1195 1222
         }
@@ -1210,7 +1237,7 @@ void MainMenu::showSD()
1210 1237
         {
1211 1238
           card.getfilename(i-2);
1212 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 1242
         if((activeline==line) && CLICKED)
1216 1243
         {
@@ -1292,7 +1319,7 @@ void MainMenu::showMainMenu()
1292 1319
     { 
1293 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 1323
         if((activeline==line)&&CLICKED)
1297 1324
         {
1298 1325
           BLOCK;
@@ -1302,7 +1329,7 @@ void MainMenu::showMainMenu()
1302 1329
       } break;
1303 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 1333
         if((activeline==line)&&CLICKED)
1307 1334
         {
1308 1335
           BLOCK;
@@ -1313,7 +1340,7 @@ void MainMenu::showMainMenu()
1313 1340
        
1314 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 1344
         if((activeline==line)&&CLICKED)
1318 1345
         {
1319 1346
           BLOCK;
@@ -1334,13 +1361,13 @@ void MainMenu::showMainMenu()
1334 1361
           #endif
1335 1362
           {
1336 1363
             if(card.sdprinting)
1337
-              lcd.print(" Stop Print   \x7E");
1364
+              lcdprintPGM(" Stop Print   \x7E");
1338 1365
             else
1339
-              lcd.print(" Card Menu    \x7E");
1366
+              lcdprintPGM(" Card Menu    \x7E");
1340 1367
           }
1341 1368
           else
1342 1369
           {
1343
-           lcd.print(" No Card"); 
1370
+           lcdprintPGM(" No Card"); 
1344 1371
           }
1345 1372
         }
1346 1373
         #ifdef CARDINSERTED
@@ -1356,7 +1383,8 @@ void MainMenu::showMainMenu()
1356 1383
       }break;
1357 1384
       #endif
1358 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 1388
       break;
1361 1389
     }
1362 1390
   }

+ 4
- 3
Marlin/watchdog.pde 查看文件

@@ -41,10 +41,11 @@ ISR(WDT_vect)
41 41
   {
42 42
  
43 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 47
     #else
47
-      LCD_MESSAGE("Timeout, resetting!");
48
+      LCD_MESSAGEPGM("Timeout, resetting!");
48 49
     #endif 
49 50
     //disable watchdog, it will survife reboot.
50 51
     WDTCSR |= (1<<WDCE) | (1<<WDE);

正在加载...
取消
保存