Browse Source

project progmem finished: total change with ultipanel: 2456 byte free ram initial. now: 4374 ram.

Bernhard Kubicek 13 years ago
parent
commit
ab154d5592
10 changed files with 293 additions and 186 deletions
  1. 106
    106
      Marlin/EEPROMwrite.h
  2. 42
    7
      Marlin/Marlin.h
  3. 79
    45
      Marlin/Marlin.pde
  4. 2
    2
      Marlin/cardreader.h
  5. 26
    12
      Marlin/cardreader.pde
  6. 3
    1
      Marlin/stepper.cpp
  7. 15
    8
      Marlin/temperature.cpp
  8. 1
    0
      Marlin/ultralcd.h
  9. 15
    2
      Marlin/ultralcd.pde
  10. 4
    3
      Marlin/watchdog.pde

+ 106
- 106
Marlin/EEPROMwrite.h View File

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

+ 42
- 7
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
-
9
 #include "streaming.h"
8
 #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 << "Error: " << x;
13
-#define SERIAL_ERRORLN(x) Serial << "Error: " << x<<endl;
14
-#define SERIAL_PROTOCOL(x) Serial << x;
15
-#define SERIAL_PROTOCOLLN(x) Serial << x<<endl;
9
+#include <avr/pgmspace.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
+//things to write to serial from Programmemory. saves 400 to 2k of RAM.
40
+#define SerialprintPGM(x) serialprintPGM(PSTR(x))
41
+inline void serialprintPGM(const char *str)
42
+{
43
+  char ch=pgm_read_byte(str);
44
+  while(ch)
45
+  {
46
+    Serial.write(ch);
47
+    ch=pgm_read_byte(++str);
48
+  }
49
+}
50
+
16
 
51
 
17
 void get_command();
52
 void get_command();
18
 void process_commands();
53
 void process_commands();

+ 79
- 45
Marlin/Marlin.pde View File

101
 // M220 - set speed factor override percentage S:factor in percent
101
 // M220 - set speed factor override percentage S:factor in percent
102
 // M301 - Set PID parameters P I and D
102
 // M301 - Set PID parameters P I and D
103
 // M500 - stores paramters in EEPROM
103
 // M500 - stores paramters in EEPROM
104
-// 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).  
105
 // 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.
106
 
106
 
107
 //Stepper Movement Variables
107
 //Stepper Movement Variables
199
   {
199
   {
200
     //this is dangerous if a mixing of serial and this happsens
200
     //this is dangerous if a mixing of serial and this happsens
201
     strcpy(&(cmdbuffer[bufindw][0]),cmd);
201
     strcpy(&(cmdbuffer[bufindw][0]),cmd);
202
-    SERIAL_ECHOLN("enqueing \""<<cmdbuffer[bufindw]<<"\"");
202
+    SERIAL_ECHO_START;
203
+    SERIAL_ECHOPGM("enqueing \"");
204
+    SERIAL_ECHO(cmdbuffer[bufindw]);
205
+    SERIAL_ECHOLNPGM("\"");
203
     bufindw= (bufindw + 1)%BUFSIZE;
206
     bufindw= (bufindw + 1)%BUFSIZE;
204
     buflen += 1;
207
     buflen += 1;
205
   }
208
   }
208
 void setup()
211
 void setup()
209
 { 
212
 { 
210
   Serial.begin(BAUDRATE);
213
   Serial.begin(BAUDRATE);
211
-  SERIAL_ECHOLN("Marlin "<<version_string);
212
-  SERIAL_PROTOCOLLN("start");
213
-  Serial.print("echo: Free Memory:");
214
-  serial.println(freeMemory());
214
+  SERIAL_ECHO_START;
215
+  SERIAL_ECHOPGM("Marlin ");
216
+  SERIAL_ECHOLN(version_string);
217
+  SERIAL_PROTOCOLLNPGM("start");
218
+  SERIAL_ECHO_START;
219
+  SERIAL_ECHOPGM("Free Memory:");
220
+  SERIAL_ECHOLN(freeMemory());
215
   for(int8_t i = 0; i < BUFSIZE; i++)
221
   for(int8_t i = 0; i < BUFSIZE; i++)
216
   {
222
   {
217
     fromsd[i] = false;
223
     fromsd[i] = false;
244
 	if(strstr(cmdbuffer[bufindr],"M29") == NULL)
250
 	if(strstr(cmdbuffer[bufindr],"M29") == NULL)
245
 	{
251
 	{
246
 	  card.write_command(cmdbuffer[bufindr]);
252
 	  card.write_command(cmdbuffer[bufindr]);
247
-	  SERIAL_PROTOCOLLN("ok");
253
+	  SERIAL_PROTOCOLLNPGM("ok");
248
 	}
254
 	}
249
 	else
255
 	else
250
 	{
256
 	{
251
 	  card.closefile();
257
 	  card.closefile();
252
-	  SERIAL_PROTOCOLLN("Done saving file.");
258
+	  SERIAL_PROTOCOLLNPGM("Done saving file.");
253
 	}
259
 	}
254
       }
260
       }
255
       else
261
       else
284
           strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
290
           strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
285
           gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10));
