Browse Source

watchdog,percent done,

Bernhard Kubicek 13 years ago
parent
commit
7919a40d06
7 changed files with 55 additions and 33 deletions
  1. 6
    5
      Marlin/Configuration.h
  2. 1
    1
      Marlin/Marlin.h
  3. 34
    26
      Marlin/Marlin.pde
  4. 1
    0
      Marlin/cardreader.h
  5. 1
    1
      Marlin/ultralcd.h
  6. 10
    0
      Marlin/ultralcd.pde
  7. 2
    0
      Marlin/watchdog.pde

+ 6
- 5
Marlin/Configuration.h View File

220
 
220
 
221
 // The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
221
 // The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
222
 // this enables the watchdog interrupt.
222
 // this enables the watchdog interrupt.
223
-#define USE_WATCHDOG
224
-// you cannot reboot on a mega2560 due to a bug in he bootloader. Hence, you have to reset manually, and this is done hereby:
225
-#define RESET_MANUAL
226
-#define WATCHDOG_TIMEOUT 4  //seconds
227
-
223
+//#define USE_WATCHDOG
224
+#ifdef USE_WATCHDOG
225
+  // you cannot reboot on a mega2560 due to a bug in he bootloader. Hence, you have to reset manually, and this is done hereby:
226
+  #define RESET_MANUAL
227
+  #define WATCHDOG_TIMEOUT 4  //seconds
228
+#endif
228
 
229
 
229
 
230
 
230
 
231
 

+ 1
- 1
Marlin/Marlin.h View File

100
 void kill();
100
 void kill();
101
 
101
 
102
 void enquecommand(const char *cmd); //put an ascii command at the end of the current buffer.
102
 void enquecommand(const char *cmd); //put an ascii command at the end of the current buffer.
103
-
103
+void prepare_arc_move(char isclockwise);
104
 
104
 
105
 #ifndef CRITICAL_SECTION_START
105
 #ifndef CRITICAL_SECTION_START
106
   #define CRITICAL_SECTION_START  unsigned char _sreg = SREG; cli();
106
   #define CRITICAL_SECTION_START  unsigned char _sreg = SREG; cli();

+ 34
- 26
Marlin/Marlin.pde View File

37
 #include "temperature.h"
37
 #include "temperature.h"
38
 #include "motion_control.h"
38
 #include "motion_control.h"
39
 #include "cardreader.h"
39
 #include "cardreader.h"
40
+#include "watchdog.h"
40
 
41
 
41
 
42
 
42
 #define VERSION_STRING  "1.0.0 Alpha 1"
43
 #define VERSION_STRING  "1.0.0 Alpha 1"
191
 }
192
 }
192
 
193
 
193
 
194
 
195
+
196
+inline void get_coordinates()
197
+{
198
+  for(int8_t i=0; i < NUM_AXIS; i++) {
199
+    if(code_seen(axis_codes[i])) destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i];
200
+    else destination[i] = current_position[i]; //Are these else lines really needed?
201
+  }
202
+  if(code_seen('F')) {
203
+    next_feedrate = code_value();
204
+    if(next_feedrate > 0.0) feedrate = next_feedrate;
205
+  }
206
+}
207
+
208
+inline void get_arc_coordinates()
209
+{
210
+   get_coordinates();
211
+   if(code_seen('I')) offset[0] = code_value();
212
+   if(code_seen('J')) offset[1] = code_value();
213
+}
214
+
215
+void prepare_move()
216
+{
217
+  plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60.0/100.0);
218
+  for(int8_t i=0; i < NUM_AXIS; i++) {
219
+    current_position[i] = destination[i];
220
+  }
221
+}
222
+
223
+
224
+
194
 //adds an command to the main command buffer
225
 //adds an command to the main command buffer
195
 //thats really done in a non-safe way.
226
 //thats really done in a non-safe way.
196
 //needs overworking someday
227
 //needs overworking someday
234
   plan_init();  // Initialize planner;
265
   plan_init();  // Initialize planner;
235
   st_init();    // Initialize stepper;
266
   st_init();    // Initialize stepper;
236
   tp_init();    // Initialize temperature loop
