Selaa lähdekoodia

First cleanup. Moved all code to cpp files, so there are no dependencies on pde files. And no more odd requirement to cat files together. (Still need to fix the Makefile). Also cleaned up some defines and made defines upper case as by C coding conventions.

daid303 11 vuotta sitten
vanhempi
commit
06b58a9c4f

+ 8
- 9
Marlin/Configuration_adv.h Näytä tiedosto

@@ -181,15 +181,14 @@
181 181
 #define SD_FINISHED_STEPPERRELEASE true  //if sd support and the file is finished: disable steppers?
182 182
 #define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // no z because of layer shift.
183 183
 
184
-// The hardware watchdog should halt the Microcontroller, in case the firmware gets stuck somewhere. However:
185
-// the Watchdog is not working well, so please only enable this for testing
186
-// this enables the watchdog interrupt.
187
-//#define USE_WATCHDOG
188
-//#ifdef USE_WATCHDOG
189
-  // you cannot reboot on a mega2560 due to a bug in he bootloader. Hence, you have to reset manually, and this is done hereby:
184
+// The hardware watchdog should reset the Microcontroller disabling all outputs, in case the firmware gets stuck and doesn't do temperature regulation.
185
+#define USE_WATCHDOG
186
+
187
+#ifdef USE_WATCHDOG
188
+// you cannot watchdog reboot on Arduino mega2560 due to a bug in he bootloader. Hence we need to ask the user to reset.
189
+//  THIS FEATURE IS UNSAFE!, as it will only work if interrupts are disabled. And the code could hang in an interrupt routine with interrupts disabled.
190 190
 //#define RESET_MANUAL
191
-//#define WATCHDOG_TIMEOUT 4  //seconds
192
-//#endif
191
+#endif
193 192
 
194 193
 // extruder advance constant (s2/mm3)
195 194
 //
@@ -214,7 +213,7 @@
214 213
 #define MM_PER_ARC_SEGMENT 1
215 214
 #define N_ARC_CORRECTION 25
216 215
 
217
-const int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
216
+const unsigned int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
218 217
 
219 218
 // If you are using a RAMPS board or cheap E-bay purchased boards that do not detect when an SD card is inserted
220 219
 // You can get round this by connecting a push button or single throw switch to the pin defined as SDCARDCARDDETECT 

+ 0
- 8
Marlin/EEPROMwrite.h Näytä tiedosto

@@ -6,14 +6,6 @@
6 6
 #include "temperature.h"
7 7
 //#include <EEPROM.h>
8 8
 
9
-int plaPreheatHotendTemp;
10
-int plaPreheatHPBTemp;
11
-int plaPreheatFanSpeed;
12
-
13
-int absPreheatHotendTemp;
14
-int absPreheatHPBTemp;
15
-int absPreheatFanSpeed;
16
-
17 9
 template <class T> int EEPROM_writeAnything(int &ee, const T& value)
