Parcourir la source

Merge pull request #159 from MaikStohn/Marlin_v1

Marlin v1 - BUG FIXES / CORRECTIONS
ErikZalm il y a 13 ans
Parent
révision
b2a9ccdb97
3 fichiers modifiés avec 60 ajouts et 52 suppressions
  1. 3
    2
      Marlin/Marlin.pde
  2. 6
    4
      Marlin/ultralcd.h
  3. 51
    46
      Marlin/ultralcd.pde

+ 3
- 2
Marlin/Marlin.pde Voir le fichier

300
   st_init();    // Initialize stepper;
300
   st_init();    // Initialize stepper;
301
   wd_init();
301
   wd_init();
302
   setup_photpin();
302
   setup_photpin();
303
+  
304
+  LCD_INIT;
303
 }
305
 }
304
 
306
 
305
 
307
 
687
         st_synchronize();
689
         st_synchronize();
688
       for(int8_t i=0; i < NUM_AXIS; i++) {
690
       for(int8_t i=0; i < NUM_AXIS; i++) {
689
         if(code_seen(axis_codes[i])) { 
691
         if(code_seen(axis_codes[i])) { 
690
-           current_position[i] = code_value()+add_homeing[i];  
691
            if(i == E_AXIS) {
692
            if(i == E_AXIS) {
692
              current_position[i] = code_value();  
693
              current_position[i] = code_value();  
693
              plan_set_e_position(current_position[E_AXIS]);
694
              plan_set_e_position(current_position[E_AXIS]);
1246
      }
1247
      }
1247
     break;
1248
     break;
1248
       
1249
       
1249
-    case 302: // finish all moves
1250
+    case 302: // allow cold extrudes
1250
     {
1251
     {
1251
       allow_cold_extrudes(true);
1252
       allow_cold_extrudes(true);
1252
     }
1253
     }

+ 6
- 4
Marlin/ultralcd.h Voir le fichier

7
   void lcd_init();
7
   void lcd_init();
8
   void lcd_status(const char* message);
8
   void lcd_status(const char* message);
9
   void beep();
9
   void beep();
10
+  void buttons_init();
10
   void buttons_check();
11
   void buttons_check();
11
 
12
 
12
   #define LCD_UPDATE_INTERVAL 100
13
   #define LCD_UPDATE_INTERVAL 100
69
     void showAxisMove();
70
     void showAxisMove();
70
     void showSD();
71
     void showSD();
71
     bool force_lcd_update;
72
     bool force_lcd_update;
72
-    int lastencoderpos;
73
+    long lastencoderpos;
73
     int8_t lineoffset;
74
     int8_t lineoffset;
74
     int8_t lastlineoffset;
75
     int8_t lastlineoffset;
75
     
76
     
78
     bool tune;
79
     bool tune;
79
     
80
     
80
   private:
81
   private:
81
-    FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
82
+    FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile long &encoderpos)
82
     {
83
     {
83
       if(linechanging) return; // an item is changint its value, do not switch lines hence
84
       if(linechanging) return; // an item is changint its value, do not switch lines hence
84
       lastlineoffset=lineoffset; 
85
       lastlineoffset=lineoffset; 
85
-      int curencoderpos=encoderpos;  
86
+      long curencoderpos=encoderpos;  
86
       force_lcd_update=false;
87
       force_lcd_update=false;
87
       if(  (abs(curencoderpos-lastencoderpos)<lcdslow) ) 
88
       if(  (abs(curencoderpos-lastencoderpos)<lcdslow) ) 
88
       { 
89
       { 
134
   char *ftostr3(const float &x);
135
   char *ftostr3(const float &x);
135
 
136
 
136
 
137
 
137
-
138
+  #define LCD_INIT lcd_init();
138
   #define LCD_MESSAGE(x) lcd_status(x);
139
   #define LCD_MESSAGE(x) lcd_status(x);
139
   #define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x));
140
   #define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x));
140
   #define LCD_STATUS lcd_status()
141
   #define LCD_STATUS lcd_status()
141
 #else //no lcd
142
 #else //no lcd
143
+  #define LCD_INIT
142
   #define LCD_STATUS
144
   #define LCD_STATUS
143
   #define LCD_MESSAGE(x)
145
   #define LCD_MESSAGE(x)
144
   #define LCD_MESSAGEPGM(x)
146
   #define LCD_MESSAGEPGM(x)

+ 51
- 46
Marlin/ultralcd.pde Voir le fichier

1
 #include "ultralcd.h"
1
 #include "ultralcd.h"
2
 #ifdef ULTRA_LCD
2
 #ifdef ULTRA_LCD
3
 #include "Marlin.h"
3
 #include "Marlin.h"
4
+#include "language.h"
5
+#include "temperature.h"
6
+#include "EEPROMwrite.h"
4
 #include <LiquidCrystal.h>
7
 #include <LiquidCrystal.h>
5
 //===========================================================================
8
 //===========================================================================
6
 //=============================imported variables============================
9
 //=============================imported variables============================
13
 
16
 
14
 extern long position[4];   
17
 extern long position[4];   
15
 #ifdef SDSUPPORT
18
 #ifdef SDSUPPORT
19
+#include "cardreader.h"
16
 extern CardReader card;
20
 extern CardReader card;
17
 #endif
21
 #endif
18
 
22
 
20
 //=============================public variables============================
24
 //=============================public variables============================
21
 //===========================================================================
25
 //===========================================================================
22
 volatile char buttons=0;  //the last checked buttons in a bit array.
26
 volatile char buttons=0;  //the last checked buttons in a bit array.
23
-int encoderpos=0;
27
+long encoderpos=0;
24
 short lastenc=0;
28
 short lastenc=0;
25
 
29
 
26
 
30
 
95
 void lcd_init()
99
 void lcd_init()
96
 {
100
 {
97
   //beep();
101
   //beep();
102
+  #ifdef ULTIPANEL
103
+    buttons_init();
104
+  #endif
98
   
105
   
99
   byte Degree[8] =
106
   byte Degree[8] =
100
   {
107
   {
302
   displayStartingRow=0;
309
   displayStartingRow=0;
303
   activeline=0;
310
   activeline=0;
304
   force_lcd_update=true;
311
   force_lcd_update=true;
305
-  #ifdef ULTIPANEL
306
-    buttons_init();
307
-  #endif
308
-  lcd_init();
309
   linechanging=false;
312
   linechanging=false;
310
   tune=false;
313
   tune=false;
311
 }
314
 }
881
       if(force_lcd_update)
884
       if(force_lcd_update)
882
         {
885
         {
883
           lcd.setCursor(0,line);lcdprintPGM(MSG_FLOW);
886
           lcd.setCursor(0,line);lcdprintPGM(MSG_FLOW);
884
-          lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3]));
887
+          lcd.setCursor(13,line);lcd.print(ftostr52(axis_steps_per_unit[E_AXIS]));
885
         }
888
         }
886
         
889
         
887
         if((activeline!=line) )
890
         if((activeline!=line) )
892
           linechanging=!linechanging;
895
           linechanging=!linechanging;
893
           if(linechanging)
896
           if(linechanging)
894
           {
897
           {
895
-              encoderpos=(int)axis_steps_per_unit[3];
898
+              encoderpos=(long)(axis_steps_per_unit[E_AXIS]*100.0);
896
           }
899
           }
897
           else
900
           else
898
           {
901
           {
899
-            float factor=float(encoderpos)/float(axis_steps_per_unit[3]);
902
+            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS]);
900
             position[E_AXIS]=lround(position[E_AXIS]*factor);
903
             position[E_AXIS]=lround(position[E_AXIS]*factor);
901
-            //current_position[3]*=factor;
902
-            axis_steps_per_unit[E_AXIS]= encoderpos;
904
+            //current_position[E_AXIS]*=factor;
905
+            axis_steps_per_unit[E_AXIS]= encoderpos/100.0;
903
             encoderpos=activeline*lcdslow;
906
             encoderpos=activeline*lcdslow;
904
               
907
               
905
           }
908
           }
909
         if(linechanging)
912
         if(linechanging)
910
         {
913
         {
911
           if(encoderpos<5) encoderpos=5;
914
           if(encoderpos<5) encoderpos=5;
912
-          if(encoderpos>9999) encoderpos=9999;
913
-          lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
915
+          if(encoderpos>999999) encoderpos=999999;
916
+          lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/100.0));
914
         }
917
         }
915
         
918
         
916
       }break; 
919
       }break; 