267
   tp_init();    // Initialize temperature loop
268
+  wd_init();
237
 }
269
 }
238
 
270
 
239
 
271
 
656
       break;
688
       break;
657
     case 105: // M105
689
     case 105: // M105
658
       //SERIAL_ECHOLN(freeMemory());
690
       //SERIAL_ECHOLN(freeMemory());
659
-          
691
+       //test watchdog:
692
+       //delay(20000);
660
       #if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
693
       #if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
661
         SERIAL_PROTOCOLPGM("ok T:");
694
         SERIAL_PROTOCOLPGM("ok T:");
662
         SERIAL_PROTOCOL( degHotend0()); 
695
         SERIAL_PROTOCOL( degHotend0()); 
975
   SERIAL_PROTOCOLLNPGM("ok"); 
1008
   SERIAL_PROTOCOLLNPGM("ok"); 
976
 }
1009
 }
977
 
1010
 
978
-inline void get_coordinates()
979
-{
980
-  for(int8_t i=0; i < NUM_AXIS; i++) {
981
-    if(code_seen(axis_codes[i])) destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i];
982
-    else destination[i] = current_position[i]; //Are these else lines really needed?
983
-  }
984
-  if(code_seen('F')) {
985
-    next_feedrate = code_value();
986
-    if(next_feedrate > 0.0) feedrate = next_feedrate;
987
-  }
988
-}
989
-
990
-inline void get_arc_coordinates()
991
-{
992
-   get_coordinates();
993
-   if(code_seen('I')) offset[0] = code_value();
994
-   if(code_seen('J')) offset[1] = code_value();
995
-}
996
 
1011
 
997
-void prepare_move()
998
-{
999
-  plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60.0/100.0);
1000
-  for(int8_t i=0; i < NUM_AXIS; i++) {
1001
-    current_position[i] = destination[i];
1002
-  }
1003
-}
1004
 
1012
 
1005
 void prepare_arc_move(char isclockwise) {
1013
 void prepare_arc_move(char isclockwise) {
1006
   float r = hypot(offset[X_AXIS], offset[Y_AXIS]); // Compute arc radius for mc_arc
1014
   float r = hypot(offset[X_AXIS], offset[Y_AXIS]); // Compute arc radius for mc_arc

+ 1
- 0
Marlin/cardreader.h View File

33
   inline bool eof() { return sdpos>=filesize ;};
33
   inline bool eof() { return sdpos>=filesize ;};
34
   inline int16_t get() {  sdpos = file.curPosition();return (int16_t)file.read();};
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
+  inline uint8_t percentDone(){if(!sdprinting) return 0; if(filesize) return sdpos*100/filesize; else return 0;};
36
 
37
 
37
 public:
38
 public:
38
   bool saving;
39
   bool saving;

+ 1
- 1
Marlin/ultralcd.h View File

96
   #define BLOCK ;
96
   #define BLOCK ;
97
 #endif 
97
 #endif 
98
   
98
   
99
-  
99
+void lcd_statuspgm(const char* message);
100
   
100
   
101
 #endif //ULTRALCD
101
 #endif //ULTRALCD
102
 
102
 

+ 10
- 0
Marlin/ultralcd.pde View File

374
     lcd.print(fillto(LCD_WIDTH,messagetext));
374
     lcd.print(fillto(LCD_WIDTH,messagetext));
375
     messagetext[0]='\0';
375
     messagetext[0]='\0';
376
   }
376
   }
377
+  
378
+  static uint8_t oldpercent=101;
379
+  uint8_t percent=card.percentDone();
380
+  if(oldpercent!=percent)
381
+  {
382
+     lcd.setCursor(6,3);
383
+    lcd.print(oldpercent);
384
+    lcdprintPGM("done");
385
+  }
386
+  
377
 #else //smaller LCDS----------------------------------
387
 #else //smaller LCDS----------------------------------
378
   static int olddegHotEnd0=-1;
388
   static int olddegHotEnd0=-1;
379
   static int oldtargetHotEnd0=-1;
389
   static int oldtargetHotEnd0=-1;

+ 2
- 0
Marlin/watchdog.pde View File

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

Loading…
Cancel
Save