18 10
 {
19 11
   const byte* p = (const byte*)(const void*)&value;

+ 1
- 2
Marlin/LiquidCrystalRus.cpp Näytä tiedosto

@@ -1,4 +1,3 @@
1
-#define __PROG_TYPES_COMPAT__
2 1
 #include "LiquidCrystalRus.h"
3 2
 
4 3
 #include <stdio.h>
@@ -14,7 +13,7 @@
14 13
 
15 14
 // it is a russian alphabet translation
16 15
 // except 0401 --> 0xa2 = ╗, 0451 --> 0xb5
17
-const PROGMEM prog_uchar utf_recode[] = 
16
+const PROGMEM uint8_t utf_recode[] = 
18 17
        { 0x41,0xa0,0x42,0xa1,0xe0,0x45,0xa3,0xa4,0xa5,0xa6,0x4b,0xa7,0x4d,0x48,0x4f,
19 18
          0xa8,0x50,0x43,0x54,0xa9,0xaa,0x58,0xe1,0xab,0xac,0xe2,0xad,0xae,0x62,0xaf,0xb0,0xb1,
20 19
          0x61,0xb2,0xb3,0xb4,0xe3,0x65,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0x6f,

+ 7
- 16
Marlin/Marlin.h Näytä tiedosto

@@ -17,8 +17,8 @@
17 17
 #include <util/delay.h>
18 18
 #include <avr/pgmspace.h>
19 19
 #include <avr/eeprom.h>
20
-#include  <avr/wdt.h>
21
-#include  <avr/interrupt.h>
20
+#include <avr/wdt.h>
21
+#include <avr/interrupt.h>
22 22
 
23 23
 
24 24
 #include "fastio.h"
@@ -52,22 +52,11 @@
52 52
   #define MYSERIAL MSerial
53 53
 #endif
54 54
 
55
-//this is a unfinsihed attemp to removes a lot of warning messages, see:
56
-// http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=57011
57
-//typedef char prog_char PROGMEM; 
58
-// //#define PSTR    (s )        ((const PROGMEM char *)(s))
59
-// //# define MYPGM(s) (__extension__({static prog_char __c[] = (s); &__c[0];})) 
60
-// //#define MYPGM(s) ((const prog_char *g PROGMEM=s))
61
-#define MYPGM(s) PSTR(s)
62
-//#define MYPGM(s)  (__extension__({static char __c[] __attribute__((__progmem__)) = (s); &__c[0];}))  //This is the normal behaviour
63
-//#define MYPGM(s)  (__extension__({static prog_char __c[]  = (s); &__c[0];})) //this does not work but hides the warnings
64
-
65
-
66 55
 #define SERIAL_PROTOCOL(x) MYSERIAL.print(x);
67 56
 #define SERIAL_PROTOCOL_F(x,y) MYSERIAL.print(x,y);
68
-#define SERIAL_PROTOCOLPGM(x) serialprintPGM(MYPGM(x));
57
+#define SERIAL_PROTOCOLPGM(x) serialprintPGM(PSTR(x));
69 58
 #define SERIAL_PROTOCOLLN(x) {MYSERIAL.print(x);MYSERIAL.write('\n');}
70
-#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(MYPGM(x));MYSERIAL.write('\n');}
59
+#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(PSTR(x));MYSERIAL.write('\n');}
71 60
 
72 61
 
73 62
 const char errormagic[] PROGMEM ="Error:";
@@ -92,7 +81,6 @@ void serial_echopair_P(const char *s_P, unsigned long v);
92 81
 
93 82
 
94 83
 //things to write to serial from Programmemory. saves 400 to 2k of RAM.
95
-#define SerialprintPGM(x) serialprintPGM(MYPGM(x))
96 84
 FORCE_INLINE void serialprintPGM(const char *str)
97 85
 {
98 86
   char ch=pgm_read_byte(str);
@@ -197,6 +185,9 @@ extern float min_pos[3];
197 185
 extern float max_pos[3];
198 186
 extern unsigned char FanSpeed;
199 187
 
188
+extern unsigned long starttime;
189
+extern unsigned long stoptime;
190
+
200 191
 // Handling multiple extruders pins
201 192
 extern uint8_t active_extruder;
202 193
 

+ 5
- 1834
Marlin/Marlin.pde
File diff suppressed because it is too large
Näytä tiedosto


+ 1865
- 0
Marlin/Marlin_main.cpp
File diff suppressed because it is too large
Näytä tiedosto


+ 8
- 5
Marlin/SdFile.cpp Näytä tiedosto

@@ -55,13 +55,16 @@ int16_t SdFile::write(const void* buf, uint16_t nbyte) {
55 55
  * Use writeError to check for errors.
56 56
  */
57 57
 #if ARDUINO >= 100
58
-    size_t SdFile::write(uint8_t b)
58
+size_t SdFile::write(uint8_t b)
59
+{
60
+    return SdBaseFile::write(&b, 1);
61
+}
59 62
 #else
60
-  void SdFile::write(uint8_t b)
61
-#endif
63
+void SdFile::write(uint8_t b)
62 64
 {
63
-  SdBaseFile::write(&b, 1);
65
+    SdBaseFile::write(&b, 1);
64 66
 }
67
+#endif
65 68
 //------------------------------------------------------------------------------
66 69
 /** Write a string to a file. Used by the Arduino Print class.
67 70
  * \param[in] str Pointer to the string.
@@ -89,4 +92,4 @@ void SdFile::writeln_P(PGM_P str) {
89 92
 }
90 93
 
91 94
 
92
-#endif
95
+#endif

+ 1
- 2
Marlin/planner.cpp Näytä tiedosto

@@ -191,8 +191,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
191 191
   // have to use intersection_distance() to calculate when to abort acceleration and start braking
192 192
   // in order to reach the final_rate exactly at the end of this block.
193 193
   if (plateau_steps < 0) {
194
-    accelerate_steps = ceil(
195
-    intersection_distance(block->initial_rate, block->final_rate, acceleration, block->step_event_count));
194
+    accelerate_steps = ceil(intersection_distance(block->initial_rate, block->final_rate, acceleration, block->step_event_count));
196 195
     accelerate_steps = max(accelerate_steps,0); // Check limits due to numerical round-off
197 196
     accelerate_steps = min(accelerate_steps,block->step_event_count);
198 197
     plateau_steps = 0;

+ 7
- 11
Marlin/temperature.cpp Näytä tiedosto

@@ -145,20 +145,20 @@ static volatile bool temp_meas_ready = false;
145 145
 
146 146
 void PID_autotune(float temp, int extruder, int ncycles)
147 147
 {
148
-  float input;
148
+  float input = 0.0;
149 149
   int cycles=0;
150 150
   bool heating = true;
151 151
 
152 152
   unsigned long temp_millis = millis();
153 153
   unsigned long t1=temp_millis;
154 154
   unsigned long t2=temp_millis;
155
-  long t_high;
156
-  long t_low;
155
+  long t_high = 0;
156
+  long t_low = 0;
157 157
 
158 158
   long bias, d;
159 159
   float Ku, Tu;
160 160
   float Kp, Ki, Kd;
161
-  float max, min;
161
+  float max = 0, min = 10000;
162 162
 
163 163
 	if ((extruder > EXTRUDERS)
164 164
   #if (TEMP_BED_PIN <= -1)
@@ -315,17 +315,15 @@ int getHeaterPower(int heater) {
315 315
 
316 316
 void manage_heater()
317 317
 {
318
-
319
-  #ifdef USE_WATCHDOG
320
-    wd_reset();
321
-  #endif
322
-  
323 318
   float pid_input;
324 319
   float pid_output;
325 320
 
326 321
   if(temp_meas_ready != true)   //better readability
327 322
     return; 
328 323
 
324
+  //Reset the watchdog after we know we have a temperature measurement.
325
+  watchdog_reset();
326
+
329 327
   CRITICAL_SECTION_START;
330 328
   temp_meas_ready = false;
331 329
   CRITICAL_SECTION_END;
@@ -548,7 +546,6 @@ int temp2analogBed(int celsius) {
548 546
 #elif defined BED_USES_AD595
549 547
     return lround(((celsius-TEMP_SENSOR_AD595_OFFSET)/TEMP_SENSOR_AD595_GAIN) * (1024.0 * OVERSAMPLENR/ (5.0 * 100.0) ) );
550 548
 #else
551
-    #warning No heater-type defined for the bed.
552 549
     return 0;
553 550
 #endif
554 551
 }
@@ -625,7 +622,6 @@ float analog2tempBed(int raw) {
625 622
   #elif defined BED_USES_AD595
626 623
     return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
627 624
   #else
628
-    #warning No heater-type defined for the bed.
629 625
     return 0;
630 626
   #endif
631 627
 }

Marlin/ultralcd.pde → Marlin/ultralcd.cpp Näytä tiedosto

@@ -6,11 +6,7 @@
6 6
 #include "language.h"
7 7
 #include "temperature.h"
8 8
 #include "EEPROMwrite.h"
9
-#if LANGUAGE_CHOICE == 6
10
-#include "LiquidCrystalRus.h"
11
-#else
12
-#include <LiquidCrystal.h>
13
-#endif
9
+
14 10
 //===========================================================================
15 11
 //=============================imported variables============================
16 12
 //===========================================================================
@@ -33,6 +29,14 @@ volatile char buttons=0;  //the last checked buttons in a bit array.
33 29
 long encoderpos=0;
34 30
 short lastenc=0;
35 31
 
32
+//TODO: This should be in a preferences file.
33
+int plaPreheatHotendTemp;
34
+int plaPreheatHPBTemp;
35
+int plaPreheatFanSpeed;
36
+
37
+int absPreheatHotendTemp;
38
+int absPreheatHPBTemp;
39
+int absPreheatFanSpeed;
36 40
 
37 41
 //===========================================================================
38 42
 //=============================private  variables============================
@@ -42,11 +46,7 @@ static char messagetext[LCD_WIDTH]="";
42 46
 //return for string conversion routines
43 47
 static char conv[8];
44 48
 
45
-#if LANGUAGE_CHOICE == 6
46
-LiquidCrystalRus lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7);  //RS,Enable,D4,D5,D6,D7
47
-#else
48
-LiquidCrystal lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7);  //RS,Enable,D4,D5,D6,D7 
49
-#endif
49
+LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7);  //RS,Enable,D4,D5,D6,D7
50 50
 
51 51
 static unsigned long previous_millis_lcd=0;
52 52
 //static long previous_millis_buttons=0;
@@ -70,7 +70,7 @@ void lcdProgMemprint(const char *str)
70 70
     ch=pgm_read_byte(++str);
71 71
   }
72 72
 }
73
-#define lcdprintPGM(x) lcdProgMemprint(MYPGM(x))
73
+#define LCD_PRINT_PGM(x) lcdProgMemprint(PSTR(x))
74 74
 
75 75
 
76 76
 //===========================================================================
@@ -366,11 +366,11 @@ void MainMenu::showStatus()
366 366
   {
367 367
     encoderpos=feedmultiply;
368 368
     clear();
369
-    lcd.setCursor(0,0);lcdprintPGM("\002000/000\001 ");
369
+    lcd.setCursor(0,0);LCD_PRINT_PGM("\002000/000\001 ");
370 370
     #if defined BED_USES_THERMISTOR || defined BED_USES_AD595 
371
-      lcd.setCursor(10,0);lcdprintPGM("B000/000\001 ");
371
+      lcd.setCursor(10,0);LCD_PRINT_PGM("B000/000\001 ");
372 372
     #elif EXTRUDERS > 1
373
-      lcd.setCursor(10,0);lcdprintPGM("\002000/000\001 ");
373
+      lcd.setCursor(10,0);LCD_PRINT_PGM("\002000/000\001 ");
374 374
     #endif
375 375
   }
376 376
     
@@ -432,7 +432,7 @@ void MainMenu::showStatus()
432 432
     
433 433
     if(starttime!=oldtime)
434 434
     {
435
-      lcd.print(itostr2(time/60));lcdprintPGM("h ");lcd.print(itostr2(time%60));lcdprintPGM("m");
435
+      lcd.print(itostr2(time/60));LCD_PRINT_PGM("h ");lcd.print(itostr2(time%60));LCD_PRINT_PGM("m");
436 436
       oldtime=time;
437 437
     }
438 438
   }
@@ -441,7 +441,7 @@ void MainMenu::showStatus()
441 441
   if((currentz!=oldzpos)||force_lcd_update)
442 442
   {
443 443
     lcd.setCursor(10,1);
444
-    lcdprintPGM("Z:");lcd.print(ftostr52(current_position[2]));
444
+    LCD_PRINT_PGM("Z:");lcd.print(ftostr52(current_position[2]));
445 445
     oldzpos=currentz;
446 446
   }
447 447
   
@@ -468,7 +468,7 @@ void MainMenu::showStatus()
468 468
   {
469 469
    oldfeedmultiply=curfeedmultiply;
470 470
    lcd.setCursor(0,2);
471
-   lcd.print(itostr3(curfeedmultiply));lcdprintPGM("% ");
471
+   lcd.print(itostr3(curfeedmultiply));LCD_PRINT_PGM("% ");
472 472
   }
473 473
   
474 474
   if(messagetext[0]!='\0')
@@ -487,7 +487,7 @@ void MainMenu::showStatus()
487 487
   {
488 488
      lcd.setCursor(10,2);
489 489
     lcd.print(itostr3((int)percent));
490
-    lcdprintPGM("%SD");
490
+    LCD_PRINT_PGM("%SD");
491 491
   }
492 492
 #endif
493 493
 #else //smaller LCDS----------------------------------
@@ -496,7 +496,7 @@ void MainMenu::showStatus()
496 496
   if(force_lcd_update)  //initial display of content
497 497
   {
498 498
     encoderpos=feedmultiply;
499
-    lcd.setCursor(0,0);lcdprintPGM("\002---/---\001 ");
499
+    lcd.setCursor(0,0);LCD_PRINT_PGM("\002---/---\001 ");
500 500
   }
501 501
     
502 502
   int tHotEnd0=intround(degHotend0());
@@ -550,26 +550,26 @@ void MainMenu::showPrepare()
550 550
   switch(i)
551 551
   {
552 552
     case ItemP_exit:
553
-      MENUITEM(  lcdprintPGM(MSG_MAIN)  ,  BLOCK;status=Main_Menu;beepshort(); ) ;
553
+      MENUITEM(  LCD_PRINT_PGM(MSG_MAIN)  ,  BLOCK;status=Main_Menu;beepshort(); ) ;
554 554
       break;
555 555
     case ItemP_autostart:
556
-      MENUITEM(  lcdprintPGM(MSG_AUTOSTART)  ,  BLOCK;
556
+      MENUITEM(  LCD_PRINT_PGM(MSG_AUTOSTART)  ,  BLOCK;
557 557
 #ifdef SDSUPPORT
558 558
           card.lastnr=0;card.setroot();card.checkautostart(true);
559 559
 #endif
560 560
           beepshort(); ) ;
561 561
       break;
562 562
     case ItemP_disstep:
563
-      MENUITEM(  lcdprintPGM(MSG_DISABLE_STEPPERS)  ,  BLOCK;enquecommand("M84");beepshort(); ) ;
563
+      MENUITEM(  LCD_PRINT_PGM(MSG_DISABLE_STEPPERS)  ,  BLOCK;enquecommand("M84");beepshort(); ) ;
564 564
       break;
565 565
     case ItemP_home:
566
-      MENUITEM(  lcdprintPGM(MSG_AUTO_HOME)  ,  BLOCK;enquecommand("G28");beepshort(); ) ;
566
+      MENUITEM(  LCD_PRINT_PGM(MSG_AUTO_HOME)  ,  BLOCK;enquecommand("G28");beepshort(); ) ;
567 567
       break;
568 568
     case ItemP_origin:
569
-      MENUITEM(  lcdprintPGM(MSG_SET_ORIGIN)  ,  BLOCK;enquecommand("G92 X0 Y0 Z0");beepshort(); ) ;
569
+      MENUITEM(  LCD_PRINT_PGM(MSG_SET_ORIGIN)  ,  BLOCK;enquecommand("G92 X0 Y0 Z0");beepshort(); ) ;
570 570
       break;
571 571
     case ItemP_preheat_pla:
572
-		MENUITEM(  lcdprintPGM(MSG_PREHEAT_PLA)  ,  BLOCK;setTargetHotend0(plaPreheatHotendTemp);setTargetBed(plaPreheatHPBTemp);
572
+		MENUITEM(  LCD_PRINT_PGM(MSG_PREHEAT_PLA)  ,  BLOCK;setTargetHotend0(plaPreheatHotendTemp);setTargetBed(plaPreheatHPBTemp);
573 573
       #if FAN_PIN > -1
574 574
 		FanSpeed = plaPreheatFanSpeed;
575 575
         analogWrite(FAN_PIN,  FanSpeed);
@@ -577,7 +577,7 @@ void MainMenu::showPrepare()
577 577
       beepshort(); );
578 578
       break;
579 579
     case ItemP_preheat_abs:
580
-      MENUITEM(  lcdprintPGM(MSG_PREHEAT_ABS)  ,  BLOCK;setTargetHotend0(absPreheatHotendTemp);setTargetBed(absPreheatHPBTemp); 
580
+      MENUITEM(  LCD_PRINT_PGM(MSG_PREHEAT_ABS)  ,  BLOCK;setTargetHotend0(absPreheatHotendTemp);setTargetBed(absPreheatHPBTemp); 
581 581
       #if FAN_PIN > -1
582 582
 	  	FanSpeed = absPreheatFanSpeed;
583 583
         analogWrite(FAN_PIN,  FanSpeed);
@@ -585,13 +585,13 @@ void MainMenu::showPrepare()
585 585
       beepshort(); );
586 586
       break;
587 587
     case ItemP_cooldown:
588
-      MENUITEM(  lcdprintPGM(MSG_COOLDOWN)  ,  BLOCK;setTargetHotend0(0);setTargetHotend1(0);setTargetHotend2(0);setTargetBed(0);beepshort(); ) ;
588
+      MENUITEM(  LCD_PRINT_PGM(MSG_COOLDOWN)  ,  BLOCK;setTargetHotend0(0);setTargetHotend1(0);setTargetHotend2(0);setTargetBed(0);beepshort(); ) ;
589 589
       break;
590 590
 //    case ItemP_extrude:
591
-  //    MENUITEM(  lcdprintPGM(" Extrude")  ,  BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E50");beepshort(); ) ;
591
+  //    MENUITEM(  LCD_PRINT_PGM(" Extrude")  ,  BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E50");beepshort(); ) ;
592 592
     //  break;
593 593
     case ItemP_move:
594
-      MENUITEM(  lcdprintPGM(MSG_MOVE_AXIS) , BLOCK;status=Sub_PrepareMove;beepshort(); );
594
+      MENUITEM(  LCD_PRINT_PGM(MSG_MOVE_AXIS) , BLOCK;status=Sub_PrepareMove;beepshort(); );
595 595
       break;
596 596
         default:   
597 597
       break;
@@ -617,14 +617,14 @@ void MainMenu::showAxisMove()
617 617
      switch(i)
618 618
       {
619 619
           case ItemAM_exit:
620
-          MENUITEM(  lcdprintPGM(MSG_PREPARE_ALT)  ,  BLOCK;status=Main_Prepare;beepshort(); ) ;
620
+          MENUITEM(  LCD_PRINT_PGM(MSG_PREPARE_ALT)  ,  BLOCK;status=Main_Prepare;beepshort(); ) ;
621 621
           break;
622 622
           case ItemAM_X:
623 623
           {
624 624
 	 	  //oldencoderpos=0;
625 625
                   if(force_lcd_update)
626 626
                   {
627
-                    lcd.setCursor(0,line);lcdprintPGM(" X:");
627
+                    lcd.setCursor(0,line);LCD_PRINT_PGM(" X:");
628 628
                     lcd.setCursor(11,line);lcd.print(ftostr52(current_position[X_AXIS]));
629 629
                   }
630 630
       
@@ -669,7 +669,7 @@ void MainMenu::showAxisMove()
669 669
             {
670 670
                   if(force_lcd_update)
671 671
                   {
672
-                    lcd.setCursor(0,line);lcdprintPGM(" Y:");
672
+                    lcd.setCursor(0,line);LCD_PRINT_PGM(" Y:");
673 673
                     lcd.setCursor(11,line);lcd.print(ftostr52(current_position[Y_AXIS]));
674 674
                   }
675 675
       
@@ -714,7 +714,7 @@ void MainMenu::showAxisMove()
714 714
           {
715 715
                   if(force_lcd_update)
716 716
                   {
717
-                    lcd.setCursor(0,line);lcdprintPGM(" Z:");
717
+                    lcd.setCursor(0,line);LCD_PRINT_PGM(" Z:");
718 718
                     lcd.setCursor(11,line);lcd.print(ftostr52(current_position[Z_AXIS]));
719 719
                   }
720 720
       
@@ -757,11 +757,11 @@ void MainMenu::showAxisMove()
757 757
           break;
758 758
           case ItemAM_E:
759 759
           // ErikDB: TODO: this length should be changed for volumetric.
760
-          MENUITEM(  lcdprintPGM(MSG_EXTRUDE)  ,  BLOCK;enquecommand("G92 E0");enquecommand("G1 F70 E1");beepshort(); ) ;
760
+          MENUITEM(  LCD_PRINT_PGM(MSG_EXTRUDE)  ,  BLOCK;enquecommand("G92 E0");enquecommand("G1 F70 E1");beepshort(); ) ;
761 761
           break;
762 762
           case ItemAM_ERetract:
763 763
               // ErikDB: TODO: this length should be changed for volumetric.
764
-              MENUITEM(  lcdprintPGM(MSG_RETRACT)  ,  BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E-1");beepshort(); ) ;
764
+              MENUITEM(  LCD_PRINT_PGM(MSG_RETRACT)  ,  BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E-1");beepshort(); ) ;
765 765
               break;
766 766
           default:
767 767
           break;
@@ -787,13 +787,13 @@ void MainMenu::showTune()
787 787
   switch(i)
788 788
   {
789 789
   case ItemT_exit:
790
-      MENUITEM(  lcdprintPGM(MSG_MAIN)  ,  BLOCK;status=Main_Menu;beepshort(); ) ;
790
+      MENUITEM(  LCD_PRINT_PGM(MSG_MAIN)  ,  BLOCK;status=Main_Menu;beepshort(); ) ;
791 791
       break;
792 792
   case ItemT_speed:
793 793
     {
794 794
       if(force_lcd_update)
795 795
       {
796
-        lcd.setCursor(0,line);lcdprintPGM(MSG_SPEED);
796
+        lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_SPEED);
797 797
         lcd.setCursor(13,line);lcd.print(ftostr3(feedmultiply));
798 798
       }
799 799
       
@@ -828,7 +828,7 @@ void MainMenu::showTune()
828 828
       {
829 829
         if(force_lcd_update)
830 830
         {
831
-          lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE);
831
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE);
832 832
           lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
833 833
         } 
834 834
         
@@ -862,7 +862,7 @@ void MainMenu::showTune()
862 862
       {
863 863
         if(force_lcd_update)
864 864
         {
865
-          lcd.setCursor(0,line);lcdprintPGM(MSG_BED);
865
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_BED);
866 866
           lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetBed())));
867 867
         }
868 868
         
@@ -898,7 +898,7 @@ void MainMenu::showTune()
898 898
       {
899 899
         if(force_lcd_update)
900 900
         {
901
-          lcd.setCursor(0,line);lcdprintPGM(MSG_FAN_SPEED);
901
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FAN_SPEED);
902 902
           lcd.setCursor(13,line);lcd.print(ftostr3(FanSpeed));
903 903
         }
904 904
         
@@ -933,7 +933,7 @@ void MainMenu::showTune()
933 933
          {
934 934
       if(force_lcd_update)
935 935
         {
936
-          lcd.setCursor(0,line);lcdprintPGM(MSG_FLOW);
936
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FLOW);
937 937
           lcd.setCursor(13,line);lcd.print(ftostr52(axis_steps_per_unit[E_AXIS]));
938 938
         }
939 939
         
@@ -975,22 +975,22 @@ void MainMenu::showTune()
975 975
  updateActiveLines(ItemT_fan,encoderpos);
976 976
 }
977 977
 
978
-//does not work
979
-// #define MENUCHANGEITEM(repaint_action,  enter_action, accept_action,  change_action) \
980
-//   {\
981
-//     if(force_lcd_update)  { lcd.setCursor(0,line);  repaint_action; } \
982
-//     if(activeline==line)  \
983
-//     { \
984
-//       if(CLICKED) \
985
-//       { \
986
-//         linechanging=!linechanging; \
987
-//         if(linechanging)  {enter_action;} \
988
-//         else {accept_action;} \
989
-//       }  \
990
-//       else \
991
-//       if(linechanging) {change_action};}\
992
-//   }
993
-//   
978
+/*does not work
979
+#define MENUCHANGEITEM(repaint_action,  enter_action, accept_action,  change_action) \
980
+   {\
981
+     if(force_lcd_update)  { lcd.setCursor(0,line);  repaint_action; } \
982
+     if(activeline==line)  \
983
+     { \
984
+       if(CLICKED) \
985
+       { \
986
+         linechanging=!linechanging; \
987
+         if(linechanging)  {enter_action;} \
988
+         else {accept_action;} \
989
+       }  \
990
+       else \
991
+       if(linechanging) {change_action};}\
992
+   }
993
+*/   
994 994
 
995 995
 enum {
996 996
   ItemCT_exit,ItemCT_nozzle0,
@@ -1022,13 +1022,13 @@ void MainMenu::showControlTemp()
1022 1022
   switch(i)
1023 1023
   {
1024 1024
     case ItemCT_exit:
1025
-      MENUITEM(  lcdprintPGM(MSG_CONTROL)  ,  BLOCK;status=Main_Control;beepshort(); ) ;
1025
+      MENUITEM(  LCD_PRINT_PGM(MSG_CONTROL)  ,  BLOCK;status=Main_Control;beepshort(); ) ;
1026 1026
       break;
1027 1027
     case ItemCT_nozzle0:
1028 1028
       {
1029 1029
         if(force_lcd_update)
1030 1030
         {
1031
-          lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE);
1031
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE);
1032 1032
           lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
1033 1033
         }
1034 1034
         
@@ -1063,7 +1063,7 @@ void MainMenu::showControlTemp()
1063 1063
       {
1064 1064
         if(force_lcd_update)
1065 1065
         {
1066
-          lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE1);
1066
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE1);
1067 1067
           lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend1())));
1068 1068
         }
1069 1069
         
@@ -1099,7 +1099,7 @@ void MainMenu::showControlTemp()
1099 1099
       {
1100 1100
         if(force_lcd_update)
1101 1101
         {
1102
-          lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE2);
1102
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE2);
1103 1103
           lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend2())));
