Browse Source

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

Erik van der Zalm 13 years ago
parent
commit
15bb3f284e
5 changed files with 450 additions and 454 deletions
  1. 4
    2
      Marlin/cardreader.h
  2. 80
    35
      Marlin/cardreader.pde
  3. 53
    2
      Marlin/ultralcd.h
  4. 306
    411
      Marlin/ultralcd.pde
  5. 7
    4
      README.md

+ 4
- 2
Marlin/cardreader.h View File

28
   
28
   
29
 
29
 
30
   void ls();
30
   void ls();
31
-  
31
+  void chdir(const char * relpath);
32
+  void updir();
32
 
33
 
33
   inline bool eof() { return sdpos>=filesize ;};
34
   inline bool eof() { return sdpos>=filesize ;};
34
   inline int16_t get() {  sdpos = file.curPosition();return (int16_t)file.read();};
35
   inline int16_t get() {  sdpos = file.curPosition();return (int16_t)file.read();};
40
   bool sdprinting ;  
41
   bool sdprinting ;  
41
   bool cardOK ;
42
   bool cardOK ;
42
   char filename[11];
43
   char filename[11];
44
+  bool filenameIsDir;
43
 private:
45
 private:
44
-  SdFile root,*curDir;
46
+  SdFile root,*curDir,workDir,workDirParent,workDirParentParent;
45
   Sd2Card card;
47
   Sd2Card card;
46
   SdVolume volume;
48
   SdVolume volume;
47
   SdFile file;
49
   SdFile file;

+ 80
- 35
Marlin/cardreader.pde View File

1
 #include "cardreader.h"
1
 #include "cardreader.h"
2
+//#include <unistd.h>
2
 #ifdef SDSUPPORT
3
 #ifdef SDSUPPORT
3
 
4
 
4
 CardReader::CardReader()
5
 CardReader::CardReader()
36
   return buffer;
37
   return buffer;
37
 }
38
 }
38
 
39
 
39
-// bool SdFat::chdir(bool set_cwd) {
40
-//   if (set_cwd) SdBaseFile::cwd_ = &vwd_;
41
-//   vwd_.close();
42
-//   return vwd_.openRoot(&vol_);
43
-// }
40
+
44
 void  CardReader::lsDive(char *prepend,SdFile parent)
41
 void  CardReader::lsDive(char *prepend,SdFile parent)