291
           gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10));
286
           if(gcode_N != gcode_LastN+1 && (strstr(cmdbuffer[bufindw], "M110") == NULL) ) {
292
           if(gcode_N != gcode_LastN+1 && (strstr(cmdbuffer[bufindw], "M110") == NULL) ) {
287
-            SERIAL_ERRORLN("Line Number is not Last Line Number+1, Last Line:"<<gcode_LastN);
293
+            SERIAL_ERROR_START;
294
+            SERIAL_ERRORPGM("Line Number is not Last Line Number+1, Last Line:");
295
+            SERIAL_ERRORLN(gcode_LastN);
288
             //Serial.println(gcode_N);
296
             //Serial.println(gcode_N);
289
             FlushSerialRequestResend();
297
             FlushSerialRequestResend();
290
             serial_count = 0;
298
             serial_count = 0;
299
             strchr_pointer = strchr(cmdbuffer[bufindw], '*');
307
             strchr_pointer = strchr(cmdbuffer[bufindw], '*');
300
 
308
 
301
             if( (int)(strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)) != checksum) {
309
             if( (int)(strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)) != checksum) {
302
-              SERIAL_ERRORLN("checksum mismatch, Last Line:"<<gcode_LastN);
310
+              SERIAL_ERROR_START;
311
+              SERIAL_ERRORPGM("checksum mismatch, Last Line:");
312
+              SERIAL_ERRORLN(gcode_LastN);
303
               FlushSerialRequestResend();
313
               FlushSerialRequestResend();
304
               serial_count = 0;
314
               serial_count = 0;
305
               return;
315
               return;
308
           }
318
           }
309
           else 
319
           else 
310
           {
320
           {
311
-            SERIAL_ERRORLN("No Checksum with line number, Last Line:"<<gcode_LastN);
321
+            SERIAL_ERROR_START;
322
+            SERIAL_ERRORPGM("No Checksum with line number, Last Line:");
323
+            SERIAL_ERRORLN(gcode_LastN);
312
             FlushSerialRequestResend();
324
             FlushSerialRequestResend();
313
             serial_count = 0;
325
             serial_count = 0;
314
             return;
326
             return;
321
         {
333
         {
322
           if((strstr(cmdbuffer[bufindw], "*") != NULL))
334
           if((strstr(cmdbuffer[bufindw], "*") != NULL))
323
           {
335
           {
324
-            SERIAL_ERRORLN("No Line Number with checksum, Last Line:"<<gcode_LastN);
336
+            SERIAL_ERROR_START;
337
+            SERIAL_ERRORPGM("No Line Number with checksum, Last Line:");
338
+            SERIAL_ERRORLN(gcode_LastN);
325
             serial_count = 0;
339
             serial_count = 0;
326
             return;
340
             return;
327
           }
341
           }
337
             if(card.saving)
351
             if(card.saving)
338
               break;
352
               break;
339
 	    #endif //SDSUPPORT
353
 	    #endif //SDSUPPORT
340
-            SERIAL_PROTOCOLLN("ok"); 
354
+            SERIAL_PROTOCOLLNPGM("ok"); 
341
             break;
355
             break;
342
           default:
356
           default:
343
             break;
357
             break;
362
     return;
376
     return;
363
   }
377
   }
364
   while( !card.eof()  && buflen < BUFSIZE) {
378
   while( !card.eof()  && buflen < BUFSIZE) {
365
-    
366
-    serial_char = card.get();
367
-    if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1)) 
379
+    int16_t n=card.get();
380
+    serial_char = (char)n;
381
+    if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1)||n==-1) 
368
     {
382
     {
369
      
383
      
370
       if(card.eof()){
384
       if(card.eof()){
371
         card.sdprinting = false;
385
         card.sdprinting = false;
372
-        SERIAL_PROTOCOL("Done printing file");
386
+        SERIAL_PROTOCOLLNPGM("Done printing file");
373
         stoptime=millis();
387
         stoptime=millis();
374
         char time[30];
388
         char time[30];
375
         unsigned long t=(stoptime-starttime)/1000;
389
         unsigned long t=(stoptime-starttime)/1000;
377
         min=t/60;
391
         min=t/60;
378
         sec=t%60;
392
         sec=t%60;
379
         sprintf(time,"%i min, %i sec",min,sec);
393
         sprintf(time,"%i min, %i sec",min,sec);
394
+        SERIAL_ECHO_START;
380
         SERIAL_ECHOLN(time);
395
         SERIAL_ECHOLN(time);
381
         LCD_MESSAGE(time);
396
         LCD_MESSAGE(time);
382
         card.checkautostart(true);
397
         card.checkautostart(true);
398
       if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
413
       if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
399
     }
414
     }
400
   }
415
   }
