Bladeren bron

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

Erik van der Zalm 13 jaren geleden
bovenliggende
commit
6e6fdb9a4e
8 gewijzigde bestanden met toevoegingen van 237 en 488 verwijderingen
  1. 2
    2
      Marlin/Configuration.h
  2. 13
    2
      Marlin/Marlin.pde
  3. 0
    329
      Marlin/SdFat.cpp
  4. 0
    76
      Marlin/SdFat.h
  5. 15
    10
      Marlin/cardreader.h
  6. 187
    61
      Marlin/cardreader.pde
  7. 13
    7
      Marlin/planner.cpp
  8. 7
    1
      Marlin/planner.h

+ 2
- 2
Marlin/Configuration.h Bestand weergeven

@@ -204,7 +204,7 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
204 204
 
205 205
 // default settings 
206 206
 
207
-#define DEFAULT_AXIS_STEPS_PER_UNIT   {79.87220447,79.87220447,200*8/3,760*1.1}                    // default steps per unit for ultimaker 
207
+#define DEFAULT_AXIS_STEPS_PER_UNIT   {78.7402,78.7402,200*8/3,760*1.1}                    // default steps per unit for ultimaker 
208 208
 //#define DEFAULT_AXIS_STEPS_PER_UNIT   {40, 40, 3333.92, 67} 
209 209
 #define DEFAULT_MAX_FEEDRATE          {500, 500, 5, 200000}    // (mm/sec)    
210 210
 #define DEFAULT_MAX_ACCELERATION      {9000,9000,100,10000}    // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.
@@ -274,7 +274,7 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
274 274
 
275 275
 #define ULTIPANEL
276 276
 #ifdef ULTIPANEL
277
-//  #define NEWPANEL  //enable this if you have a click-encoder panel
277
+  //#define NEWPANEL  //enable this if you have a click-encoder panel
278 278
   #define SDSUPPORT
279 279
   #define ULTRA_LCD
280 280
   #define LCD_WIDTH 20

+ 13
- 2
Marlin/Marlin.pde Bestand weergeven

@@ -176,6 +176,7 @@ static unsigned long stoptime=0;
176 176
 //=============================ROUTINES=============================
177 177
 //===========================================================================
178 178
 
179
+void get_arc_coordinates();
179 180
 
180 181
 extern "C"{
181 182
   extern unsigned int __bss_end;
@@ -588,7 +589,7 @@ inline void process_commands()
588 589
       starpos = (strchr(strchr_pointer + 4,'*'));
589 590
       if(starpos!=NULL)
590 591
         *(starpos-1)='\0';
591
-      card.selectFile(strchr_pointer + 4);
592
+      card.openFile(strchr_pointer + 4,true);
592 593
       break;
593 594
     case 24: //M24 - Start SD print
594 595
       card.startFileprint();
@@ -613,7 +614,7 @@ inline void process_commands()
613 614
         strchr_pointer = strchr(npos,' ') + 1;
614 615
         *(starpos-1) = '\0';
615 616
       }
616
-      card.startFilewrite(strchr_pointer+4);
617
+      card.openFile(strchr_pointer+4,false);
617 618
       
618 619
       break;
619 620
     case 29: //M29 - Stop SD write
@@ -694,7 +695,17 @@ inline void process_commands()
694 695
     case 109: 