1104 1104
         }
1105 1105
         
@@ -1135,7 +1135,7 @@ void MainMenu::showControlTemp()
1135 1135
       {
1136 1136
         if(force_lcd_update)
1137 1137
         {
1138
-          lcd.setCursor(0,line);lcdprintPGM(MSG_MIN);
1138
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_MIN);
1139 1139
           lcd.setCursor(13,line);lcd.print(ftostr3(autotemp_min));
1140 1140
         }
1141 1141
         
@@ -1169,7 +1169,7 @@ void MainMenu::showControlTemp()
1169 1169
       {
1170 1170
         if(force_lcd_update)
1171 1171
         {
1172
-          lcd.setCursor(0,line);lcdprintPGM(MSG_MAX);
1172
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_MAX);
1173 1173
           lcd.setCursor(13,line);lcd.print(ftostr3(autotemp_max));
1174 1174
         }
1175 1175
         
@@ -1203,7 +1203,7 @@ void MainMenu::showControlTemp()
1203 1203
       {
1204 1204
         if(force_lcd_update)
1205 1205
         {
1206
-          lcd.setCursor(0,line);lcdprintPGM(MSG_FACTOR);
1206
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FACTOR);
1207 1207
           lcd.setCursor(13,line);lcd.print(ftostr32(autotemp_factor));
1208 1208
         }