416
+  
401
   #endif //SDSUPPORT
417
   #endif //SDSUPPORT
402
 
418
 
403
 }
419
 }
473
       previous_millis_cmd = millis();
489
       previous_millis_cmd = millis();
474
       return;
490
       return;
475
     case 4: // G4 dwell
491
     case 4: // G4 dwell
492
+      LCD_MESSAGEPGM("DWELL...");
476
       codenum = 0;
493
       codenum = 0;
477
       if(code_seen('P')) codenum = code_value(); // milliseconds to wait
494
       if(code_seen('P')) codenum = code_value(); // milliseconds to wait
478
       if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
495
       if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
533
     #ifdef SDSUPPORT
550
     #ifdef SDSUPPORT
534
 
551
 
535
     case 20: // M20 - list SD card
552
     case 20: // M20 - list SD card
536
-      SERIAL_PROTOCOLLN("Begin file list");
553
+      SERIAL_PROTOCOLLNPGM("Begin file list");
537
       card.ls();
554
       card.ls();
538
-      SERIAL_PROTOCOLLN("End file list");
555
+      SERIAL_PROTOCOLLNPGM("End file list");
539
       break;
556
       break;
540
     case 21: // M21 - init SD card
557
     case 21: // M21 - init SD card
541
       
558
       
542
       card.initsd();
559
       card.initsd();
560
+      
543
       break;
561
       break;
544
     case 22: //M22 - release SD card
562
     case 22: //M22 - release SD card
545
       card.release();
563
       card.release();
592
       min=t/60;
610
       min=t/60;
593
       sec=t%60;
611
       sec=t%60;
594
       sprintf(time,"%i min, %i sec",min,sec);
612
       sprintf(time,"%i min, %i sec",min,sec);
595
-      SERIAL_ERRORLN(time);
613
+      SERIAL_ECHO_START;
614
+      SERIAL_ECHOLN(time);
596
       LCD_MESSAGE(time);
615
       LCD_MESSAGE(time);
597
     }
616
     }
598
     break;
617
     break;
637
           bt = degBed();
656
           bt = degBed();
638
       #endif
657
       #endif
639
       #if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
658
       #if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
640
-        SERIAL_PROTOCOL("ok T:");
659
+        SERIAL_PROTOCOLPGM("ok T:");
641
         SERIAL_PROTOCOL(tt); 
660
         SERIAL_PROTOCOL(tt); 
642
         #if TEMP_1_PIN > -1 
661
         #if TEMP_1_PIN > -1 
643
           #ifdef PIDTEMP
662
           #ifdef PIDTEMP
654
             SERIAL_PROTOCOLLN("");
673
             SERIAL_PROTOCOLLN("");
655
           #endif //TEMP_1_PIN
674
           #endif //TEMP_1_PIN
656
         #else
675
         #else
657
-          SERIAL_ERRORLN("No thermistors - no temp");
676
+          SERIAL_ERROR_START;
677
+          SERIAL_ERRORLNPGM("No thermistors - no temp");
658
       #endif
678
       #endif
659
       return;
679
       return;
660
       break;
680
       break;
661
     case 109: 
681
     case 109: 