695 696
     {// M109 - Wait for extruder heater to reach target.
696 697
         LCD_MESSAGEPGM("Heating...");
698
+        autotemp_enabled=false;
697 699
         if (code_seen('S')) setTargetHotend0(code_value());
700
+        #ifdef AUTOTEMP
701
+          if (code_seen('S')) autotemp_min=code_value();
702
+          if (code_seen('T')) autotemp_max=code_value();
703
+          if (code_seen('F')) 
704
+          {
705
+            autotemp_factor=code_value();
706
+            autotemp_enabled=true;
707
+          }
708
+        #endif
698 709
         
699 710
         setWatch();
700 711
         codenum = millis(); 

+ 0
- 329
Marlin/SdFat.cpp Bestand weergeven

@@ -1,329 +0,0 @@
1
-/* Arduino SdFat Library
2
- * Copyright (C) 2009 by William Greiman
3
- *
4
- * This file is part of the Arduino SdFat Library
5
- *
6
- * This Library is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This Library is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with the Arduino SdFat Library.  If not, see
18
- * <http://www.gnu.org/licenses/>.
19
- */
20
-#include "SdFat.h"
21
-#include "SdFatUtil.h"
22
-//------------------------------------------------------------------------------
23
-/** Change a volume's working directory to root
24
- *
25
- * Changes the volume's working directory to the SD's root directory.
26
- * Optionally set the current working directory to the volume's
27
- * working directory.
28
- *
29
- * \param[in] set_cwd Set the current working directory to this volume's
30
- *  working directory if true.
31
- *
32
- * \return The value one, true, is returned for success and
33
- * the value zero, false, is returned for failure.
34
- */
35
-bool SdFat::chdir(bool set_cwd) {
36
-  if (set_cwd) SdBaseFile::cwd_ = &vwd_;
37
-  vwd_.close();
38
-  return vwd_.openRoot(&vol_);
39
-}
40
-//------------------------------------------------------------------------------
41
-/** Change a volume's working directory
42
- *
43
- * Changes the volume working directory to the \a path subdirectory.
44
- * Optionally set the current working directory to the volume's
45
- * working directory.
46
- *
47
- * Example: If the volume's working directory is "/DIR", chdir("SUB")
48
- * will change the volume's working directory from "/DIR" to "/DIR/SUB".
49
- *
50
- * If path is "/", the volume's working directory will be changed to the
51
- * root directory
52
- *
53
- * \param[in] path The name of the subdirectory.
54
- *
55
- * \param[in] set_cwd Set the current working directory to this volume's
56
- *  working directory if true.
57
- *
58
- * \return The value one, true, is returned for success and
59
- * the value zero, false, is returned for failure.
60
- */
61
-bool SdFat::chdir(const char *path, bool set_cwd) {
62
-  SdBaseFile dir;
63
-  if (path[0] == '/' && path[1] == '\0') return chdir(set_cwd);
64
-  if (!dir.open(&vwd_, path, O_READ)) goto fail;
65
-  if (!dir.isDir()) goto fail;
66
-  vwd_ = dir;
67
-  if (set_cwd) SdBaseFile::cwd_ = &vwd_;
68
-  return true;
69
-
70
- fail:
71
-  return false;
72
-}
73
-//------------------------------------------------------------------------------
74
-/** Set the current working directory to a volume's working directory.
75
- *
76
- * This is useful with multiple SD cards.
77
- *
78
- * The current working directory is changed to this volume's working directory.
79
- *
80
- * This is like the Windows/DOS \<drive letter>: command.
81
- */
82
-void SdFat::chvol() {
83
-  SdBaseFile::cwd_ = &vwd_;
84
-}
85
-//------------------------------------------------------------------------------
86
-/** %Print any SD error code and halt. */
87
-void SdFat::errorHalt() {
88
-  errorPrint();
89
-  while (1);
90
-}
91
-//------------------------------------------------------------------------------
92
-/** %Print msg, any SD error code, and halt.
93
- *
94
- * \param[in] msg Message to print.
95
- */
96
-void SdFat::errorHalt(char const* msg) {
97
-  errorPrint(msg);
98
-  while (1);
99
-}
100
-//------------------------------------------------------------------------------
101
-/** %Print msg, any SD error code, and halt.
102
- *
103
- * \param[in] msg Message in program space (flash memory) to print.
104
- */
105
-void SdFat::errorHalt_P(PGM_P msg) {
106
-  errorPrint_P(msg);
107
-  while (1);
108
-}
109
-//------------------------------------------------------------------------------
110
-/** %Print any SD error code. */
111
-void SdFat::errorPrint() {
112
-  if (!card_.errorCode()) return;
113
-  PgmPrint("SD errorCode: 0X");
114
-  Serial.println(card_.errorCode(), HEX);
115
-}
116
-//------------------------------------------------------------------------------
117
-/** %Print msg, any SD error code.
118
- *
119
- * \param[in] msg Message to print.
120
- */
121
-void SdFat::errorPrint(char const* msg) {
122
-  PgmPrint("error: ");
123
-  Serial.println(msg);
124
-  errorPrint();
125
-}
126
-//------------------------------------------------------------------------------
127
-/** %Print msg, any SD error code.
128
- *
129
- * \param[in] msg Message in program space (flash memory) to print.
130
- */
131
-void SdFat::errorPrint_P(PGM_P msg) {
132
-  PgmPrint("error: ");
133
-  SerialPrintln_P(msg);
134
-  errorPrint();
135
-}
136
-//------------------------------------------------------------------------------
137
-/**
138
- * Test for the existence of a file.
139
- *
140
- * \param[in] name Name of the file to be tested for.
141
- *
142
- * \return true if the file exists else false.
143
- */
144
-bool SdFat::exists(const char* name) {
145
-  return vwd_.exists(name);
146
-}
147
-//------------------------------------------------------------------------------
148
-/**
149
- * Initialize an SdFat object.
150
- *
151
- * Initializes the SD card, SD volume, and root directory.
152
- *
153
- * \param[in] sckRateID value for SPI SCK rate. See Sd2Card::init().
154
- * \param[in] chipSelectPin SD chip select pin. See Sd2Card::init().
155
- *
156
- * \return The value one, true, is returned for success and
157
- * the value zero, false, is returned for failure.
158
- */
159
-bool SdFat::init(uint8_t sckRateID, uint8_t chipSelectPin) {
160
-  return card_.init(sckRateID, chipSelectPin) && vol_.init(&card_) && chdir(1);
161
-}
162
-//------------------------------------------------------------------------------
163
-/** %Print error details and halt after SdFat::init() fails. */
164
-void SdFat::initErrorHalt() {
165
-  initErrorPrint();
166
-  while (1);
167
-}
168
-//------------------------------------------------------------------------------
169
-/**Print message, error details, and halt after SdFat::init() fails.
170
- *
171
- * \param[in] msg Message to print.
172
- */
173
-void SdFat::initErrorHalt(char const *msg) {
174
-  Serial.println(msg);
175
-  initErrorHalt();
176
-}
177
-//------------------------------------------------------------------------------
178
-/**Print message, error details, and halt after SdFat::init() fails.
179
- *
180
- * \param[in] msg Message in program space (flash memory) to print.
181
- */
182
-void SdFat::initErrorHalt_P(PGM_P msg) {
183
-  SerialPrintln_P(msg);
184
-  initErrorHalt();
185
-}
186
-//------------------------------------------------------------------------------
187
-/** Print error details after SdFat::init() fails. */
188
-void SdFat::initErrorPrint() {
189
-  if (card_.errorCode()) {
190
-    PgmPrintln("Can't access SD card. Do not reformat.");
191
-    if (card_.errorCode() == SD_CARD_ERROR_CMD0) {
192
-      PgmPrintln("No card, wrong chip select pin, or SPI problem?");
193
-    }
194
-    errorPrint();
195
-  } else if (vol_.fatType() == 0) {
196
-    PgmPrintln("Invalid format, reformat SD.");
197
-  } else if (!vwd_.isOpen()) {
198
-    PgmPrintln("Can't open root directory.");
199
-  } else {
200
-    PgmPrintln("No error found.");
201
-  }
202
-}
203
-//------------------------------------------------------------------------------
204
-/**Print message and error details and halt after SdFat::init() fails.
205
- *
206
- * \param[in] msg Message to print.
207
- */
208
-void SdFat::initErrorPrint(char const *msg) {
209
-  Serial.println(msg);
210
-  initErrorPrint();
211
-}
212
-//------------------------------------------------------------------------------
213
-/**Print message and error details after SdFat::init() fails.
214
- *
215
- * \param[in] msg Message in program space (flash memory) to print.
216
- */
217
-void SdFat::initErrorPrint_P(PGM_P msg) {
218
-  SerialPrintln_P(msg);
219
-  initErrorHalt();
220
-}
221
-//------------------------------------------------------------------------------
222
-/** List the directory contents of the volume working directory to Serial.
223
- *
224
- * \param[in] flags The inclusive OR of
225
- *
226
- * LS_DATE - %Print file modification date
227
- *
228
- * LS_SIZE - %Print file size.
229
- *
230
- * LS_R - Recursive list of subdirectories.
231
- */
232
-void SdFat::ls(uint8_t flags) {
233
-  vwd_.ls(&Serial, flags);
234
-}
235
-//------------------------------------------------------------------------------
236
-/** List the directory contents of the volume working directory to Serial.
237
- *
238
- * \param[in] pr Print stream for list.
239
- *
240
- * \param[in] flags The inclusive OR of
241
- *
242
- * LS_DATE - %Print file modification date
243
- *
244
- * LS_SIZE - %Print file size.
245
- *
246
- * LS_R - Recursive list of subdirectories.
247
- */
248
-void SdFat::ls(Print* pr, uint8_t flags) {
249
-  vwd_.ls(pr, flags);
250
-}
251
-//------------------------------------------------------------------------------
252
-/** Make a subdirectory in the volume working directory.
253
- *
254
- * \param[in] path A path with a valid 8.3 DOS name for the subdirectory.
255
- *
256
- * \param[in] pFlag Create missing parent directories if true.
257
- *
258
- * \return The value one, true, is returned for success and
259
- * the value zero, false, is returned for failure.
260
- */
261
-bool SdFat::mkdir(const char* path, bool pFlag) {
262
-  SdBaseFile sub;
263
-  return sub.mkdir(&vwd_, path, pFlag);
264
-}
265
-//------------------------------------------------------------------------------
266
-/** Remove a file from the volume working directory.
267
-*
268
-* \param[in] path A path with a valid 8.3 DOS name for the file.
269
-*
270
-* \return The value one, true, is returned for success and
271
-* the value zero, false, is returned for failure.
272
-*/
273
-bool SdFat::remove(const char* path) {
274
-  return SdBaseFile::remove(&vwd_, path);
275
-}
276
-//------------------------------------------------------------------------------
277
-/** Rename a file or subdirectory.
278
- *
279
- * \param[in] oldPath Path name to the file or subdirectory to be renamed.
280
- *
281
- * \param[in] newPath New path name of the file or subdirectory.
282
- *
283
- * The \a newPath object must not exist before the rename call.
284
- *
285
- * The file to be renamed must not be open.  The directory entry may be
286
- * moved and file system corruption could occur if the file is accessed by
287
- * a file object that was opened before the rename() call.
288
- *
289
- * \return The value one, true, is returned for success and
290
- * the value zero, false, is returned for failure.
291
- */
292
-bool SdFat::rename(const char *oldPath, const char *newPath) {
293
-  SdBaseFile file;
294
-  if (!file.open(oldPath, O_READ)) return false;
295
-  return file.rename(&vwd_, newPath);
296
-}
297
-//------------------------------------------------------------------------------
298
-/** Remove a subdirectory from the volume's working directory.
299
- *
300
- * \param[in] path A path with a valid 8.3 DOS name for the subdirectory.
301
- *
302
- * The subdirectory file will be removed only if it is empty.
303
- *
304
- * \return The value one, true, is returned for success and
305
- * the value zero, false, is returned for failure.
306
- */
307
-bool SdFat::rmdir(const char* path) {
308
-  SdBaseFile sub;
309
-  if (!sub.open(path, O_READ)) return false;
310
-  return sub.rmdir();
311
-}
312
-//------------------------------------------------------------------------------
313
-/** Truncate a file to a specified length.  The current file position
314
- * will be maintained if it is less than or equal to \a length otherwise
315
- * it will be set to end of file.
316
- *
317
- * \param[in] path A path with a valid 8.3 DOS name for the file.
318
- * \param[in] length The desired length for the file.
319
- *
320
- * \return The value one, true, is returned for success and
321
- * the value zero, false, is returned for failure.
322
- * Reasons for failure include file is read only, file is a directory,
323
- * \a length is greater than the current file size or an I/O error occurs.
324
- */
325
-bool SdFat::truncate(const char* path, uint32_t length) {
326
-  SdBaseFile file;
327
-  if (!file.open(path, O_WRITE)) return false;
328
-  return file.truncate(length);
329
-}

+ 0
- 76
Marlin/SdFat.h Bestand weergeven

@@ -1,76 +0,0 @@
1
-/* Arduino SdFat Library
2
- * Copyright (C) 2009 by William Greiman
3
- *
4
- * This file is part of the Arduino SdFat Library
5
- *
6
- * This Library is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This Library is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with the Arduino SdFat Library.  If not, see
18
- * <http://www.gnu.org/licenses/>.
19
- */
20
-#ifndef SdFat_h
21
-#define SdFat_h
22
-/**
23
- * \file
24
- * \brief SdFat class
25
- */
26
-#include "SdFile.h"
27
-//#include <SdStream.h>
28
-//#include <ArduinoStream.h>
29
-//------------------------------------------------------------------------------
30
-/** SdFat version YYYYMMDD */
31
-#define SD_FAT_VERSION 20110902
32
-//------------------------------------------------------------------------------
33
-/**
34
- * \class SdFat
35
- * \brief Integration class for the %SdFat library.
36
- */
37
-class SdFat {
38
- public:
39
-  SdFat() {}
40
-  /** \return a pointer to the Sd2Card object. */
41
-  Sd2Card* card() {return &card_;}
42
-  bool chdir(bool set_cwd = false);
43
-  bool chdir(const char* path, bool set_cwd = false);
44
-  void chvol();
45
-  void errorHalt();
46
-  void errorHalt_P(PGM_P msg);
47
-  void errorHalt(char const *msg);
48
-  void errorPrint();
49
-  void errorPrint_P(PGM_P msg);
50
-  void errorPrint(char const *msg);
51
-  bool exists(const char* name);
52
-  bool init(uint8_t sckRateID = SPI_FULL_SPEED,
53
-    uint8_t chipSelectPin = SD_CHIP_SELECT_PIN);
54
-  void initErrorHalt();
55
-  void initErrorHalt(char const *msg);
56
-  void initErrorHalt_P(PGM_P msg);
57
-  void initErrorPrint();
58
-  void initErrorPrint(char const *msg);
59
-  void initErrorPrint_P(PGM_P msg);
60
-  void ls(uint8_t flags = 0);
61
-  void ls(Print* pr, uint8_t flags = 0);
62
-  bool mkdir(const char* path, bool pFlag = true);
63
-  bool remove(const char* path);
64
-  bool rename(const char *oldPath, const char *newPath);
65
-  bool rmdir(const char* path);
66
-  bool truncate(const char* path, uint32_t length);
67
-  /** \return a pointer to the SdVolume object. */
68
-  SdVolume* vol() {return &vol_;}
69
-  /** \return a pointer to the volume working directory. */
70
-  SdBaseFile* vwd() {return &vwd_;}
71
- private:
72
-  Sd2Card card_;
73
-  SdVolume vol_;
74
-  SdBaseFile vwd_;
75
-};
76
-#endif  // SdFat_h

+ 15
- 10
Marlin/cardreader.h Bestand weergeven

@@ -3,9 +3,8 @@
3 3
 
4 4
 #ifdef SDSUPPORT
5 5
  
6
-
7
-#include "SdFat.h"
8
-
6
+#include "SdFile.h"
7
+enum LsAction {LS_SerialPrint,LS_Count,LS_GetFilename};
9 8
 class CardReader
10 9
 {
11 10
 public:
@@ -17,20 +16,22 @@ public:
17 16
   //this is to delay autostart and hence the initialisaiton of the sd card to some seconds after the normal init, so the device is available quick after a reset
18 17
 
19 18
   void checkautostart(bool x); 
20
-  
19
+  void openFile(char* name,bool read);
21 20
   void closefile();
22 21
   void release();
23 22
   void startFileprint();
24
-  void startFilewrite(char *name);
23
+  //void startFilewrite(char *name);
25 24
   void pauseSDPrint();
26 25
   void getStatus();
27
-  
28
-  void selectFile(char* name);
26
+  void cd(char * absolutPath);
27
+  //void selectFile(char* name);
29 28
   void getfilename(const uint8_t nr);
30
-  uint8_t getnrfilenames();
29
+  uint16_t getnrfilenames();
31 30
   
32 31
 
33
-  inline void ls() {root.ls();};
32
+  void ls();
33
+  void lsDive(char *prepend,SdFile parent);
34
+
34 35
   inline bool eof() { return sdpos>=filesize ;};
35 36
   inline int16_t get() {  sdpos = file.curPosition();return (int16_t)file.read();};
36 37
   inline void setIndex(long index) {sdpos = index;file.seekSet(index);};
@@ -42,7 +43,7 @@ public:
42 43
   bool cardOK ;
43 44
   char filename[11];
44 45
 private:
45
-  SdFile root;
46
+  SdFile root,*curDir;
46 47
   Sd2Card card;
47 48
   SdVolume volume;
48 49
   SdFile file;
@@ -52,6 +53,10 @@ private:
52 53
   uint32_t sdpos ;
53 54
 
54 55
   bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
56
+  
57
+  LsAction lsAction; //stored for recursion.
58
+  int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory.
59
+  char* diveDirName;
55 60
 };
56 61
   
57 62
 

+ 187
- 61
Marlin/cardreader.pde Bestand weergeven

@@ -20,6 +20,109 @@ CardReader::CardReader()
20 20
   autostart_atmillis=millis()+5000;
21 21
 }