45
 {
42
 {
46
   dir_t p;
43
   dir_t p;
85
     {
82
     {
86
       if (p.name[0] == DIR_NAME_FREE) break;
83
       if (p.name[0] == DIR_NAME_FREE) break;
87
       if (p.name[0] == DIR_NAME_DELETED || p.name[0] == '.'|| p.name[0] == '_') continue;
84
       if (p.name[0] == DIR_NAME_DELETED || p.name[0] == '.'|| p.name[0] == '_') continue;
85
+      if ( p.name[0] == '.')
86
+      {
87
+        if ( p.name[1] != '.')
88
+        continue;
89
+      }
88
       if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
90
       if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
91
+      filenameIsDir=DIR_IS_SUBDIR(&p);
89
       
92
       
90
-      
91
-      if(p.name[8]!='G') continue;
92
-      if(p.name[9]=='~') continue;
93
+      if(!filenameIsDir)
94
+      {
95
+        if(p.name[8]!='G') continue;
96
+        if(p.name[9]=='~') continue;
97
+      }
93
       //if(cnt++!=nr) continue;
98
       //if(cnt++!=nr) continue;
94
       createFilename(filename,p);
99
       createFilename(filename,p);
95
       if(lsAction==LS_SerialPrint)
100
       if(lsAction==LS_SerialPrint)
126
 void CardReader::initsd()
131
 void CardReader::initsd()
127
 {
132
 {
128
   cardOK = false;
133
   cardOK = false;
129
-  #if SDSS >- 1
130
-    if(root.isOpen())
131
-      root.close();
132
-    if (!card.init(SPI_FULL_SPEED,SDSS))
133
-    {
134
-      //if (!card.init(SPI_HALF_SPEED,SDSS))
135
-      SERIAL_ECHO_START;
136
-      SERIAL_ECHOLNPGM("SD init fail");
137
-    }
138
-    else if (!volume.init(&card))
139
-    {
140
-      SERIAL_ERROR_START;
141
-      SERIAL_ERRORLNPGM("volume.init failed");
142
-    }
143
-    else if (!root.openRoot(&volume)) 
144
-    {
145
-      SERIAL_ERROR_START;
146
-      SERIAL_ERRORLNPGM("openRoot failed");
147
-    }
148
-    else 
149
-    {
150
-      cardOK = true;
151
-      SERIAL_ECHO_START;
152
-      SERIAL_ECHOLNPGM("SD card ok");
153
-    }
154
-    curDir=&root;
155
-  #endif //SDSS
134
+  if(root.isOpen())
135
+    root.close();
136
+  if (!card.init(SPI_FULL_SPEED,SDSS))
137
+  {
138
+    //if (!card.init(SPI_HALF_SPEED,SDSS))
139
+    SERIAL_ECHO_START;
140
+    SERIAL_ECHOLNPGM("SD init fail");
141
+  }
142
+  else if (!volume.init(&card))
143
+  {
144
+    SERIAL_ERROR_START;
145
+    SERIAL_ERRORLNPGM("volume.init failed");
146
+  }
147
+  else if (!root.openRoot(&volume)) 
148
+  {
149
+    SERIAL_ERROR_START;
150
+    SERIAL_ERRORLNPGM("openRoot failed");
151
+  }
152
+  else 
153
+  {
154
+    cardOK = true;
155
+    SERIAL_ECHO_START;
156
+    SERIAL_ECHOLNPGM("SD card ok");
157
+  }
158
+  curDir=&root;
159
+  if(!workDir.openRoot(&volume))
160
+  {
161
+    SERIAL_ECHOLNPGM("workDir open failed");
162
+  }
156
 }
163
 }
157
 void CardReader::release()
164
 void CardReader::release()
158
 {
165
 {
229
       
236
       
230
     }
237
     }
231
   }
238
   }
239
+  else //relative path
240
+  {
241
+    curDir=&workDir;
242
+  }
232
   if(read)
243
   if(read)
233
   {
244
   {
234
     if (file.open(curDir, fname, O_READ)) 
245
     if (file.open(curDir, fname, O_READ)) 
362
 
373
 
363
 void CardReader::getfilename(const uint8_t nr)
374
 void CardReader::getfilename(const uint8_t nr)
364
 {
375
 {
376
+  curDir=&workDir;
365
   lsAction=LS_GetFilename;
377
   lsAction=LS_GetFilename;
366
   nrFiles=nr;
378
   nrFiles=nr;
367
   curDir->rewind();
379
   curDir->rewind();
371
 
383
 
372
 uint16_t CardReader::getnrfilenames()
384
 uint16_t CardReader::getnrfilenames()
373
 {
385
 {
386
+  curDir=&workDir;
374
   lsAction=LS_Count;
387
   lsAction=LS_Count;
375
   nrFiles=0;
388
   nrFiles=0;
376
   curDir->rewind();
389
   curDir->rewind();
377
   lsDive("",*curDir);
390
   lsDive("",*curDir);
391
+  //SERIAL_ECHOLN(nrFiles);
378
   return nrFiles;
392
   return nrFiles;
379
 }
393
 }
380
 
394
 
395
+void CardReader::chdir(const char * relpath)
396
+{
397
+  SdFile newfile;
398
+  SdFile *parent=&root;
399
+  
400
+  if(workDir.isOpen())
401
+    parent=&workDir;
402
+  
403
+  if(!newfile.open(*parent,relpath, O_READ))
404
+  {
405
+   SERIAL_ECHO_START;
406
+   SERIAL_ECHOPGM("Cannot enter subdir:");
407
+   SERIAL_ECHOLN(relpath);
408
+  }
409
+  else
410
+  {
411
+    workDirParentParent=workDirParent;
412
+    workDirParent=*parent;
413
+    
414
+    workDir=newfile;
415
+  }
416
+}
417
+
418
+void CardReader::updir()
419
+{
420
+  if(!workDir.isRoot())
421
+  {
422
+    workDir=workDirParent;
423
+    workDirParent=workDirParentParent;
424
+  }
425
+}
381
 
426
 
382
 #endif //SDSUPPORT
427
 #endif //SDSUPPORT

+ 53
- 2
Marlin/ultralcd.h View File

51
   #define blocktime 500
51
   #define blocktime 500
52
   #define lcdslow 5
52
   #define lcdslow 5
53
     
53
     
54
-  enum MainStatus{Main_Status, Main_Menu, Main_Prepare, Main_Control, Main_SD};
54
+  enum MainStatus{Main_Status, Main_Menu, Main_Prepare, Main_Control, Main_SD,Sub_TempControl,Sub_MotionControl};
55
 
55
 
56
   class MainMenu{
56
   class MainMenu{
57
   public:
57
   public:
58
     MainMenu();
58
     MainMenu();
59
     void update();
59
     void update();
60
-    uint8_t activeline;
60
+    int8_t activeline;
61
     MainStatus status;
61
     MainStatus status;
62
     uint8_t displayStartingRow;
62
     uint8_t displayStartingRow;
63
     
63
     
65
     void showMainMenu();
65
     void showMainMenu();
66
     void showPrepare();
66
     void showPrepare();
67
     void showControl();
67
     void showControl();
68
+    void showControlMotion();
69
+    void showControlTemp();
68
     void showSD();
70
     void showSD();
69
     bool force_lcd_update;
71
     bool force_lcd_update;
70
     int lastencoderpos;
72
     int lastencoderpos;
72
     int8_t lastlineoffset;
74
     int8_t lastlineoffset;
73
     
75
     
74
     bool linechanging;
76
     bool linechanging;
77
+    
78
+  private:
79
+    inline void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
80
+    {
81
+      if(linechanging) return; // an item is changint its value, do not switch lines hence
82
+      lastlineoffset=lineoffset; 
83
+      int curencoderpos=encoderpos;  
84
+      force_lcd_update=false;
85
+      if(  (abs(curencoderpos-lastencoderpos)<lcdslow) ) 
86
+      { 
87
+        lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?' ':' '); 
88
+        if(curencoderpos<0)  
89
+        {  
90
+          lineoffset--; 
91
+          if(lineoffset<0) lineoffset=0; 
92
+          curencoderpos=lcdslow-1; 
93
+          force_lcd_update=true; 
94
+        } 
95
+        if(curencoderpos>(LCD_HEIGHT-1+1)*lcdslow) 
96
+        { 
97
+          lineoffset++; 
98
+          curencoderpos=(LCD_HEIGHT-1)*lcdslow; 
99
+          if(lineoffset>(maxlines+1-LCD_HEIGHT)) 
100
+            lineoffset=maxlines+1-LCD_HEIGHT; 
101
+          if(curencoderpos>maxlines*lcdslow) 
102
+            curencoderpos=maxlines*lcdslow; 
103
+          force_lcd_update=true; 
104
+        } 
105
+        lastencoderpos=encoderpos=curencoderpos; 
106
+        activeline=curencoderpos/lcdslow;
107
+        if(activeline<0) activeline=0;
108
+        if(activeline>LCD_HEIGHT-1) activeline=LCD_HEIGHT-1;
109
+        if(activeline>maxlines) 
110
+        {
111
+          activeline=maxlines;
112
+          curencoderpos=maxlines*lcdslow;
113
+        }
114
+        lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?'>':'\003');    
115
+      } 
116
+    }
117
+    
118
+    inline void clearIfNecessary()
119
+    {
120
+      if(lastlineoffset!=lineoffset ||force_lcd_update)
121
+      {
122
+        force_lcd_update=true;
123
+         lcd.clear();
124
+      } 
125
+    }
75
   };
126
   };
76
 
127
 
77
   //conversion routines, could need some overworking
128
   //conversion routines, could need some overworking

+ 306
- 411
Marlin/ultralcd.pde
File diff suppressed because it is too large
View File


+ 7
- 4
README.md View File

54
 It leads to less over-deposition at corners, especially at flat angles.
54
 It leads to less over-deposition at corners, especially at flat angles.
55
 
55
 
56
 *Arc support:*
56
 *Arc support:*
57
+
57
 Splic3r can find curves that, although broken into segments, were ment to describe an arc.
58
 Splic3r can find curves that, although broken into segments, were ment to describe an arc.
58
 Marlin is able to print those arcs. The advantage is the firmware can choose the resolution,
59
 Marlin is able to print those arcs. The advantage is the firmware can choose the resolution,
59
 and can perform the arc with nearly constant velocity, resulting in a nice finish. 
60
 and can perform the arc with nearly constant velocity, resulting in a nice finish. 
118
 
119
 
119
 Non-standard M-Codes, different to an old version of sprinter:
120
 Non-standard M-Codes, different to an old version of sprinter:
120
 ==============================================================
121
 ==============================================================
122
+Movement:
123
+
121
 *   G2  - CW ARC
124
 *   G2  - CW ARC
122
 *   G3  - CCW ARC
125
 *   G3  - CCW ARC
123
 
126
 
124
 General:
127
 General:
125
 
128
 
126
-*   M17  - Enable/Power all stepper motors
127
-*   M18  - Disable all stepper motors; same as M84
129
+*   M17  - Enable/Power all stepper motors. Compatibility to ReplicatorG.
130
+*   M18  - Disable all stepper motors; same as M84.Compatibility to ReplicatorG.
128
 *   M30  - Print time since last M109 or SD card start to serial
131
 *   M30  - Print time since last M109 or SD card start to serial
129
 *   M42  - Change pin status via gcode
132
 *   M42  - Change pin status via gcode
130
 *   M80  - Turn on Power Supply
133
 *   M80  - Turn on Power Supply
137
 *   M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!!
140
 *   M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!!
138
 *   M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec
141
 *   M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec
139
 *   M204 - Set default acceleration: S normal moves T filament only moves (M204 S3000 T7000) im mm/sec^2  also sets minimum segment time in ms (B20000) to prevent buffer underruns and M20 minimum feedrate
142
 *   M204 - Set default acceleration: S normal moves T filament only moves (M204 S3000 T7000) im mm/sec^2  also sets minimum segment time in ms (B20000) to prevent buffer underruns and M20 minimum feedrate
140
-*   M220 - set build speed factor override percentage S:factor in percent ; aka "realtime tuneing in the gcode"
143
+*   M220 - set build speed mulitplying S:factor in percent ; aka "realtime tuneing in the gcode". So you can slow down if you have islands in one height-range, and speed up otherwise.
141
 *   M301 - Set PID parameters P I and D
144
 *   M301 - Set PID parameters P I and D
142
-*   M400 - Finish all moves
145
+*   M400 - Finish all buffered moves.
143
 
146
 
144
 Advance:
147
 Advance:
145
 
148
 

Loading…
Cancel
Save