662
     {// M109 - Wait for extruder heater to reach target.
682
     {// M109 - Wait for extruder heater to reach target.
663
-        LCD_MESSAGE("Heating...");
683
+        LCD_MESSAGEPGM("Heating...");
664
         if (code_seen('S')) setTargetHotend0(code_value());
684
         if (code_seen('S')) setTargetHotend0(code_value());
665
         
685
         
666
         setWatch();
686
         setWatch();
681
         #endif //TEMP_RESIDENCY_TIME
701
         #endif //TEMP_RESIDENCY_TIME
682
         if( (millis() - codenum) > 1000 ) 
702
         if( (millis() - codenum) > 1000 ) 
683
         { //Print Temp Reading every 1 second while heating up/cooling down
703
         { //Print Temp Reading every 1 second while heating up/cooling down
684
-          SERIAL_PROTOCOLLN("T:"<< degHotend0() ); 
704
+          SERIAL_PROTOCOLPGM("T:");
705
+          SERIAL_PROTOCOLLN( degHotend0() ); 
685
           codenum = millis();
706
           codenum = millis();
686
         }
707
         }
687
         manage_heater();
708
         manage_heater();
697
           }
718
           }
698
         #endif //TEMP_RESIDENCY_TIME
719
         #endif //TEMP_RESIDENCY_TIME
699
         }
720
         }
700
-        LCD_MESSAGE("Heating done.");
721
+        LCD_MESSAGEPGM("Heating done.");
701
         starttime=millis();
722
         starttime=millis();
702
       }
723
       }
703
       break;
724
       break;
704
     case 190: // M190 - Wait bed for heater to reach target.
725
     case 190: // M190 - Wait bed for heater to reach target.
705
     #if TEMP_1_PIN > -1
726
     #if TEMP_1_PIN > -1
727
+        LCD_MESSAGEPGM("Bed Heating.");
706
         if (code_seen('S')) setTargetBed(code_value());
728
         if (code_seen('S')) setTargetBed(code_value());
707
         codenum = millis(); 
729
         codenum = millis(); 
708
         while(isHeatingBed()) 
730
         while(isHeatingBed()) 
710
           if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
732
           if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
711
           {
733
           {
712
             float tt=degHotend0();
734
             float tt=degHotend0();
713
-            SERIAL_PROTOCOLLN("T:"<<tt );
714
-            SERIAL_PROTOCOLLN("ok T:"<<tt <<" B:"<<degBed() ); 
735
+            SERIAL_PROTOCOLPGM("T:");
736
+            SERIAL_PROTOCOLLN(tt );
737
+            SERIAL_PROTOCOLPGM("ok T:");
738
+            SERIAL_PROTOCOL(tt );
739
+            SERIAL_PROTOCOLPGM(" B:");
740
+            SERIAL_PROTOCOLLN(degBed() ); 
715
             codenum = millis(); 
741
             codenum = millis(); 
716
           }
742
           }
717
           manage_heater();
743
           manage_heater();
718
         }
744
         }
745
+        LCD_MESSAGEPGM("Bed done.");
719
     #endif
746
     #endif
720
     break;
747
     break;
721
 
748
 
759
       }
786
       }
760
       else
787
       else
761
       { 
788
       { 
789
+        LCD_MESSAGEPGM("Free move.");
762
         st_synchronize(); 
790
         st_synchronize(); 
763
         disable_x(); 
791
         disable_x(); 
764
         disable_y(); 
792
         disable_y(); 
778
       }
806
       }
779
       break;
807
       break;
780
     case 115: // M115
808
     case 115: // M115
781
-      SERIAL_PROTOCOLLN("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");
809
+      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");
782
       break;
810
       break;
783
     case 114: // M114
811
     case 114: // M114
784
-      SERIAL_PROTOCOL("X:");
812
+      SERIAL_PROTOCOLPGM("X:");
785
       SERIAL_PROTOCOL(current_position[X_AXIS]);
813
       SERIAL_PROTOCOL(current_position[X_AXIS]);
786
-      SERIAL_PROTOCOL("Y:");
814
+      SERIAL_PROTOCOLPGM("Y:");
787
       SERIAL_PROTOCOL(current_position[Y_AXIS]);
815
       SERIAL_PROTOCOL(current_position[Y_AXIS]);
788
-      SERIAL_PROTOCOL("Z:");
816
+      SERIAL_PROTOCOLPGM("Z:");
789
       SERIAL_PROTOCOL(current_position[Z_AXIS]);
817
       SERIAL_PROTOCOL(current_position[Z_AXIS]);
790
-      SERIAL_PROTOCOL("E:");      
818
+      SERIAL_PROTOCOLPGM("E:");      
791
       SERIAL_PROTOCOL(current_position[E_AXIS]);