1209 1209
         
@@ -1237,12 +1237,12 @@ void MainMenu::showControlTemp()
1237 1237
       {
1238 1238
         if(force_lcd_update)
1239 1239
         {
1240
-          lcd.setCursor(0,line);lcdprintPGM(MSG_AUTOTEMP);
1240
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_AUTOTEMP);
1241 1241
           lcd.setCursor(13,line);
1242 1242
           if(autotemp_enabled)
1243
-            lcdprintPGM(MSG_ON);
1243
+            LCD_PRINT_PGM(MSG_ON);
1244 1244
           else
1245
-            lcdprintPGM(MSG_OFF);
1245
+            LCD_PRINT_PGM(MSG_OFF);
1246 1246
         }
1247 1247
         
1248 1248
         if((activeline!=line) )
@@ -1253,9 +1253,9 @@ void MainMenu::showControlTemp()
1253 1253
           autotemp_enabled=!autotemp_enabled;
1254 1254
           lcd.setCursor(13,line);
1255 1255
           if(autotemp_enabled)
1256
-            lcdprintPGM(MSG_ON);
1256
+            LCD_PRINT_PGM(MSG_ON);
1257 1257
           else
1258
-            lcdprintPGM(MSG_OFF);
1258
+            LCD_PRINT_PGM(MSG_OFF);
1259 1259
           BLOCK;
1260 1260
         }
1261 1261
         
@@ -1266,7 +1266,7 @@ void MainMenu::showControlTemp()
1266 1266
       {
1267 1267
         if(force_lcd_update)
1268 1268
         {
1269
-          lcd.setCursor(0,line);lcdprintPGM(MSG_BED);
1269
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_BED);
1270 1270
           lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetBed())));
1271 1271
         }
1272 1272
         
@@ -1300,7 +1300,7 @@ void MainMenu::showControlTemp()
1300 1300
       {
1301 1301
         if(force_lcd_update)
1302 1302
         {
1303
-          lcd.setCursor(0,line);lcdprintPGM(MSG_FAN_SPEED);
1303
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FAN_SPEED);
1304 1304
           lcd.setCursor(13,line);lcd.print(ftostr3(FanSpeed));
1305 1305
         }
1306 1306
         
@@ -1336,7 +1336,7 @@ void MainMenu::showControlTemp()
1336 1336
       {
1337 1337
       if(force_lcd_update)
1338 1338
         {
1339
-          lcd.setCursor(0,line);lcdprintPGM(" PID-P: ");
1339
+          lcd.setCursor(0,line);LCD_PRINT_PGM(" PID-P: ");
1340 1340
           lcd.setCursor(13,line);lcd.print(itostr4(Kp));
1341 1341
         }
1342 1342
         
@@ -1371,7 +1371,7 @@ void MainMenu::showControlTemp()
1371 1371
       {
1372 1372
       if(force_lcd_update)
1373 1373
         {
1374
-          lcd.setCursor(0,line);lcdprintPGM(MSG_PID_I);
1374
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_PID_I);
1375 1375
           lcd.setCursor(13,line);lcd.print(ftostr51(Ki/PID_dT));
1376 1376
         }
1377 1377
         
@@ -1406,7 +1406,7 @@ void MainMenu::showControlTemp()
1406 1406
       {
1407 1407
       if(force_lcd_update)
1408 1408
         {
1409
-          lcd.setCursor(0,line);lcdprintPGM(MSG_PID_D);
1409
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_PID_D);
1410 1410
           lcd.setCursor(13,line);lcd.print(itostr4(Kd*PID_dT));
1411 1411
         }
1412 1412
         
@@ -1443,7 +1443,7 @@ void MainMenu::showControlTemp()
1443 1443
       {
1444 1444
       if(force_lcd_update)
1445 1445
         {
1446
-          lcd.setCursor(0,line);lcdprintPGM(MSG_PID_C);
1446
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_PID_C);
1447 1447
           lcd.setCursor(13,line);lcd.print(itostr3(Kc));
1448 1448
         }
1449 1449
         
@@ -1478,10 +1478,10 @@ void MainMenu::showControlTemp()
1478 1478
     #endif
1479 1479
       break;
1480 1480
 	  case ItemCT_PLA_PreHeat_Setting:
1481
-        MENUITEM(  lcdprintPGM(MSG_PREHEAT_PLA_SETTINGS)  ,  BLOCK;status=Sub_PreheatPLASettings;beepshort(); ) ;
1481
+        MENUITEM(  LCD_PRINT_PGM(MSG_PREHEAT_PLA_SETTINGS)  ,  BLOCK;status=Sub_PreheatPLASettings;beepshort(); ) ;
1482 1482
 	  break;
1483 1483
 	  case ItemCT_ABS_PreHeat_Setting:
1484
-        MENUITEM(  lcdprintPGM(MSG_PREHEAT_ABS_SETTINGS)  ,  BLOCK;status=Sub_PreheatABSSettings;beepshort(); ) ;
1484
+        MENUITEM(  LCD_PRINT_PGM(MSG_PREHEAT_ABS_SETTINGS)  ,  BLOCK;status=Sub_PreheatABSSettings;beepshort(); ) ;
1485 1485
 	  break;
1486 1486
     default:   
1487 1487
       break;
@@ -1513,14 +1513,14 @@ void MainMenu::showControlMotion()
1513 1513
   switch(i)
1514 1514
   {
1515 1515
     case ItemCM_exit:
1516
-      MENUITEM(  lcdprintPGM(MSG_CONTROL)  ,  BLOCK;status=Main_Control;beepshort(); ) ;
1516
+      MENUITEM(  LCD_PRINT_PGM(MSG_CONTROL)  ,  BLOCK;status=Main_Control;beepshort(); ) ;
1517 1517
       break;
1518 1518
     case ItemCM_acc:
1519 1519
     {
1520 1520
       if(force_lcd_update)
1521 1521
         {
1522
-          lcd.setCursor(0,line);lcdprintPGM(MSG_ACC);
1523
-          lcd.setCursor(13,line);lcd.print(itostr3(acceleration/100));lcdprintPGM("00");
1522
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_ACC);
1523
+          lcd.setCursor(13,line);lcd.print(itostr3(acceleration/100));LCD_PRINT_PGM("00");
1524 1524
         }
1525 1525
         
1526 1526
         if((activeline!=line) )
@@ -1545,7 +1545,7 @@ void MainMenu::showControlMotion()
1545 1545
         {
1546 1546
           if(encoderpos<5) encoderpos=5;
1547 1547
           if(encoderpos>990) encoderpos=990;
1548
-          lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
1548
+          lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));LCD_PRINT_PGM("00");
1549 1549
         }