22 22
 
23
+char *createFilename(char *buffer,const dir_t &p) //buffer>12characters
24
+{
25
+  char *pos=buffer;
26
+  for (uint8_t i = 0; i < 11; i++) 
27
+  {
28
+    if (p.name[i] == ' ')continue;
29
+    if (i == 8) 
30
+    {
31
+      *pos++='.';
32
+    }
33
+    *pos++=p.name[i];
34
+  }
35
+  *pos++=0;
36
+  return buffer;
37
+}
38
+
39
+// bool SdFat::chdir(bool set_cwd) {
40
+//   if (set_cwd) SdBaseFile::cwd_ = &vwd_;
41
+//   vwd_.close();
42
+//   return vwd_.openRoot(&vol_);
43
+// }
44
+void  CardReader::lsDive(char *prepend,SdFile parent)
45
+{
46
+  dir_t p;
47
+ uint8_t cnt=0;
48
+ 
49
+  while (parent.readDir(p) > 0)
50
+  {
51
+    if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename)
52
+    {
53
+
54
+      char path[13*2];
55
+      char lfilename[13];
56
+      createFilename(lfilename,p);
57
+      
58
+      path[0]=0;
59
+      if(strlen(prepend)==0) //avoid leading / if already in prepend
60
+      {
61
+       strcat(path,"/");
62
+      }
63
+      strcat(path,prepend);
64
+      strcat(path,lfilename);
65
+      strcat(path,"/");
66
+      
67
+      //Serial.print(path);
68
+      
69
+      SdFile dir;
70
+      if(!dir.open(parent,lfilename, O_READ))
71
+      {
72
+        if(lsAction==LS_SerialPrint)
73
+        {
74
+          SERIAL_ECHO_START;
75
+          SERIAL_ECHOLN("Cannot open subdir");
76
+          SERIAL_ECHOLN(lfilename);
77
+        }
78
+      }
79
+      lsDive(path,dir);
80
+      //close done automatically by destructor of SdFile
81
+
82
+      
83
+    }
84
+    else
85
+    {
86
+      if (p.name[0] == DIR_NAME_FREE) break;
87
+      if (p.name[0] == DIR_NAME_DELETED || p.name[0] == '.'|| p.name[0] == '_') continue;
88
+      if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
89
+      
90
+      
91
+      if(p.name[8]!='G') continue;
92
+      if(p.name[9]=='~') continue;
93
+      //if(cnt++!=nr) continue;
94
+      createFilename(filename,p);
95
+      if(lsAction==LS_SerialPrint)
96
+      {
97
+        SERIAL_PROTOCOL(prepend);
98
+        SERIAL_PROTOCOLLN(filename);
99
+      }
100
+      else if(lsAction==LS_Count)
101
+      {
102
+        nrFiles++;
103
+      } 
104
+      else if(lsAction==LS_GetFilename)
105
+      {
106
+        if(cnt==nrFiles)
107
+          return;
108
+        cnt++;
109
+        
110
+      }
111
+    }
112
+  }
113
+}
114
+
115
+void CardReader::ls() 
116
+{
117
+  lsAction=LS_SerialPrint;
118
+  if(lsAction==LS_Count)
119
+  nrFiles=0;
120
+
121
+  root.rewind();
122
+  lsDive("",root);
123
+}
124
+
125
+
23 126
 void CardReader::initsd()