819
       SERIAL_PROTOCOL(current_position[E_AXIS]);
792
       #ifdef DEBUG_STEPS
820
       #ifdef DEBUG_STEPS
793
-        SERIAL_PROTOCOL(" Count X:");
821
+        SERIAL_PROTOCOLPGM(" Count X:");
794
         SERIAL_PROTOCOL(float(count_position[X_AXIS])/axis_steps_per_unit[X_AXIS]);
822
         SERIAL_PROTOCOL(float(count_position[X_AXIS])/axis_steps_per_unit[X_AXIS]);
795
-        SERIAL_PROTOCOL("Y:");
823
+        SERIAL_PROTOCOLPGM("Y:");
796
         SERIAL_PROTOCOL(float(count_position[Y_AXIS])/axis_steps_per_unit[Y_AXIS]);
824
         SERIAL_PROTOCOL(float(count_position[Y_AXIS])/axis_steps_per_unit[Y_AXIS]);
797
-        SERIAL_PROTOCOL("Z:");
825
+        SERIAL_PROTOCOLPGM("Z:");
798
         SERIAL_PROTOCOL(float(count_position[Z_AXIS])/axis_steps_per_unit[Z_AXIS]);
826
         SERIAL_PROTOCOL(float(count_position[Z_AXIS])/axis_steps_per_unit[Z_AXIS]);
799
       #endif
827
       #endif
800
       SERIAL_PROTOCOLLN("");
828
       SERIAL_PROTOCOLLN("");
801
       break;
829
       break;
802
     case 119: // M119
830
     case 119: // M119
803
       #if (X_MIN_PIN > -1)
831
       #if (X_MIN_PIN > -1)