1550 1550
         
1551 1551
       }break;
@@ -1553,7 +1553,7 @@ void MainMenu::showControlMotion()
1553 1553
       {
1554 1554
       if(force_lcd_update)
1555 1555
         {
1556
-          lcd.setCursor(0,line);lcdprintPGM(MSG_VXY_JERK);
1556
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_VXY_JERK);
1557 1557
           lcd.setCursor(13,line);lcd.print(itostr3(max_xy_jerk));
1558 1558
         }
1559 1559
         
@@ -1592,11 +1592,11 @@ void MainMenu::showControlMotion()
1592 1592
       {
1593 1593
       if(force_lcd_update)
1594 1594
         {
1595
-          lcd.setCursor(0,line);lcdprintPGM(MSG_VMAX);
1596
-          if(i==ItemCM_vmaxx)lcdprintPGM(MSG_X);
1597
-          if(i==ItemCM_vmaxy)lcdprintPGM(MSG_Y);
1598
-          if(i==ItemCM_vmaxz)lcdprintPGM(MSG_Z);
1599
-          if(i==ItemCM_vmaxe)lcdprintPGM(MSG_E);
1595
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_VMAX);
1596
+          if(i==ItemCM_vmaxx)LCD_PRINT_PGM(MSG_X);
1597
+          if(i==ItemCM_vmaxy)LCD_PRINT_PGM(MSG_Y);
1598
+          if(i==ItemCM_vmaxz)LCD_PRINT_PGM(MSG_Z);
1599
+          if(i==ItemCM_vmaxe)LCD_PRINT_PGM(MSG_E);
1600 1600
           lcd.setCursor(13,line);lcd.print(itostr3(max_feedrate[i-ItemCM_vmaxx]));
1601 1601
         }
1602 1602
         
@@ -1632,7 +1632,7 @@ void MainMenu::showControlMotion()
1632 1632
     {
1633 1633
       if(force_lcd_update)
1634 1634
         {
1635
-          lcd.setCursor(0,line);lcdprintPGM(MSG_VMIN);
1635
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_VMIN);
1636 1636
           lcd.setCursor(13,line);lcd.print(itostr3(minimumfeedrate));
1637 1637
         }
1638 1638
         
@@ -1667,7 +1667,7 @@ void MainMenu::showControlMotion()
1667 1667
     {
1668 1668
       if(force_lcd_update)
1669 1669
         {
1670
-          lcd.setCursor(0,line);lcdprintPGM(MSG_VTRAV_MIN);
1670
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_VTRAV_MIN);
1671 1671
           lcd.setCursor(13,line);lcd.print(itostr3(mintravelfeedrate));
1672 1672
         }
1673 1673
         
@@ -1706,12 +1706,12 @@ void MainMenu::showControlMotion()
1706 1706
     {
1707 1707
       if(force_lcd_update)
1708 1708
         {
1709
-          lcd.setCursor(0,line);lcdprintPGM(" Amax ");
1710
-          if(i==ItemCM_amaxx)lcdprintPGM(MSG_X);
1711
-          if(i==ItemCM_amaxy)lcdprintPGM(MSG_Y);
1712
-          if(i==ItemCM_amaxz)lcdprintPGM(MSG_Z);
1713
-          if(i==ItemCM_amaxe)lcdprintPGM(MSG_E);
1714
-          lcd.setCursor(13,line);lcd.print(itostr3(max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100));lcdprintPGM("00");
1709
+          lcd.setCursor(0,line);LCD_PRINT_PGM(" Amax ");
1710
+          if(i==ItemCM_amaxx)LCD_PRINT_PGM(MSG_X);
1711
+          if(i==ItemCM_amaxy)LCD_PRINT_PGM(MSG_Y);
1712
+          if(i==ItemCM_amaxz)LCD_PRINT_PGM(MSG_Z);
1713
+          if(i==ItemCM_amaxe)LCD_PRINT_PGM(MSG_E);
1714
+          lcd.setCursor(13,line);lcd.print(itostr3(max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100));LCD_PRINT_PGM("00");
1715 1715
         }
1716 1716
         
1717 1717
         if((activeline!=line) )
@@ -1736,7 +1736,7 @@ void MainMenu::showControlMotion()
1736 1736
         {
1737 1737
           if(encoderpos<1) encoderpos=1;
1738 1738
           if(encoderpos>990) encoderpos=990;
1739
-          lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
1739
+          lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));LCD_PRINT_PGM("00");
1740 1740
         }
1741 1741
         
1742 1742
       }break;
@@ -1746,8 +1746,8 @@ void MainMenu::showControlMotion()
1746 1746
     {
1747 1747
         if(force_lcd_update)
1748 1748
         {
1749
-          lcd.setCursor(0,line);lcdprintPGM(MSG_A_RETRACT);
1750
-          lcd.setCursor(13,line);lcd.print(ftostr3(retract_acceleration/100));lcdprintPGM("00");
1749
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_A_RETRACT);
1750
+          lcd.setCursor(13,line);lcd.print(ftostr3(retract_acceleration/100));LCD_PRINT_PGM("00");
1751 1751
         }
1752 1752
         
1753 1753
         if((activeline!=line) )
@@ -1773,7 +1773,7 @@ void MainMenu::showControlMotion()
1773 1773
         {
1774 1774
           if(encoderpos<10) encoderpos=10;
1775 1775
           if(encoderpos>990) encoderpos=990;
1776
-          lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
1776
+          lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));LCD_PRINT_PGM("00");
1777 1777
         }
1778 1778
         
1779 1779
       }break;
@@ -1781,7 +1781,7 @@ void MainMenu::showControlMotion()
1781 1781
          {
1782 1782
       if(force_lcd_update)
1783 1783
         {
1784
-          lcd.setCursor(0,line);lcdprintPGM(MSG_XSTEPS);
1784
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_XSTEPS);
1785 1785
           lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[X_AXIS]));
1786 1786
         }
1787 1787
         
@@ -1818,7 +1818,7 @@ void MainMenu::showControlMotion()
1818 1818
          {
1819 1819
       if(force_lcd_update)
1820 1820
         {
1821
-          lcd.setCursor(0,line);lcdprintPGM(MSG_YSTEPS);
1821
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_YSTEPS);
1822 1822
           lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Y_AXIS]));
1823 1823
         }
1824 1824
         
@@ -1856,7 +1856,7 @@ void MainMenu::showControlMotion()
1856 1856
          {
1857 1857
       if(force_lcd_update)
1858 1858
         {
1859
-          lcd.setCursor(0,line);lcdprintPGM(MSG_ZSTEPS);
1859
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_ZSTEPS);
1860 1860
           lcd.setCursor(11,line);lcd.print(ftostr51(axis_steps_per_unit[Z_AXIS]));
1861 1861
         }
1862 1862
         
@@ -1895,7 +1895,7 @@ void MainMenu::showControlMotion()
1895 1895
          {
1896 1896
       if(force_lcd_update)
1897 1897
         {
1898
-          lcd.setCursor(0,line);lcdprintPGM(MSG_ESTEPS);
1898
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_ESTEPS);
1899 1899
           lcd.setCursor(11,line);lcd.print(ftostr51(axis_steps_per_unit[E_AXIS]));
1900 1900
         }
1901 1901
         
@@ -1958,7 +1958,7 @@ void MainMenu::showControlRetract()
1958 1958
   switch(i)