1293
           linechanging=!linechanging;
1296
           linechanging=!linechanging;
1294
           if(linechanging)
1297
           if(linechanging)
1295
           {
1298
           {
1296
-              encoderpos=(int)Kp;
1299
+              encoderpos=(long)Kp;
1297
           }
1300
           }
1298
           else
1301
           else
1299
           {
1302
           {
1328
           linechanging=!linechanging;
1331
           linechanging=!linechanging;
1329
           if(linechanging)
1332
           if(linechanging)
1330
           {
1333
           {
1331
-              encoderpos=(int)(Ki*10/PID_dT);
1334
+              encoderpos=(long)(Ki*10/PID_dT);
1332
           }
1335
           }
1333
           else
1336
           else
1334
           {
1337
           {
1364
           linechanging=!linechanging;
1367
           linechanging=!linechanging;
1365
           if(linechanging)
1368
           if(linechanging)
1366
           {
1369
           {
1367
-              encoderpos=(int)(Kd/5./PID_dT);
1370
+              encoderpos=(long)(Kd/5./PID_dT);
1368
           }
1371
           }
1369
           else
1372
           else
1370
           {
1373
           {
1400
           linechanging=!linechanging;
1403
           linechanging=!linechanging;
1401
           if(linechanging)
1404
           if(linechanging)
1402
           {
1405
           {
1403
-              encoderpos=(int)Kc;
1406
+              encoderpos=(long)Kc;
1404
           }
1407
           }
1405
           else
1408
           else
1406
           {
1409
           {
1473
           linechanging=!linechanging;
1476
           linechanging=!linechanging;
1474
           if(linechanging)
1477
           if(linechanging)
1475
           {
1478
           {
1476
-              encoderpos=(int)acceleration/100;
1479
+              encoderpos=(long)acceleration/100;
1477
           }
1480
           }
1478
           else
1481
           else
1479
           {
1482
           {
1507
           linechanging=!linechanging;
1510
           linechanging=!linechanging;
1508
           if(linechanging)
1511
           if(linechanging)
1509
           {
1512
           {
1510
-              encoderpos=(int)max_xy_jerk;
1513
+              encoderpos=(long)max_xy_jerk;
1511
           }
1514
           }
1512
           else
1515
           else
1513
           {
1516
           {
1550
           linechanging=!linechanging;
1553
           linechanging=!linechanging;
1551
           if(linechanging)
1554
           if(linechanging)
1552
           {
1555
           {
1553
-              encoderpos=(int)max_feedrate[i-ItemCM_vmaxx];
1556
+              encoderpos=(long)max_feedrate[i-ItemCM_vmaxx];
1554
           }
1557
           }
1555
           else
1558
           else
1556
           {
1559
           {
1586
           linechanging=!linechanging;
1589
           linechanging=!linechanging;
1587
           if(linechanging)
1590
           if(linechanging)
1588
           {
1591
           {
1589
-              encoderpos=(int)(minimumfeedrate);
1592
+              encoderpos=(long)(minimumfeedrate);
1590
           }
1593
           }
1591
           else
1594
           else
1592
           {
1595
           {
1621
           linechanging=!linechanging;
1624
           linechanging=!linechanging;
1622
           if(linechanging)
1625
           if(linechanging)
1623
           {
1626
           {
1624
-              encoderpos=(int)mintravelfeedrate;
1627
+              encoderpos=(long)mintravelfeedrate;
1625
           }
1628
           }
1626
           else
1629
           else
1627
           {
1630
           {
1664
           linechanging=!linechanging;
1667
           linechanging=!linechanging;
1665
           if(linechanging)
1668
           if(linechanging)
1666
           {
1669
           {
1667
-              encoderpos=(int)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100;
1670
+              encoderpos=(long)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100;
1668
           }
1671
           }
1669
           else
1672
           else
1670
           {
1673
           {
1698
           linechanging=!linechanging;
1701
           linechanging=!linechanging;
1699
           if(linechanging)
1702
           if(linechanging)
1700
           {
1703
           {
1701
-              encoderpos=(int)retract_acceleration/100;
1704
+              encoderpos=(long)retract_acceleration/100;
1702
           }
1705
           }
1703
           else
1706
           else
1704
           {
1707
           {
1722
       if(force_lcd_update)
1725
       if(force_lcd_update)
1723
         {
1726
         {
1724
           lcd.setCursor(0,line);lcdprintPGM(MSG_XSTEPS);
1727
           lcd.setCursor(0,line);lcdprintPGM(MSG_XSTEPS);
1725
-          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[0]));
1728
+          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[X_AXIS]));
1726
         }
1729
         }
1727
         
1730
         
1728
         if((activeline!=line) )
1731
         if((activeline!=line) )
1733
           linechanging=!linechanging;
1736
           linechanging=!linechanging;
1734
           if(linechanging)
1737
           if(linechanging)
1735
           {
1738
           {
1736
-              encoderpos=(int)(axis_steps_per_unit[0]*100.0);
1739
+              encoderpos=(long)(axis_steps_per_unit[X_AXIS]*100.0);
1737
           }
1740
           }
1738
           else
1741
           else
1739
           {
1742
           {
1740
-            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[0]);
1743
+            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[X_AXIS]);
1741
             position[X_AXIS]=lround(position[X_AXIS]*factor);
1744
             position[X_AXIS]=lround(position[X_AXIS]*factor);
1742
-            //current_position[3]*=factor;
1745
+            //current_position[X_AXIS]*=factor;
1743
             axis_steps_per_unit[X_AXIS]= encoderpos/100.0;
1746
             axis_steps_per_unit[X_AXIS]= encoderpos/100.0;
1744
             encoderpos=activeline*lcdslow;
1747
             encoderpos=activeline*lcdslow;
1745
           }
1748
           }
1749
         if(linechanging)
1752
         if(linechanging)
1750
         {
1753
         {
1751
           if(encoderpos<5) encoderpos=5;
1754
           if(encoderpos<5) encoderpos=5;
1752
-          if(encoderpos>32000) encoderpos=32000;//TODO: This is a problem, encoderpos is 16bit, but steps_per_unit for e can be wel over 800
1755
+          if(encoderpos>999999) encoderpos=999999;
1753
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1756
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1754
         }
1757
         }
1755
         
1758
         
1759
       if(force_lcd_update)
1762
       if(force_lcd_update)
1760
         {
1763
         {
1761
           lcd.setCursor(0,line);lcdprintPGM(MSG_YSTEPS);
1764
           lcd.setCursor(0,line);lcdprintPGM(MSG_YSTEPS);
1762
-          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[1]));
1765
+          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Y_AXIS]));
1763
         }
1766
         }
1764
         
1767
         
1765
         if((activeline!=line) )
1768
         if((activeline!=line) )
1770
           linechanging=!linechanging;
1773
           linechanging=!linechanging;
1771
           if(linechanging)
1774
           if(linechanging)
1772
           {
1775
           {
1773
-              encoderpos=(int)(axis_steps_per_unit[1]*100.0);
1776
+              encoderpos=(long)(axis_steps_per_unit[Y_AXIS]*100.0);
1774
           }
1777
           }
1775
           else
1778
           else
1776
           {
1779
           {
1777
-            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[1]);
1780
+            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Y_AXIS]);
1778
             position[Y_AXIS]=lround(position[Y_AXIS]*factor);
1781
             position[Y_AXIS]=lround(position[Y_AXIS]*factor);
1779
-            //current_position[3]*=factor;
1782
+            //current_position[Y_AXIS]*=factor;
1780
             axis_steps_per_unit[Y_AXIS]= encoderpos/100.0;
1783
             axis_steps_per_unit[Y_AXIS]= encoderpos/100.0;
1781
             encoderpos=activeline*lcdslow;
1784
             encoderpos=activeline*lcdslow;
1782
               
1785
               
1787
         if(linechanging)
1790
         if(linechanging)
1788
         {
1791
         {
1789
           if(encoderpos<5) encoderpos=5;
1792
           if(encoderpos<5) encoderpos=5;
1790
-          if(encoderpos>9999) encoderpos=9999;
1793
+          if(encoderpos>999999) encoderpos=999999;
1791
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1794
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1792
         }
1795
         }
1793
         
1796
         
1797
       if(force_lcd_update)
1800
       if(force_lcd_update)
1798
         {
1801
         {
1799
           lcd.setCursor(0,line);lcdprintPGM(MSG_ZSTEPS);
1802
           lcd.setCursor(0,line);lcdprintPGM(MSG_ZSTEPS);
1800
-          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[2]));
1803
+          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Z_AXIS]));
1801
         }
1804
         }
1802
         
1805
         
1803
         if((activeline!=line) )
1806
         if((activeline!=line) )
1808
           linechanging=!linechanging;
1811
           linechanging=!linechanging;
1809
           if(linechanging)
1812
           if(linechanging)
1810
           {
1813
           {
1811
-              encoderpos=(int)(axis_steps_per_unit[2]*100.0);
1814
+              encoderpos=(long)(axis_steps_per_unit[Z_AXIS]*100.0);
1812
           }
1815
           }
1813
           else
1816
           else
1814
           {
1817
           {
1815
-            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[2]);
1818
+            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Z_AXIS]);
1816
             position[Z_AXIS]=lround(position[Z_AXIS]*factor);
1819
             position[Z_AXIS]=lround(position[Z_AXIS]*factor);
1817
-            //current_position[3]*=factor;
1820
+            //current_position[Z_AXIS]*=factor;
1818
             axis_steps_per_unit[Z_AXIS]= encoderpos/100.0;
1821
             axis_steps_per_unit[Z_AXIS]= encoderpos/100.0;
1819
             encoderpos=activeline*lcdslow;
1822
             encoderpos=activeline*lcdslow;
1820
               
1823
               
1825
         if(linechanging)
1828
         if(linechanging)
1826
         {
1829
         {
1827
           if(encoderpos<5) encoderpos=5;
1830
           if(encoderpos<5) encoderpos=5;
1828
-          if(encoderpos>9999) encoderpos=9999;
1831
+          if(encoderpos>999999) encoderpos=999999;
1829
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1832
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1830
         }
1833
         }
1831
         
1834
         
1836
       if(force_lcd_update)
1839
       if(force_lcd_update)
1837
         {
1840
         {
1838
           lcd.setCursor(0,line);lcdprintPGM(MSG_ESTEPS);
1841
           lcd.setCursor(0,line);lcdprintPGM(MSG_ESTEPS);
1839
-          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[3]));
1842
+          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[E_AXIS]));
1840
         }
1843
         }
