From 729cde44755732067917988296b59dab1fe3e364 Mon Sep 17 00:00:00 2001 From: Bernhard Date: Mon, 26 Dec 2011 09:20:33 +0100 Subject: [PATCH] fix autostart failure if in wrong directory --- Marlin/cardreader.h | 2 ++ Marlin/cardreader.pde | 9 +++++++++ Marlin/ultralcd.pde | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Marlin/cardreader.h b/Marlin/cardreader.h index 70f0d2c1d9..67fe58a90a 100644 --- a/Marlin/cardreader.h +++ b/Marlin/cardreader.h @@ -31,6 +31,8 @@ public: void ls(); void chdir(const char * relpath); void updir(); + void setroot(); + FORCE_INLINE bool eof() { return sdpos>=filesize ;}; FORCE_INLINE int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();}; diff --git a/Marlin/cardreader.pde b/Marlin/cardreader.pde index 3d91224977..a1f23ce068 100644 --- a/Marlin/cardreader.pde +++ b/Marlin/cardreader.pde @@ -164,6 +164,15 @@ void CardReader::initsd() SERIAL_ECHOLNPGM("workDir open failed"); } } + +void CardReader::setroot() +{ + curDir=&root; + if(!workDir.openRoot(&volume)) + { + SERIAL_ECHOLNPGM("workDir open failed"); + } +} void CardReader::release() { sdprinting = false; diff --git a/Marlin/ultralcd.pde b/Marlin/ultralcd.pde index ef86d8f32c..69be85959a 100644 --- a/Marlin/ultralcd.pde +++ b/Marlin/ultralcd.pde @@ -467,7 +467,7 @@ void MainMenu::showPrepare() MENUITEM( lcdprintPGM(" Main \003") , BLOCK;status=Main_Menu;beepshort(); ) ; break; case ItemP_autostart: - MENUITEM( lcdprintPGM(" Autostart") , BLOCK;card.lastnr=0;card.checkautostart(true);beepshort(); ) ; + MENUITEM( lcdprintPGM(" Autostart") , BLOCK;card.lastnr=0;card.setroot();card.checkautostart(true);beepshort(); ) ; break; case ItemP_disstep: MENUITEM( lcdprintPGM(" Disable Steppers") , BLOCK;enquecommand("M84");beepshort(); ) ;