1959 1959
   {
1960 1960
     case ItemR_exit:
1961
-      MENUITEM(  lcdprintPGM(MSG_CONTROL)  ,  BLOCK;status=Main_Control;beepshort(); ) ;
1961
+      MENUITEM(  LCD_PRINT_PGM(MSG_CONTROL)  ,  BLOCK;status=Main_Control;beepshort(); ) ;
1962 1962
       break;
1963 1963
     
1964 1964
       //float retract_length=2, retract_feedrate=1200, retract_zlift=0.4;
@@ -1967,12 +1967,12 @@ void MainMenu::showControlRetract()
1967 1967
       {
1968 1968
         if(force_lcd_update)
1969 1969
         {
1970
-          lcd.setCursor(0,line);lcdprintPGM(MSG_AUTORETRACT);
1970
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_AUTORETRACT);
1971 1971
           lcd.setCursor(13,line);
1972 1972
           if(autoretract_enabled)
1973
-            lcdprintPGM(MSG_ON);
1973
+            LCD_PRINT_PGM(MSG_ON);
1974 1974
           else
1975
-            lcdprintPGM(MSG_OFF);
1975
+            LCD_PRINT_PGM(MSG_OFF);
1976 1976
         }
1977 1977
         
1978 1978
         if((activeline!=line) )
@@ -1983,9 +1983,9 @@ void MainMenu::showControlRetract()
1983 1983
           autoretract_enabled=!autoretract_enabled;
1984 1984
           lcd.setCursor(13,line);
1985 1985
           if(autoretract_enabled)
1986
-            lcdprintPGM(MSG_ON);
1986
+            LCD_PRINT_PGM(MSG_ON);
1987 1987
           else
1988
-            lcdprintPGM(MSG_OFF);
1988
+            LCD_PRINT_PGM(MSG_OFF);
1989 1989
           BLOCK;
1990 1990
         }
1991 1991
         
@@ -1995,7 +1995,7 @@ void MainMenu::showControlRetract()
1995 1995
     {
1996 1996
         if(force_lcd_update)
1997 1997
         {
1998
-          lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACT);
1998
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_CONTROL_RETRACT);
1999 1999
           lcd.setCursor(13,line);lcd.print(ftostr52(retract_length));
2000 2000
         }
2001 2001
         
@@ -2030,7 +2030,7 @@ void MainMenu::showControlRetract()
2030 2030
     {
2031 2031
         if(force_lcd_update)
2032 2032
         {
2033
-          lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACTF);
2033
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_CONTROL_RETRACTF);
2034 2034
           lcd.setCursor(13,line);lcd.print(itostr4(retract_feedrate));
2035 2035
         }
2036 2036
         
@@ -2065,7 +2065,7 @@ void MainMenu::showControlRetract()
2065 2065
     {
2066 2066
         if(force_lcd_update)
2067 2067
         {
2068
-          lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACT_ZLIFT);
2068
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_CONTROL_RETRACT_ZLIFT);
2069 2069
           lcd.setCursor(13,line);lcd.print(ftostr52(retract_zlift));;
2070 2070
         }
2071 2071
         
@@ -2100,7 +2100,7 @@ void MainMenu::showControlRetract()
2100 2100
     {
2101 2101
         if(force_lcd_update)
2102 2102
         {
2103
-          lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACT_RECOVER);
2103
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_CONTROL_RETRACT_RECOVER);
2104 2104
           lcd.setCursor(13,line);lcd.print(ftostr52(retract_recover_length));;
2105 2105
         }
2106 2106
         
@@ -2136,7 +2136,7 @@ void MainMenu::showControlRetract()
2136 2136
     {
2137 2137
         if(force_lcd_update)
2138 2138
         {
2139
-          lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACT_RECOVERF);
2139
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_CONTROL_RETRACT_RECOVERF);
2140 2140
           lcd.setCursor(13,line);lcd.print(itostr4(retract_recover_feedrate));
2141 2141
         }
2142 2142
         
@@ -2196,24 +2196,24 @@ void MainMenu::showControl()
2196 2196
   switch(i)