1841
         
1844
         
1842
         if((activeline!=line) )
1845
         if((activeline!=line) )
1847
           linechanging=!linechanging;
1850
           linechanging=!linechanging;
1848
           if(linechanging)
1851
           if(linechanging)
1849
           {
1852
           {
1850
-              encoderpos=(int)(axis_steps_per_unit[3]*100.0);
1853
+              encoderpos=(long)(axis_steps_per_unit[E_AXIS]*100.0);
1851
           }
1854
           }
1852
           else
1855
           else
1853
           {
1856
           {
1854
-            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[3]);
1857
+            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS]);
1855
             position[E_AXIS]=lround(position[E_AXIS]*factor);
1858
             position[E_AXIS]=lround(position[E_AXIS]*factor);
1856
-            //current_position[3]*=factor;
1859
+            //current_position[E_AXIS]*=factor;
1857
             axis_steps_per_unit[E_AXIS]= encoderpos/100.0;
1860
             axis_steps_per_unit[E_AXIS]= encoderpos/100.0;
1858
             encoderpos=activeline*lcdslow;
1861
             encoderpos=activeline*lcdslow;
1859
               
1862
               
1864
         if(linechanging)
1867
         if(linechanging)
1865
         {
1868
         {
1866
           if(encoderpos<5) encoderpos=5;
1869
           if(encoderpos<5) encoderpos=5;
1867
-          if(encoderpos>9999) encoderpos=9999;
1870
+          if(encoderpos>999999) encoderpos=999999;
1868
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1871
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1869
         }
1872
         }