24 127
 {
25 128
   cardOK = false;
@@ -48,6 +151,7 @@ void CardReader::initsd()
48 151
       SERIAL_ECHO_START;
49 152
       SERIAL_ECHOLNPGM("SD card ok");
50 153
     }
154
+    curDir=&root;
51 155
   #endif //SDSS
52 156
 }
53 157
 void CardReader::release()
@@ -73,48 +177,94 @@ void CardReader::pauseSDPrint()
73 177
   }
74 178
 }
75 179
 
76
-void CardReader::selectFile(char* name)
180
+
181
+
182
+void CardReader::openFile(char* name,bool read)
77 183
 {
78
-  if(cardOK){
79
-    sdprinting = false;
80
-    file.close();
81
-   
82
-    if (file.open(&root, name, O_READ)) {
184
+  if(!cardOK)
185
+    return;
186
+  file.close();
187
+  sdprinting = false;
188
+  
189
+  
190
+  SdFile myDir;
191
+  curDir=&root;
192
+  char *fname=name;
193
+  
194
+  char *dirname_start,*dirname_end;
195
+  if(name[0]=='/')
196
+  {
197
+    dirname_start=strchr(name,'/')+1;
198
+    while(dirname_start>0)
199
+    {
200
+      dirname_end=strchr(dirname_start,'/');
201
+      //SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name));
202
+      //SERIAL_ECHO("end  :");SERIAL_ECHOLN((int)(dirname_end-name));
203
+      if(dirname_end>0 && dirname_end>dirname_start)
204
+      {
205
+        char subdirname[13];
206
+        strncpy(subdirname, dirname_start, dirname_end-dirname_start);
207
+        subdirname[dirname_end-dirname_start]=0;
208
+        SERIAL_ECHOLN(subdirname);
209
+        if(!myDir.open(curDir,subdirname,O_READ))
210
+        {
211
+          SERIAL_PROTOCOLPGM("open failed, File: ");
212
+          SERIAL_PROTOCOL(subdirname);
213
+          SERIAL_PROTOCOLLNPGM(".");
214
+          return;
215
+        }
216
+        else
217
+          ;//SERIAL_ECHOLN("dive ok");
218
+          
219
+        curDir=&myDir; 
220
+        dirname_start=dirname_end+1;
221
+      }
222
+      else // the reminder after all /fsa/fdsa/ is the filename
223
+      {
224
+        fname=dirname_start;
225
+        //SERIAL_ECHOLN("remaider");
226
+        //SERIAL_ECHOLN(fname);
227
+        break;
228
+      }
229
+      
230
+    }
231
+  }
232
+  if(read)
233
+  {
234
+    if (file.open(curDir, fname, O_READ)) 
235
+    {
83 236
       filesize = file.fileSize();
84 237
       SERIAL_PROTOCOLPGM("File opened:");
85
-      SERIAL_PROTOCOL(name);
238
+      SERIAL_PROTOCOL(fname);
86 239
       SERIAL_PROTOCOLPGM(" Size:");
87 240
       SERIAL_PROTOCOLLN(filesize);
88 241
       sdpos = 0;
89 242
       
90 243
       SERIAL_PROTOCOLLNPGM("File selected");
91 244
     }
92
-    else{
93
-      SERIAL_PROTOCOLLNPGM("file.open failed");
245
+    else
246
+    {
247
+     SERIAL_PROTOCOLPGM("open failed, File: ");
248
+      SERIAL_PROTOCOL(fname);
249
+      SERIAL_PROTOCOLLNPGM(".");
94 250
     }
95 251
   }
96
-}
97
-
98
-void CardReader::startFilewrite(char *name)
99
-{
100
-  if(cardOK)
101
-  {
102
-    
103
-    file.close();
104
-    sdprinting = false;
105
-    
106
-    if (!file.open(&root, name, O_CREAT | O_APPEND | O_WRITE | O_TRUNC))
252
+  else 
253
+  { //write
254
+    if (!file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC))
107 255
     {
108 256
       SERIAL_PROTOCOLPGM("open failed, File: ");
109
-      SERIAL_PROTOCOL(name);
257
+      SERIAL_PROTOCOL(fname);
110 258
       SERIAL_PROTOCOLLNPGM(".");
111 259
     }
112
-    else{
260
+    else
261
+    {
113 262
       saving = true;
114 263
       SERIAL_PROTOCOLPGM("Writing to file: ");
115 264
       SERIAL_PROTOCOLLN(name);
116 265
     }
117 266
   }
267
+  
118 268
 }
119 269
 
120 270
 void CardReader::getStatus()
@@ -212,49 +362,25 @@ void CardReader::closefile()
212 362
 
213 363
 void CardReader::getfilename(const uint8_t nr)
214 364
 {
215
-
216
-  dir_t p;
217
-  root.rewind();
218
-  uint8_t cnt=0;
219
-  filename[0]='\0';
220
-  while (root.readDir(p) > 0)
221
-  {
222
-    if (p.name[0] == DIR_NAME_FREE) break;
223
-    if (p.name[0] == DIR_NAME_DELETED || p.name[0] == '.'|| p.name[0] == '_') continue;
224
-    if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
225
-    if(p.name[8]!='G') continue;
226
-    if(p.name[9]=='~') continue;
227
-    if(cnt++!=nr) continue;
228
-    //Serial.println((char*)p.name);
229
-    uint8_t writepos=0;
230
-    for (int8_t i = 0; i < 11; i++) 
231
-    {
232
-      if (p.name[i] == ' ') continue;
233
-      if (i == 8) {
234
-        filename[writepos++]='.';
235
-      }
236
-      filename[writepos++]=p.name[i];
237
-    }
238
-    filename[writepos++]=0;
239
-  }
365
+  lsAction=LS_GetFilename;
366
+  nrFiles=nr;
367
+  curDir->rewind();
368
+  lsDive("",*curDir);
369
+  
240 370
 }
241 371
 
242
-uint8_t CardReader::getnrfilenames()
372
+uint16_t CardReader::getnrfilenames()
243 373
 {
244
-  dir_t p;
245
-  root.rewind();
246
-  uint8_t cnt=0;
247
-  while (root.readDir(p) > 0)
248
-  {
249
-    if (p.name[0] == DIR_NAME_FREE) break;
250
-    if (p.name[0] == DIR_NAME_DELETED || p.name[0] == '.'|| p.name[0] == '_') continue;
251
-    if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
252
-    if(p.name[8]!='G') continue;
253
-    if(p.name[9]=='~') continue;
254
-    cnt++;
255
-  }
256
-  return cnt;
374
+  lsAction=LS_Count;
375
+  nrFiles=0;
376
+  curDir->rewind();
377
+  lsDive("",*curDir);
378
+  return nrFiles;
257 379
 }
258 380
 
381
+void CardReader::cd(char * absolutPath)
382
+{
383
+  
384
+}
259 385
 
260 386
 #endif //SDSUPPORT

+ 13
- 7
Marlin/planner.cpp Bestand weergeven

@@ -87,7 +87,10 @@ static float previous_speed[4]; // Speed of previous path line segment
87 87
 static float previous_nominal_speed; // Nominal speed of previous path line segment
88 88
 
89 89
 #ifdef AUTOTEMP
90
-float high_e_speed=0;
90
+    float autotemp_max=250;
91
+    float autotemp_min=210;
92
+    float autotemp_factor=1;
93
+    bool autotemp_enabled=false;
91 94
 #endif
92 95
 
93 96
 
@@ -379,26 +382,29 @@ block_t *plan_get_current_block() {
379 382
 #ifdef AUTOTEMP
380 383
 void getHighESpeed()
381 384
 {
382
-  if(degTargetHotend0()+2<AUTOTEMP_MIN)  //probably temperature set to zero.
385
+  if(!autotemp_enabled)
386
+    return;
387
+  if(degTargetHotend0()+2<autotemp_min)  //probably temperature set to zero.
383 388
     return; //do nothing
389
+  
384 390
   float high=0;
385 391
   char block_index = block_buffer_tail;
386 392
   
387 393
   while(block_index != block_buffer_head) {
388
-    float se=block_buffer[block_index].speed_e;
394
+    float se=block_buffer[block_index].steps_e/float(block_buffer[block_index].step_event_count)*block_buffer[block_index].nominal_rate;
395
+    //se; units steps/sec;
389 396
     if(se>high)
390 397
     {
391 398
       high=se;
392 399
     }
393 400
     block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
394 401
   }
395
-  high_e_speed=high*axis_steps_per_unit[E_AXIS]/(1000000.0);  //so it is independent of the esteps/mm. before 
396 402
    
397
-  float g=AUTOTEMP_MIN+high_e_speed*AUTOTEMP_FACTOR;
398
-  float t=constrain(AUTOTEMP_MIN,g,AUTOTEMP_MAX);
403
+  float g=autotemp_min+high*autotemp_factor;
404
+  float t=constrain(autotemp_min,g,autotemp_max);
399 405
   setTargetHotend0(t);
400 406
   SERIAL_ECHO_START;
401
-  SERIAL_ECHOPAIR("highe",high_e_speed);
407
+  SERIAL_ECHOPAIR("highe",high);
402 408
   SERIAL_ECHOPAIR(" t",t);
403 409
   SERIAL_ECHOLN("");
404 410
 }

+ 7
- 1
Marlin/planner.h Bestand weergeven

@@ -92,7 +92,13 @@ extern float max_xy_jerk; //speed than can be stopped at once, if i understand c
92 92
 extern float max_z_jerk;
93 93
 extern float mintravelfeedrate;
94 94
 extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
95
+
96
+
95 97
 #ifdef AUTOTEMP
96
-extern float high_e_speed;
98
+    extern bool autotemp_enabled;
99
+    extern float autotemp_max;
100
+    extern float autotemp_min;
101
+    extern float autotemp_factor;
97 102
 #endif
103
+
98 104
 #endif

Laden…
Annuleren
Opslaan