804
-        SERIAL_PROTOCOL("x_min:");
832
+        SERIAL_PROTOCOLPGM("x_min:");
805
         SERIAL_PROTOCOL(((READ(X_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
833
         SERIAL_PROTOCOL(((READ(X_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
806
       #endif
834
       #endif
807
       #if (X_MAX_PIN > -1)
835
       #if (X_MAX_PIN > -1)
808
-        SERIAL_PROTOCOL("x_max:");
836
+        SERIAL_PROTOCOLPGM("x_max:");
809
         SERIAL_PROTOCOL(((READ(X_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
837
         SERIAL_PROTOCOL(((READ(X_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
810
       #endif
838
       #endif
811
       #if (Y_MIN_PIN > -1)
839
       #if (Y_MIN_PIN > -1)
812
-        SERIAL_PROTOCOL("y_min:");
840
+        SERIAL_PROTOCOLPGM("y_min:");
813
         SERIAL_PROTOCOL(((READ(Y_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
841
         SERIAL_PROTOCOL(((READ(Y_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
814
       #endif
842
       #endif
815
       #if (Y_MAX_PIN > -1)
843
       #if (Y_MAX_PIN > -1)
816
-        SERIAL_PROTOCOL("y_max:");
844
+        SERIAL_PROTOCOLPGM("y_max:");
817
         SERIAL_PROTOCOL(((READ(Y_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
845
         SERIAL_PROTOCOL(((READ(Y_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
818
       #endif
846
       #endif
819
       #if (Z_MIN_PIN > -1)
847
       #if (Z_MIN_PIN > -1)
820
-        SERIAL_PROTOCOL("z_min:");
848
+        SERIAL_PROTOCOLPGM("z_min:");
821
         SERIAL_PROTOCOL(((READ(Z_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
849
         SERIAL_PROTOCOL(((READ(Z_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
822
       #endif
850
       #endif
823
       #if (Z_MAX_PIN > -1)
851
       #if (Z_MAX_PIN > -1)
824
-        SERIAL_PROTOCOL("z_max:");
852
+        SERIAL_PROTOCOLPGM("z_max:");
825
         SERIAL_PROTOCOL(((READ(Z_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
853
         SERIAL_PROTOCOL(((READ(Z_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
826
       #endif
854
       #endif
827
       SERIAL_PROTOCOLLN("");
855
       SERIAL_PROTOCOLLN("");
897
   }
925
   }
898
   else
926
   else
899
   {
927
   {
900
-    SERIAL_ECHOLN("Unknown command:\""<<cmdbuffer[bufindr]<<"\"");
928
+    SERIAL_ECHO_START;
929
+    SERIAL_ECHOPGM("Unknown command:\"");
930
+    SERIAL_ECHO(cmdbuffer[bufindr]);
931
+    SERIAL_ECHOLNPGM("\"");
901
   }
932
   }
902
 
933
 
903
   ClearToSend();
934
   ClearToSend();
907
 {
938
 {
908
   //char cmdbuffer[bufindr][100]="Resend:";
939
   //char cmdbuffer[bufindr][100]="Resend:";
909
   Serial.flush();
940
   Serial.flush();
910
-  SERIAL_PROTOCOLLN("Resend:"<<gcode_LastN + 1);
941
+  SERIAL_PROTOCOLPGM("Resend:");
942
+  SERIAL_PROTOCOLLN(gcode_LastN + 1);
911
   ClearToSend();
943
   ClearToSend();
912
 }
944
 }
913
 
945
 
918
   if(fromsd[bufindr])
950
   if(fromsd[bufindr])
919
     return;
951
     return;
920
   #endif //SDSUPPORT
952
   #endif //SDSUPPORT
921
-  SERIAL_PROTOCOLLN("ok"); 
953
+  SERIAL_PROTOCOLLNPGM("ok"); 
922
 }
954
 }
923
 
955
 
924
 inline void get_coordinates()
956
 inline void get_coordinates()
992
   disable_e();
1024
   disable_e();
993
   
1025
   
994
   if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT);
1026
   if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT);
995
-  SERIAL_ERRORLN("Printer halted. kill() called !!");
1027
+  SERIAL_ERROR_START;
1028
+  SERIAL_ERRORLNPGM("Printer halted. kill() called !!");
1029
+  LCD_MESSAGEPGM("KILLED. ");
996
   while(1); // Wait for reset
1030
   while(1); // Wait for reset
997
 }
1031
 }
998
 
1032
 

+ 2
- 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)?'\n':(char)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:

+ 26
- 12
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
 }
77
    
81
    
78
     if (file.open(&root, name, O_READ)) {
82
     if (file.open(&root, name, O_READ)) {
79
       filesize = file.fileSize();
83
       filesize = file.fileSize();
80
-      SERIAL_PROTOCOLLN("File opened:"<<name<<" Size:"<<filesize);
84
+      SERIAL_PROTOCOLPGM("File opened:");
85
+      SERIAL_PROTOCOL(name);
86
+      SERIAL_PROTOCOLPGM(" Size:");
87
+      SERIAL_PROTOCOLLN(filesize);
81
       sdpos = 0;
88
       sdpos = 0;
82
       
89
       
83
-      SERIAL_PROTOCOLLN("File selected");
90
+      SERIAL_PROTOCOLLNPGM("File selected");
84
     }
91
     }
85
     else{
92
     else{
86
-      SERIAL_PROTOCOLLN("file.open failed");
93
+      SERIAL_PROTOCOLLNPGM("file.open failed");
87
     }
94
     }
88
   }
95
   }
89
 }
96
 }
98
     
105
     
99
     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))
100
     {
107
     {
101
-      SERIAL_PROTOCOLLN("open failed, File: "<<name<<".");
108
+      SERIAL_PROTOCOLPGM("open failed, File: ");
109
+      SERIAL_PROTOCOL(name);
110
+      SERIAL_PROTOCOLLNPGM(".");
102
     }
111
     }
103
     else{
112
     else{
104
       saving = true;
113
       saving = true;
105
-      SERIAL_PROTOCOLLN("Writing to file: "<<name);
114
+      SERIAL_PROTOCOLPGM("Writing to file: ");
115
+      SERIAL_PROTOCOLLN(name);
106
     }
116
     }
107
   }
117
   }
108
 }
118
 }
110
 void CardReader::getStatus()
120
 void CardReader::getStatus()
111
 {
121
 {
112
   if(cardOK){
122
   if(cardOK){
113
-    SERIAL_PROTOCOLLN("SD printing byte "<<sdpos<<"/"<<filesize);
123
+    SERIAL_PROTOCOLPGM("SD printing byte ");
124
+    SERIAL_PROTOCOL(sdpos);
125
+    SERIAL_PROTOCOLPGM("/");
126
+    SERIAL_PROTOCOLLN(filesize);
114
   }
127
   }
115
   else{
128
   else{
116
-    SERIAL_PROTOCOLLN("Not SD printing");
129
+    SERIAL_PROTOCOLLNPGM("Not SD printing");
117
   }
130
   }
118
 }
131
 }
119
 void CardReader::write_command(char *buf)
132
 void CardReader::write_command(char *buf)
134
   file.write(begin);
147
   file.write(begin);
135
   if (file.writeError)
148
   if (file.writeError)
136
   {
149
   {
137
-    SERIAL_ERRORLN("error writing to file");
150
+    SERIAL_ERROR_START;
151
+    SERIAL_ERRORLNPGM("error writing to file");
138
   }
152
   }
139
 }
153
 }
140
 
154
 

+ 3
- 1
Marlin/stepper.cpp View File

232
 ISR(TIMER1_COMPA_vect)
232
 ISR(TIMER1_COMPA_vect)
233
 {        
233
 {        
234
   if(busy){ 
234
   if(busy){ 
235
-    SERIAL_ERRORLN(*(unsigned short *)OCR1A<< " ISR overtaking itself.");
235
+    SERIAL_ERROR_START
236
+    SERIAL_ERROR(*(unsigned short *)OCR1A);
237
+    SERIAL_ERRORLNPGM(" ISR overtaking itself.");
236
     return; 
238
     return; 
237
   } // The busy-flag is used to avoid reentering this interrupt
239
   } // The busy-flag is used to avoid reentering this interrupt
238
 
240
 

+ 15
- 8
Marlin/temperature.cpp View File

160
         }
160
         }
161
     #endif //PID_OPENLOOP
161
     #endif //PID_OPENLOOP
162
     #ifdef PID_DEBUG
162
     #ifdef PID_DEBUG
163
-     SERIAL_ECHOLN(" PIDDEBUG Input "<<pid_input<<" Output "<<pid_output" pTerm "<<pTerm<<" iTerm "<<iTerm<<" dTerm "<<dTerm);  
163
+     //SERIAL_ECHOLN(" PIDDEBUG Input "<<pid_input<<" Output "<<pid_output" pTerm "<<pTerm<<" iTerm "<<iTerm<<" dTerm "<<dTerm);  
164
     #endif //PID_DEBUG
164
     #endif //PID_DEBUG
165
     analogWrite(HEATER_0_PIN, pid_output);
165
     analogWrite(HEATER_0_PIN, pid_output);
166
   #endif //PIDTEMP
166
   #endif //PIDTEMP
462
       temp_count++;
462
       temp_count++;
463
       break;
463
       break;
464
     default:
464
     default:
465
-      SERIAL_ERRORLN("Temp measurement error!");
465
+      SERIAL_ERROR_START;
466
+      SERIAL_ERRORLNPGM("Temp measurement error!");
466
       break;
467
       break;
467
   }
468
   }
468
     
469
     
496
         if(current_raw[TEMPSENSOR_HOTEND_0] >= maxttemp_0) {
497
         if(current_raw[TEMPSENSOR_HOTEND_0] >= maxttemp_0) {
497
           target_raw[TEMPSENSOR_HOTEND_0] = 0;
498
           target_raw[TEMPSENSOR_HOTEND_0] = 0;
498
           analogWrite(HEATER_0_PIN, 0);
499
           analogWrite(HEATER_0_PIN, 0);
499
-          SERIAL_ERRORLN("Temperature extruder 0 switched off. MAXTEMP triggered !!");
500
+          SERIAL_ERROR_START;
501
+          SERIAL_ERRORLNPGM("Temperature extruder 0 switched off. MAXTEMP triggered !!");
500
           kill();
502
           kill();
501
         }
503
         }
502
       #endif
504
       #endif
507
         target_raw[TEMPSENSOR_HOTEND_1] = 0;
509
         target_raw[TEMPSENSOR_HOTEND_1] = 0;
508
       if(current_raw[2] >= maxttemp_1) {
510
       if(current_raw[2] >= maxttemp_1) {
509
         analogWrite(HEATER_2_PIN, 0);
511
         analogWrite(HEATER_2_PIN, 0);
510
-        SERIAL_ERRORLN("Temperature extruder 1 switched off. MAXTEMP triggered !!");
512
+        SERIAL_ERROR_START;
513
+        SERIAL_ERRORLNPGM("Temperature extruder 1 switched off. MAXTEMP triggered !!");
511
         kill()
514
         kill()
512
       }
515
       }
513
     #endif
516
     #endif
518
       if(current_raw[TEMPSENSOR_HOTEND_0] <= minttemp_0) {
521
       if(current_raw[TEMPSENSOR_HOTEND_0] <= minttemp_0) {
519
         target_raw[TEMPSENSOR_HOTEND_0] = 0;
522
         target_raw[TEMPSENSOR_HOTEND_0] = 0;
520
         analogWrite(HEATER_0_PIN, 0);
523
         analogWrite(HEATER_0_PIN, 0);
521
-        SERIAL_ERRORLN("Temperature extruder 0 switched off. MINTEMP triggered !!");
524
+        SERIAL_ERROR_START;
525
+        SERIAL_ERRORLNPGM("Temperature extruder 0 switched off. MINTEMP triggered !!");
522
         kill();
526
         kill();
523
       }
527
       }
524
     #endif
528
     #endif
529
       if(current_raw[TEMPSENSOR_HOTEND_1] <= minttemp_1) {
533
       if(current_raw[TEMPSENSOR_HOTEND_1] <= minttemp_1) {
530
         target_raw[TEMPSENSOR_HOTEND_1] = 0;
534
         target_raw[TEMPSENSOR_HOTEND_1] = 0;
531
         analogWrite(HEATER_2_PIN, 0);
535
         analogWrite(HEATER_2_PIN, 0);
532
-        SERIAL_ERRORLN("Temperature extruder 1 switched off. MINTEMP triggered !!");
536
+        SERIAL_ERROR_START;
537
+        SERIAL_ERRORLNPGM("Temperature extruder 1 switched off. MINTEMP triggered !!");
533
         kill();
538
         kill();
534
       }
539
       }
535
     #endif
540
     #endif
540
       if(current_raw[1] <= bed_minttemp) {
545
       if(current_raw[1] <= bed_minttemp) {
541
         target_raw[1] = 0;
546
         target_raw[1] = 0;
542
         WRITE(HEATER_1_PIN, 0);
547
         WRITE(HEATER_1_PIN, 0);
543
-        SERIAL_ERRORLN("Temperatur heated bed switched off. MINTEMP triggered !!");
548
+        SERIAL_ERROR_START;
549
+        SERIAL_ERRORLNPGM("Temperatur heated bed switched off. MINTEMP triggered !!");
544
         kill();
550
         kill();
545
       }
551
       }
546
     #endif
552
     #endif
551
       if(current_raw[1] >= bed_maxttemp) {
557
       if(current_raw[1] >= bed_maxttemp) {
552
         target_raw[1] = 0;
558
         target_raw[1] = 0;
553
         WRITE(HEATER_1_PIN, 0);
559
         WRITE(HEATER_1_PIN, 0);
554
-        SERIAL_ERRORLN("Temperature heated bed switched off. MAXTEMP triggered !!");
560
+        SERIAL_ERROR_START;
561
+        SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !!");
555
         kill();
562
         kill();
556
       }
563
       }
557
     #endif
564
     #endif

+ 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

+ 15
- 2
Marlin/ultralcd.pde View File

67
   strncpy(messagetext,message,LCD_WIDTH);
67
   strncpy(messagetext,message,LCD_WIDTH);
68
 }
68
 }
69
 
69
 
70
+void lcd_statuspgm(const char* message)
71
+{
72
+  char ch=pgm_read_byte(message);
73
+  char *target=messagetext;
74
+  while(ch)
75
+  {
76
+    *target=ch;
77
+    target++;
78
+    ch=pgm_read_byte(++message);
79
+  }
80
+}
81
+
70
 inline void clear()
82
 inline void clear()
71
 {
83
 {
72
   lcd.clear();
84
   lcd.clear();
105
   lcd.createChar(2,Thermometer);
117
   lcd.createChar(2,Thermometer);
106
   lcd.createChar(3,uplevel);
118
   lcd.createChar(3,uplevel);
107
   lcd.createChar(4,refresh);
119
   lcd.createChar(4,refresh);
108
-  LCD_MESSAGE(fillto(LCD_WIDTH,"UltiMarlin ready."));
120
+  LCD_MESSAGEPGM("UltiMarlin ready.");
109
 }
121
 }
110
 
122
 
111
 
123
 
1369
       }break;
1381
       }break;
1370
       #endif
1382
       #endif
1371
       default: 
1383
       default: 
1372
-        SERIAL_ERRORLN("Something is wrong in the MenuStructure.");
1384
+        SERIAL_ERROR_START;
1385
+        SERIAL_ERRORLNPGM("Something is wrong in the MenuStructure.");
1373
       break;
1386
       break;
1374
     }
1387
     }
1375
   }
1388
   }

+ 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