2197 2197
   {
2198 2198
     case ItemC_exit:
2199
-      MENUITEM(  lcdprintPGM(MSG_MAIN_WIDE)  ,  BLOCK;status=Main_Menu;beepshort(); ) ;
2199
+      MENUITEM(  LCD_PRINT_PGM(MSG_MAIN_WIDE)  ,  BLOCK;status=Main_Menu;beepshort(); ) ;
2200 2200
       break;
2201 2201
     case ItemC_temp:
2202
-      MENUITEM(  lcdprintPGM(MSG_TEMPERATURE_WIDE)  ,  BLOCK;status=Sub_TempControl;beepshort(); ) ;
2202
+      MENUITEM(  LCD_PRINT_PGM(MSG_TEMPERATURE_WIDE)  ,  BLOCK;status=Sub_TempControl;beepshort(); ) ;
2203 2203
       break;
2204 2204
    case ItemC_move:
2205
-      MENUITEM(  lcdprintPGM(MSG_MOTION_WIDE)  ,  BLOCK;status=Sub_MotionControl;beepshort(); ) ;
2205
+      MENUITEM(  LCD_PRINT_PGM(MSG_MOTION_WIDE)  ,  BLOCK;status=Sub_MotionControl;beepshort(); ) ;
2206 2206
       break;
2207 2207
 #ifdef FWRETRACT
2208 2208
     case ItemC_rectract:
2209
-      MENUITEM(  lcdprintPGM(MSG_RECTRACT_WIDE)  ,  BLOCK;status=Sub_RetractControl;beepshort(); ) ;
2209
+      MENUITEM(  LCD_PRINT_PGM(MSG_RECTRACT_WIDE)  ,  BLOCK;status=Sub_RetractControl;beepshort(); ) ;
2210 2210
       break;
2211 2211
 #endif
2212 2212
     case ItemC_store:
2213 2213
     {
2214 2214
       if(force_lcd_update)
2215 2215
       {
2216
-        lcd.setCursor(0,line);lcdprintPGM(MSG_STORE_EPROM);
2216
+        lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_STORE_EPROM);
2217 2217
       }
2218 2218
       if((activeline==line) && CLICKED)
2219 2219
       {
@@ -2227,7 +2227,7 @@ void MainMenu::showControl()
2227 2227
     {
2228 2228
       if(force_lcd_update)
2229 2229
       {
2230
-        lcd.setCursor(0,line);lcdprintPGM(MSG_LOAD_EPROM);
2230
+        lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_LOAD_EPROM);
2231 2231
       }
2232 2232
       if((activeline==line) && CLICKED)
2233 2233
       {
@@ -2241,7 +2241,7 @@ void MainMenu::showControl()
2241 2241
     {
2242 2242
       if(force_lcd_update)
2243 2243
       {
2244
-        lcd.setCursor(0,line);lcdprintPGM(MSG_RESTORE_FAILSAFE);
2244
+        lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_RESTORE_FAILSAFE);
2245 2245
       }
2246 2246
       if((activeline==line) && CLICKED)
2247 2247
       {
@@ -2288,7 +2288,7 @@ void MainMenu::showSD()
2288 2288
   switch(i)
2289 2289
   {
2290 2290
     case 0:
2291
-      MENUITEM(  lcdprintPGM(MSG_MAIN)  ,  BLOCK;status=Main_Menu;beepshort(); ) ;
2291
+      MENUITEM(  LCD_PRINT_PGM(MSG_MAIN)  ,  BLOCK;status=Main_Menu;beepshort(); ) ;
2292 2292
       break;
2293 2293
 //     case 1:
2294 2294
 //       {
@@ -2301,11 +2301,11 @@ void MainMenu::showSD()
2301 2301
 //           if(true)
2302 2302
 //           #endif
2303 2303
 //           {
2304
-//             lcdprintPGM(" \004Refresh");
2304
+//             LCD_PRINT_PGM(" \004Refresh");
2305 2305
 //           }
2306 2306
 //           else
2307 2307
 //           {
2308
-//             lcdprintPGM(" \004Insert Card");
2308
+//             LCD_PRINT_PGM(" \004Insert Card");
2309 2309
 //           }
2310 2310
 //           
2311 2311
 //         }
@@ -2320,7 +2320,7 @@ void MainMenu::showSD()
2320 2320
 //       }break;
2321 2321
     case 1:
2322 2322
       MENUITEM(  lcd.print(" ");card.getWorkDirName();
2323
-	  if(card.filename[0]=='/') lcdprintPGM(MSG_REFRESH);
2323
+	  if(card.filename[0]=='/') LCD_PRINT_PGM(MSG_REFRESH);
2324 2324
 	  else {
2325 2325
 		  lcd.print("\005");
2326 2326
 		  lcd.print(card.filename);
@@ -2343,8 +2343,12 @@ void MainMenu::showSD()
2343 2343
         {
2344 2344
           card.getfilename(i-FIRSTITEM);
2345 2345
           //Serial.print("Filenr:");Serial.println(i-2);
2346
-          lcd.setCursor(0,line);lcdprintPGM(" ");
2347
-          if(card.filenameIsDir) lcd.print("\005");
2346
+          lcd.setCursor(0,line);LCD_PRINT_PGM(" ");
2347
+          if(card.filenameIsDir)
2348
+          {
2349
+            lcd.print("\005");
2350
+            card.longFilename[LCD_WIDTH-2] = '\0';
2351
+          }
2348 2352
           if (card.longFilename[0])
2349 2353
           {
2350 2354
             card.longFilename[LCD_WIDTH-1] = '\0';
@@ -2436,14 +2440,14 @@ void MainMenu::showMainMenu()
2436 2440
     switch(i)
2437 2441
     { 
2438 2442
       case ItemM_watch:
2439
-        MENUITEM(  lcdprintPGM(MSG_WATCH)  ,  BLOCK;status=Main_Status;beepshort(); ) ;
2443
+        MENUITEM(  LCD_PRINT_PGM(MSG_WATCH)  ,  BLOCK;status=Main_Status;beepshort(); ) ;
2440 2444
        break;
2441 2445
       case ItemM_prepare:
2442
-        MENUITEM(  if(!tune) lcdprintPGM(MSG_PREPARE);else  lcdprintPGM(MSG_TUNE); ,  BLOCK;status=Main_Prepare;beepshort(); ) ;
2446
+        MENUITEM(  if(!tune) LCD_PRINT_PGM(MSG_PREPARE);else  LCD_PRINT_PGM(MSG_TUNE); ,  BLOCK;status=Main_Prepare;beepshort(); ) ;
2443 2447
       break;
2444 2448
        
2445 2449
       case ItemM_control:
2446
-        MENUITEM(  lcdprintPGM(MSG_CONTROL_ARROW)  ,  BLOCK;status=Main_Control;beepshort(); ) ;
2450
+        MENUITEM(  LCD_PRINT_PGM(MSG_CONTROL_ARROW)  ,  BLOCK;status=Main_Control;beepshort(); ) ;
2447 2451
       break;
2448 2452
       #ifdef SDSUPPORT
2449 2453
       case ItemM_file:    
@@ -2458,13 +2462,13 @@ void MainMenu::showMainMenu()
2458 2462
           #endif
2459 2463
           {
2460 2464
             if(card.sdprinting)
2461
-              lcdprintPGM(MSG_STOP_PRINT);
2465
+              LCD_PRINT_PGM(MSG_STOP_PRINT);
2462 2466
             else
2463
-              lcdprintPGM(MSG_CARD_MENU);
2467
+              LCD_PRINT_PGM(MSG_CARD_MENU);
2464 2468
           }
2465 2469
           else
2466 2470
           {
2467
-           lcdprintPGM(MSG_NO_CARD); 
2471
+           LCD_PRINT_PGM(MSG_NO_CARD); 
2468 2472
           }
2469 2473
         }
2470 2474
         #ifdef CARDINSERTED
@@ -2490,13 +2494,13 @@ void MainMenu::showMainMenu()
2490 2494
 #endif
2491 2495
                     {
2492 2496
                         if(card.sdprinting)
2493
-                            lcdprintPGM(MSG_PAUSE_PRINT);
2497
+                            LCD_PRINT_PGM(MSG_PAUSE_PRINT);
2494 2498
                         else
2495
-                            lcdprintPGM(MSG_RESUME_PRINT);
2499
+                            LCD_PRINT_PGM(MSG_RESUME_PRINT);
2496 2500
                     }
2497 2501
                     else
2498 2502
                     {
2499
-                        //lcdprintPGM(MSG_NO_CARD);
2503
+                        //LCD_PRINT_PGM(MSG_NO_CARD);
2500 2504
                     }
2501 2505
             }
2502 2506
 #ifdef CARDINSERTED
@@ -2666,14 +2670,14 @@ void MainMenu::showPLAsettings()
2666 2670
   {
2667 2671
 
2668 2672
 	case ItemPLAPreHeat_Exit:
2669
-      MENUITEM(  lcdprintPGM(MSG_TEMPERATURE_RTN)  ,  BLOCK;status=Sub_TempControl;beepshort(); ) ;
2673
+      MENUITEM(  LCD_PRINT_PGM(MSG_TEMPERATURE_RTN)  ,  BLOCK;status=Sub_TempControl;beepshort(); ) ;
2670 2674
       break;
2671 2675
 
2672 2676
     case ItemPLAPreHeat_set_PLA_FanSpeed:
2673 2677
        {
2674 2678
         if(force_lcd_update)
2675 2679
         {
2676
-          lcd.setCursor(0,line);lcdprintPGM(MSG_FAN_SPEED);
2680
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FAN_SPEED);
2677 2681
           lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatFanSpeed));
2678 2682
         }
2679 2683
         
@@ -2707,7 +2711,7 @@ void MainMenu::showPLAsettings()
2707 2711
       {
2708 2712
         if(force_lcd_update)
2709 2713
         {
2710
-          lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE);
2714
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE);
2711 2715
           lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatHotendTemp));
2712 2716
         } 
2713 2717
         
@@ -2741,7 +2745,7 @@ void MainMenu::showPLAsettings()
2741 2745
       {
2742 2746
         if(force_lcd_update)
2743 2747
         {
2744
-          lcd.setCursor(0,line);lcdprintPGM(MSG_BED);
2748
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_BED);
2745 2749
           lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatHPBTemp));
2746 2750
         } 
2747 2751
         
@@ -2774,7 +2778,7 @@ void MainMenu::showPLAsettings()
2774 2778
     {
2775 2779
       if(force_lcd_update)
2776 2780
       {
2777
-        lcd.setCursor(0,line);lcdprintPGM(MSG_STORE_EPROM);
2781
+        lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_STORE_EPROM);
2778 2782
       }
2779 2783
       if((activeline==line) && CLICKED)
2780 2784
       {
@@ -2812,14 +2816,14 @@ void MainMenu::showABSsettings()
2812 2816
   {
2813 2817
 
2814 2818
 	case ItemABSPreHeat_Exit:
2815
-      MENUITEM(  lcdprintPGM(MSG_TEMPERATURE_RTN)  ,  BLOCK;status=Sub_TempControl;beepshort(); ) ;
2819
+      MENUITEM(  LCD_PRINT_PGM(MSG_TEMPERATURE_RTN)  ,  BLOCK;status=Sub_TempControl;beepshort(); ) ;
2816 2820
       break;
2817 2821
 
2818 2822
     case ItemABSPreHeat_set_FanSpeed:
2819 2823
        {
2820 2824
         if(force_lcd_update)
2821 2825
         {
2822
-          lcd.setCursor(0,line);lcdprintPGM(MSG_FAN_SPEED);
2826
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FAN_SPEED);
2823 2827
           lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatFanSpeed));
2824 2828
         }
2825 2829
         
@@ -2853,7 +2857,7 @@ void MainMenu::showABSsettings()
2853 2857
       {
2854 2858
         if(force_lcd_update)
2855 2859
         {
2856
-          lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE);
2860
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE);
2857 2861
           lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatHotendTemp));
2858 2862
         } 
2859 2863
         
@@ -2887,7 +2891,7 @@ void MainMenu::showABSsettings()
2887 2891
       {
2888 2892
         if(force_lcd_update)
2889 2893
         {
2890
-          lcd.setCursor(0,line);lcdprintPGM(MSG_BED);
2894
+          lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_BED);
2891 2895
           lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatHPBTemp));
2892 2896
         } 
2893 2897
         
@@ -2920,7 +2924,7 @@ void MainMenu::showABSsettings()
2920 2924
     {
2921 2925
       if(force_lcd_update)
2922 2926
       {
2923
-        lcd.setCursor(0,line);lcdprintPGM(MSG_STORE_EPROM);
2927
+        lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_STORE_EPROM);
2924 2928
       }
2925 2929
       if((activeline==line) && CLICKED)