1870
         
1873
         
2105
     }
2108
     }
2106
   } 
2109
   } 
2107
   clearIfNecessary();
2110
   clearIfNecessary();
2108
-  for(int8_t line=0;line<LCD_HEIGHT;line++)
2111
+  uint8_t line=0;
2112
+  for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
2109
   {
2113
   {
2110
-    switch(line)
2114
+    switch(i)
2111
     { 
2115
     { 
2112
       case ItemM_watch:
2116
       case ItemM_watch:
2113
         MENUITEM(  lcdprintPGM(MSG_WATCH)  ,  BLOCK;status=Main_Status;beepshort(); ) ;
2117
         MENUITEM(  lcdprintPGM(MSG_WATCH)  ,  BLOCK;status=Main_Status;beepshort(); ) ;
2161
         SERIAL_ERRORLNPGM(MSG_SERIAL_ERROR_MENU_STRUCTURE);
2165
         SERIAL_ERRORLNPGM(MSG_SERIAL_ERROR_MENU_STRUCTURE);
2162
       break;
2166
       break;
2163
     }
2167
     }
2168
+    line++;
2164
   }
2169
   }
2165
   updateActiveLines(3,encoderpos);
2170
   updateActiveLines(3,encoderpos);
2166
 }
2171
 }
2378
 
2383
 
2379
 #endif //ULTRA_LCD
2384
 #endif //ULTRA_LCD
2380
 
2385
 
2381
-
2386
+

Chargement…
Annuler
Enregistrer