2926 2930
       {

+ 45
- 31
Marlin/ultralcd.h Näytä tiedosto

@@ -1,46 +1,41 @@
1 1
 #ifndef ULTRALCD_H
2 2
 #define ULTRALCD_H
3
+
3 4
 #include "Marlin.h"
5
+
4 6
 #ifdef ULTRA_LCD
5 7
 #include "language.h"
8
+
6 9
 #if LANGUAGE_CHOICE == 6
7 10
 #include "LiquidCrystalRus.h"
11
+#define LCD_CLASS LiquidCrystalRus
8 12
 #else
9 13
 #include <LiquidCrystal.h>
14
+#define LCD_CLASS LiquidCrystal
10 15
 #endif
11
-  void lcd_status();
12
-  void lcd_init();
13
-  void lcd_status(const char* message);
14
-  void beep();
15
-  void buttons_init();
16
-  void buttons_check();
17
-
18
-  #define LCD_UPDATE_INTERVAL 100
19
-  #define STATUSTIMEOUT 15000
20
-#if LANGUAGE_CHOICE == 6
21
-  extern LiquidCrystalRus lcd;
22
-#else
23
-  extern LiquidCrystal lcd;
24
-#endif
25
-  extern volatile char buttons;  //the last checked buttons in a bit array.
16
+
17
+void lcd_status();
18
+void lcd_init();
19
+void lcd_status(const char* message);
20
+void beep();
21
+void buttons_init();
22
+void buttons_check();
23
+
24
+#define LCD_UPDATE_INTERVAL 100
25
+#define STATUSTIMEOUT 15000
26
+
27
+extern LCD_CLASS lcd;
28
+
29
+extern volatile char buttons;  //the last checked buttons in a bit array.
26 30
   
27
-  #ifdef NEWPANEL
31
+#ifdef NEWPANEL
28 32
     #define EN_C (1<<BLEN_C)
29 33
     #define EN_B (1<<BLEN_B)
30 34
     #define EN_A (1<<BLEN_A)
31
-    
35
+
32 36
     #define CLICKED (buttons&EN_C)
33 37
     #define BLOCK {blocking=millis()+blocktime;}
34
-    #if (SDCARDDETECT > -1)
35
-      #ifdef SDCARDDETECTINVERTED 
36
-        #define CARDINSERTED (READ(SDCARDDETECT)!=0)
37
-      #else
38
-        #define CARDINSERTED (READ(SDCARDDETECT)==0)
39
-      #endif
40
-    #endif  //SDCARDTETECTINVERTED
41
-
42
-  #else
43
-
38
+#else
44 39
     //atomatic, do not change
45 40
     #define B_LE (1<<BL_LE)
46 41
     #define B_UP (1<<BL_UP)
@@ -53,9 +48,18 @@
53 48
     
54 49
     #define CLICKED ((buttons&B_MI)||(buttons&B_ST))
55 50
     #define BLOCK {blocking[BL_MI]=millis()+blocktime;blocking[BL_ST]=millis()+blocktime;}
56
-    
57
-  #endif
51
+#endif
58 52
 
53
+#if (SDCARDDETECT > -1)
54
+#ifdef SDCARDDETECTINVERTED 
55
+#define CARDINSERTED (READ(SDCARDDETECT)!=0)
56
+#else
57
+#define CARDINSERTED (READ(SDCARDDETECT)==0)
58
+#endif //SDCARDTETECTINVERTED
59
+#else
60
+//If we don't have a card detect line, aways asume the card is inserted
61
+#define CARDINSERTED true
62
+#endif
59 63
 
60 64
     
61 65
   // blocking time for recognizing a new keypress of one key, ms
@@ -152,8 +156,8 @@
152 156
 
153 157
   #define LCD_INIT lcd_init();
154 158
   #define LCD_MESSAGE(x) lcd_status(x);
155
-  #define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x));
156
-  #define LCD_ALERTMESSAGEPGM(x) lcd_alertstatuspgm(MYPGM(x));
159
+  #define LCD_MESSAGEPGM(x) lcd_statuspgm(PSTR(x));
160
+  #define LCD_ALERTMESSAGEPGM(x) lcd_alertstatuspgm(PSTR(x));
157 161
   #define LCD_STATUS lcd_status()
158 162
 #else //no lcd
159 163
   #define LCD_INIT
@@ -178,4 +182,14 @@ char *itostr31(const int &xx);
178 182
 char *itostr3(const int &xx);
179 183
 char *itostr4(const int &xx);
180 184
 char *ftostr51(const float &x);
185
+
186
+//TODO: These do not belong here.
187
+extern int plaPreheatHotendTemp;
188
+extern int plaPreheatHPBTemp;
189
+extern int plaPreheatFanSpeed;
190
+
191
+extern int absPreheatHotendTemp;
192
+extern int absPreheatHPBTemp;
193
+extern int absPreheatFanSpeed;
194
+
181 195
 #endif //ULTRALCD

+ 54
- 0
Marlin/watchdog.cpp Näytä tiedosto

@@ -0,0 +1,54 @@
1
+#include "Marlin.h"
2
+
3
+#ifdef USE_WATCHDOG
4
+#include "watchdog.h"
5
+#include "ultralcd.h"
6
+
7
+//===========================================================================
8
+//=============================private variables  ============================
9
+//===========================================================================
10
+
11
+//===========================================================================
12
+//=============================functinos         ============================
13
+//===========================================================================
14
+
15
+
16
+/// intialise watch dog with a 1 sec interrupt time
17
+void watchdog_init()
18
+{
19
+#ifdef RESET_MANUAL
20
+    //We enable the watchdog timer, but only for the interrupt.
21
+    //Take care, as this requires the correct order of operation, with interrupts disabled. See the datasheet of any AVR chip for details.
22
+    wdt_reset();
23
+    _WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE);
24
+    _WD_CONTROL_REG = _BV(WDIE) | WDTO_1S;
25
+#else
26
+    wdt_enable(WDTO_1S);
27
+#endif
28
+}
29
+
30
+/// reset watchdog. MUST be called every 1s after init or avr will reset.
31
+void watchdog_reset() 
32
+{
33
+  wdt_reset();
34
+}
35
+
36
+//===========================================================================
37
+//=============================ISR               ============================
38
+//===========================================================================
39
+
40
+//Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled.
41
+#ifdef RESET_MANUAL
42
+ISR(WDT_vect)
43
+{ 
44
+    LCD_MESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display
45
+    LCD_STATUS;
46
+    SERIAL_ERROR_START;
47
+    SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
48
+
49
+    kill(); //kill blocks
50
+    while(1); //wait for user or serial reset
51
+}
52
+#endif//RESET_MANUAL
53
+
54
+#endif//USE_WATCHDOG

+ 8
- 7
Marlin/watchdog.h Näytä tiedosto

@@ -1,16 +1,17 @@
1 1
 #ifndef WATCHDOG_H
2 2
 #define WATCHDOG_H
3
+
3 4
 #include "Marlin.h"
4
-#ifdef USE_WATCHDOG
5 5
 
6
+#ifdef USE_WATCHDOG
6 7
   // intialise watch dog with a 1 sec interrupt time
7
-  void wd_init();
8
-  // pad the dog/reset watchdog. MUST be called at least every second after the first wd_init or avr will go into emergency procedures..
9
-  void wd_reset();
10
-
8
+  void watchdog_init();
9
+  // pad the dog/reset watchdog. MUST be called at least every second after the first watchdog_init or avr will go into emergency procedures..
10
+  void watchdog_reset();
11 11
 #else
12
-  FORCE_INLINE void wd_init() {};
13
-  FORCE_INLINE void wd_reset() {};
12
+  //If we do not have a watchdog, then we can have empty functions which are optimized away.
13
+  FORCE_INLINE void watchdog_init() {};
14
+  FORCE_INLINE void watchdog_reset() {};
14 15
 #endif
15 16
 
16 17
 #endif

+ 0
- 63
Marlin/watchdog.pde Näytä tiedosto

@@ -1,63 +0,0 @@
1
-#ifdef USE_WATCHDOG
2
-#include "Marlin.h"
3
-#include "watchdog.h"
4
-
5
-//===========================================================================
6
-//=============================private variables  ============================
7
-//===========================================================================
8
-
9
-static volatile uint8_t timeout_seconds=0;
10
-
11
-void(* ctrlaltdelete) (void) = 0; //does not work on my atmega2560
12
-
13
-//===========================================================================
14
-//=============================functinos         ============================
15
-//===========================================================================
16
-
17
-
18
-/// intialise watch dog with a 1 sec interrupt time
19
-void wd_init() 
20
-{
21
-  WDTCSR |= (1<<WDCE )|(1<<WDE ); //allow changes
22
-  WDTCSR = (1<<WDCE )|(1<<WDE )|(1<<WDP3 )|(1<<WDP0); // Reset after 8 sec.
23
-//  WDTCSR = (1<<WDIF)|(1<<WDIE)| (1<<WDCE )|(1<<WDE )|  (1<<WDP3) | (1<<WDP0);
24
-}
25
-
26
-/// reset watchdog. MUST be called every 1s after init or avr will reset.
27
-void wd_reset() 
28
-{
29
-  wdt_reset();
30
-}
31
-
32
-//===========================================================================
33
-//=============================ISR               ============================
34
-//===========================================================================
35
-
36
-//Watchdog timer interrupt, called if main program blocks >1sec
37
-ISR(WDT_vect) 
38
-{ 
39
-  if(timeout_seconds++ >= WATCHDOG_TIMEOUT)
40
-  {
41
- 
42
-    #ifdef RESET_MANUAL
43
-      LCD_MESSAGEPGM("Please Reset!");
44
-      LCD_STATUS;
45
-      SERIAL_ERROR_START;
46
-      SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
47
-    #else
48
-      LCD_MESSAGEPGM("Timeout, resetting!");
49
-      LCD_STATUS;
50
-    #endif 
51
-    //disable watchdog, it will survife reboot.
52
-    WDTCSR |= (1<<WDCE) | (1<<WDE);
53
-    WDTCSR = 0;
54
-    #ifdef RESET_MANUAL
55
-      kill(); //kill blocks
56
-      while(1); //wait for user or serial reset
57
-    #else
58
-      ctrlaltdelete();
59
-    #endif
60
-  }
61
-}
62
-
63
-#endif /* USE_WATCHDOG */

Loading…
Peruuta
Tallenna