SD file updates

This commit is contained in:
Scott Lahteine 2017-09-06 06:28:32 -05:00
parent 82fff87e16
commit 614a86a380
15 changed files with 233 additions and 226 deletions

View File

@ -26,11 +26,15 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h"
#include "../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#include "Sd2Card.h" #include "Sd2Card.h"
#include "../Marlin.h"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// send command and return error code. Return zero for OK // send command and return error code. Return zero for OK
uint8_t Sd2Card::cardCommand(uint8_t cmd, uint32_t arg) { uint8_t Sd2Card::cardCommand(uint8_t cmd, uint32_t arg) {

View File

@ -27,17 +27,18 @@
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h" #ifndef SD2CARD_H
#if ENABLED(SDSUPPORT) #define SD2CARD_H
#ifndef Sd2Card_h
#define Sd2Card_h
/** /**
* \file * \file
* \brief Sd2Card class for V2 SD/SDHC cards * \brief Sd2Card class for V2 SD/SDHC cards
*/ */
#include "SdFatConfig.h" #include "SdFatConfig.h"
#include "SdInfo.h" #include "SdInfo.h"
#include <stdint.h>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** init timeout ms */ /** init timeout ms */
uint16_t const SD_INIT_TIMEOUT = 2000; uint16_t const SD_INIT_TIMEOUT = 2000;
@ -239,7 +240,5 @@ class Sd2Card {
bool waitNotBusy(uint16_t timeoutMillis); bool waitNotBusy(uint16_t timeoutMillis);
bool writeData(uint8_t token, const uint8_t* src); bool writeData(uint8_t token, const uint8_t* src);
}; };
#endif // Sd2Card_h
#endif // SD2CARD_H
#endif

View File

@ -27,10 +27,14 @@
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h" #include "../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#include "SdBaseFile.h" #include "SdBaseFile.h"
#include "../Marlin.h"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// pointer to cwd directory // pointer to cwd directory
SdBaseFile* SdBaseFile::cwd_ = 0; SdBaseFile* SdBaseFile::cwd_ = 0;
@ -1822,5 +1826,4 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) {
void (*SdBaseFile::oldDateTime_)(uint16_t &date, uint16_t &time) = 0; // NOLINT void (*SdBaseFile::oldDateTime_)(uint16_t &date, uint16_t &time) = 0; // NOLINT
#endif // ALLOW_DEPRECATED_FUNCTIONS #endif // ALLOW_DEPRECATED_FUNCTIONS
#endif // SDSUPPORT
#endif

View File

@ -26,18 +26,19 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h"
#if ENABLED(SDSUPPORT)
#ifndef SdBaseFile_h #ifndef SDBASEFILE_H
#define SdBaseFile_h #define SDBASEFILE_H
/** /**
* \file * \file
* \brief SdBaseFile class * \brief SdBaseFile class
*/ */
#include "Marlin.h"
#include "SdFatConfig.h" #include "SdFatConfig.h"
#include "SdVolume.h" #include "SdVolume.h"
#include <stdint.h>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** /**
* \struct filepos_t * \struct filepos_t
@ -488,5 +489,4 @@ class SdBaseFile {
#endif // ALLOW_DEPRECATED_FUNCTIONS #endif // ALLOW_DEPRECATED_FUNCTIONS
}; };
#endif // SdBaseFile_h #endif // SDBASEFILE_H
#endif

View File

@ -26,109 +26,105 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
/** /**
* \file * \file
* \brief configuration definitions * \brief configuration definitions
*/ */
#include "Marlin.h" #ifndef SDFATCONFIG_H
#if ENABLED(SDSUPPORT) #define SDFATCONFIG_H
#ifndef SdFatConfig_h //------------------------------------------------------------------------------
#define SdFatConfig_h /**
#include <stdint.h> * To use multiple SD cards set USE_MULTIPLE_CARDS nonzero.
//------------------------------------------------------------------------------ *
/** * Using multiple cards costs 400 - 500 bytes of flash.
* To use multiple SD cards set USE_MULTIPLE_CARDS nonzero. *
* * Each card requires about 550 bytes of SRAM so use of a Mega is recommended.
* Using multiple cards costs 400 - 500 bytes of flash. */
* #define USE_MULTIPLE_CARDS 0
* Each card requires about 550 bytes of SRAM so use of a Mega is recommended. //------------------------------------------------------------------------------
*/ /**
#define USE_MULTIPLE_CARDS 0 * Call flush for endl if ENDL_CALLS_FLUSH is nonzero
//------------------------------------------------------------------------------ *
/** * The standard for iostreams is to call flush. This is very costly for
* Call flush for endl if ENDL_CALLS_FLUSH is nonzero * SdFat. Each call to flush causes 2048 bytes of I/O to the SD.
* *
* The standard for iostreams is to call flush. This is very costly for * SdFat has a single 512 byte buffer for SD I/O so it must write the current
* SdFat. Each call to flush causes 2048 bytes of I/O to the SD. * data block to the SD, read the directory block from the SD, update the
* * directory entry, write the directory block to the SD and read the data
* SdFat has a single 512 byte buffer for SD I/O so it must write the current * block back into the buffer.
* data block to the SD, read the directory block from the SD, update the *
* directory entry, write the directory block to the SD and read the data * The SD flash memory controller is not designed for this many rewrites
* block back into the buffer. * so performance may be reduced by more than a factor of 100.
* *
* The SD flash memory controller is not designed for this many rewrites * If ENDL_CALLS_FLUSH is zero, you must call flush and/or close to force
* so performance may be reduced by more than a factor of 100. * all data to be written to the SD.
* */
* If ENDL_CALLS_FLUSH is zero, you must call flush and/or close to force #define ENDL_CALLS_FLUSH 0
* all data to be written to the SD. //------------------------------------------------------------------------------
*/ /**
#define ENDL_CALLS_FLUSH 0 * Allow use of deprecated functions if ALLOW_DEPRECATED_FUNCTIONS is nonzero
//------------------------------------------------------------------------------ */
/** #define ALLOW_DEPRECATED_FUNCTIONS 1
* Allow use of deprecated functions if ALLOW_DEPRECATED_FUNCTIONS is nonzero //------------------------------------------------------------------------------
*/ /**
#define ALLOW_DEPRECATED_FUNCTIONS 1 * Allow FAT12 volumes if FAT12_SUPPORT is nonzero.
//------------------------------------------------------------------------------ * FAT12 has not been well tested.
/** */
* Allow FAT12 volumes if FAT12_SUPPORT is nonzero. #define FAT12_SUPPORT 0
* FAT12 has not been well tested. //------------------------------------------------------------------------------
*/ /**
#define FAT12_SUPPORT 0 * SPI init rate for SD initialization commands. Must be 5 (F_CPU/64)
//------------------------------------------------------------------------------ * or 6 (F_CPU/128).
/** */
* SPI init rate for SD initialization commands. Must be 5 (F_CPU/64) #define SPI_SD_INIT_RATE 5
* or 6 (F_CPU/128). //------------------------------------------------------------------------------
*/ /**
#define SPI_SD_INIT_RATE 5 * Set the SS pin high for hardware SPI. If SS is chip select for another SPI
//------------------------------------------------------------------------------ * device this will disable that device during the SD init phase.
/** */
* Set the SS pin high for hardware SPI. If SS is chip select for another SPI #define SET_SPI_SS_HIGH 1
* device this will disable that device during the SD init phase. //------------------------------------------------------------------------------
*/ /**
#define SET_SPI_SS_HIGH 1 * Define MEGA_SOFT_SPI nonzero to use software SPI on Mega Arduinos.
//------------------------------------------------------------------------------ * Pins used are SS 10, MOSI 11, MISO 12, and SCK 13.
/** *
* Define MEGA_SOFT_SPI nonzero to use software SPI on Mega Arduinos. * MEGA_SOFT_SPI allows an unmodified Adafruit GPS Shield to be used
* Pins used are SS 10, MOSI 11, MISO 12, and SCK 13. * on Mega Arduinos. Software SPI works well with GPS Shield V1.1
* * but many SD cards will fail with GPS Shield V1.0.
* MEGA_SOFT_SPI allows an unmodified Adafruit GPS Shield to be used */
* on Mega Arduinos. Software SPI works well with GPS Shield V1.1 #define MEGA_SOFT_SPI 0
* but many SD cards will fail with GPS Shield V1.0. //------------------------------------------------------------------------------
*/ /**
#define MEGA_SOFT_SPI 0 * Set USE_SOFTWARE_SPI nonzero to always use software SPI.
//------------------------------------------------------------------------------ */
/** #define USE_SOFTWARE_SPI 0
* Set USE_SOFTWARE_SPI nonzero to always use software SPI. // define software SPI pins so Mega can use unmodified 168/328 shields
*/ /** Software SPI chip select pin for the SD */
#define USE_SOFTWARE_SPI 0 #define SOFT_SPI_CS_PIN 10
// define software SPI pins so Mega can use unmodified 168/328 shields /** Software SPI Master Out Slave In pin */
/** Software SPI chip select pin for the SD */ #define SOFT_SPI_MOSI_PIN 11
#define SOFT_SPI_CS_PIN 10 /** Software SPI Master In Slave Out pin */
/** Software SPI Master Out Slave In pin */ #define SOFT_SPI_MISO_PIN 12
#define SOFT_SPI_MOSI_PIN 11 /** Software SPI Clock pin */
/** Software SPI Master In Slave Out pin */ #define SOFT_SPI_SCK_PIN 13
#define SOFT_SPI_MISO_PIN 12 //------------------------------------------------------------------------------
/** Software SPI Clock pin */ /**
#define SOFT_SPI_SCK_PIN 13 * The __cxa_pure_virtual function is an error handler that is invoked when
//------------------------------------------------------------------------------ * a pure virtual function is called.
/** */
* The __cxa_pure_virtual function is an error handler that is invoked when #define USE_CXA_PURE_VIRTUAL 1
* a pure virtual function is called.
*/
#define USE_CXA_PURE_VIRTUAL 1
/** Number of UTF-16 characters per entry */ /** Number of UTF-16 characters per entry */
#define FILENAME_LENGTH 13 #define FILENAME_LENGTH 13
/** /**
* Defines for long (vfat) filenames * Defines for long (vfat) filenames
*/ */
/** Number of VFAT entries used. Every entry has 13 UTF-16 characters */ /** Number of VFAT entries used. Every entry has 13 UTF-16 characters */
#define MAX_VFAT_ENTRIES (2) #define MAX_VFAT_ENTRIES (2)
/** Total size of the buffer used to store the long filenames */ /** Total size of the buffer used to store the long filenames */
#define LONG_FILENAME_LENGTH (FILENAME_LENGTH*MAX_VFAT_ENTRIES+1) #define LONG_FILENAME_LENGTH (FILENAME_LENGTH*MAX_VFAT_ENTRIES+1)
#endif // SdFatConfig_h
#endif // SDFATCONFIG_H
#endif

View File

@ -26,11 +26,11 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h"
#if ENABLED(SDSUPPORT)
#ifndef SdFatStructs_h #ifndef SDFATSTRUCTS_H
#define SdFatStructs_h #define SDFATSTRUCTS_H
#include <stdint.h>
#define PACKED __attribute__((__packed__)) #define PACKED __attribute__((__packed__))
/** /**
@ -649,7 +649,5 @@ static inline uint8_t DIR_IS_SUBDIR(const dir_t* dir) {
static inline uint8_t DIR_IS_FILE_OR_SUBDIR(const dir_t* dir) { static inline uint8_t DIR_IS_FILE_OR_SUBDIR(const dir_t* dir) {
return (dir->attributes & DIR_ATT_VOLUME_ID) == 0; return (dir->attributes & DIR_ATT_VOLUME_ID) == 0;
} }
#endif // SdFatStructs_h
#endif // SDFATSTRUCTS_H
#endif

View File

@ -26,9 +26,11 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h"
#include "../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#include "SdFatUtil.h" #include "SdFatUtil.h"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -88,4 +90,5 @@ void SdFatUtil::SerialPrint_P(PGM_P str) {
void SdFatUtil::SerialPrintln_P(PGM_P str) { void SdFatUtil::SerialPrintln_P(PGM_P str) {
println_P(str); println_P(str);
} }
#endif
#endif // SDSUPPORT

View File

@ -26,11 +26,10 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#ifndef SdFatUtil_h #ifndef SDFATUTIL_H
#define SdFatUtil_h #define SDFATUTIL_H
#include "Marlin.h" #include <string.h>
#if ENABLED(SDSUPPORT)
/** /**
* \file * \file
@ -51,6 +50,4 @@ namespace SdFatUtil {
using namespace SdFatUtil; // NOLINT using namespace SdFatUtil; // NOLINT
#endif // SDSUPPORT #endif // SDFATUTIL_H
#endif // SdFatUtil_h

View File

@ -26,10 +26,13 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h"
#include "../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#include "SdFile.h" #include "SdFile.h"
/** Create a file object and open it in the current working directory. /** Create a file object and open it in the current working directory.
* *
* \param[in] path A path with a valid 8.3 DOS name for a file to be opened. * \param[in] path A path with a valid 8.3 DOS name for a file to be opened.

View File

@ -26,18 +26,20 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
/** /**
* \file * \file
* \brief SdFile class * \brief SdFile class
*/ */
#include "Marlin.h"
#if ENABLED(SDSUPPORT) #ifndef SDFILE_H
#define SDFILE_H
#include "SdBaseFile.h" #include "SdBaseFile.h"
//todo: HAL: create wrapper for Print?
//#include <Print.h> #include <stdint.h>
#ifndef SdFile_h #include <string.h>
#define SdFile_h
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** /**
* \class SdFile * \class SdFile
@ -58,7 +60,5 @@ class SdFile : public SdBaseFile/*, public Print*/ {
void write_P(PGM_P str); void write_P(PGM_P str);
void writeln_P(PGM_P str); void writeln_P(PGM_P str);
}; };
#endif // SdFile_h
#endif // SDFILE_H
#endif

View File

@ -26,12 +26,11 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h" #ifndef SDINFO_H
#if ENABLED(SDSUPPORT) #define SDINFO_H
#ifndef SdInfo_h
#define SdInfo_h
#include <stdint.h> #include <stdint.h>
// Based on the document: // Based on the document:
// //
// SD Specifications // SD Specifications
@ -284,6 +283,5 @@ union csd_t {
csd1_t v1; csd1_t v1;
csd2_t v2; csd2_t v2;
}; };
#endif // SdInfo_h
#endif #endif // SDINFO_H

View File

@ -26,10 +26,15 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h"
#include "../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#include "SdVolume.h" #include "SdVolume.h"
#include "../Marlin.h"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#if !USE_MULTIPLE_CARDS #if !USE_MULTIPLE_CARDS
// raw block cache // raw block cache
@ -417,4 +422,5 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
FAIL: FAIL:
return false; return false;
} }
#endif
#endif // SDSUPPORT

View File

@ -26,10 +26,9 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h" #ifndef SDVOLUME_H
#if ENABLED(SDSUPPORT) #define SDVOLUME_H
#ifndef SdVolume_h
#define SdVolume_h
/** /**
* \file * \file
* \brief SdVolume class * \brief SdVolume class
@ -38,6 +37,8 @@
#include "Sd2Card.h" #include "Sd2Card.h"
#include "SdFatStructs.h" #include "SdFatStructs.h"
#include <stdint.h>
//============================================================================== //==============================================================================
// SdVolume class // SdVolume class
/** /**
@ -136,19 +137,19 @@ class SdVolume {
// value for dirty argument in cacheRawBlock to indicate write to cache // value for dirty argument in cacheRawBlock to indicate write to cache
static bool const CACHE_FOR_WRITE = true; static bool const CACHE_FOR_WRITE = true;
#if USE_MULTIPLE_CARDS #if USE_MULTIPLE_CARDS
cache_t cacheBuffer_; // 512 byte cache for device blocks cache_t cacheBuffer_; // 512 byte cache for device blocks
uint32_t cacheBlockNumber_; // Logical number of block in the cache uint32_t cacheBlockNumber_; // Logical number of block in the cache
Sd2Card* sdCard_; // Sd2Card object for cache Sd2Card* sdCard_; // Sd2Card object for cache
bool cacheDirty_; // cacheFlush() will write block if true bool cacheDirty_; // cacheFlush() will write block if true
uint32_t cacheMirrorBlock_; // block number for mirror FAT uint32_t cacheMirrorBlock_; // block number for mirror FAT
#else // USE_MULTIPLE_CARDS #else // USE_MULTIPLE_CARDS
static cache_t cacheBuffer_; // 512 byte cache for device blocks static cache_t cacheBuffer_; // 512 byte cache for device blocks
static uint32_t cacheBlockNumber_; // Logical number of block in the cache static uint32_t cacheBlockNumber_; // Logical number of block in the cache
static Sd2Card* sdCard_; // Sd2Card object for cache static Sd2Card* sdCard_; // Sd2Card object for cache
static bool cacheDirty_; // cacheFlush() will write block if true static bool cacheDirty_; // cacheFlush() will write block if true
static uint32_t cacheMirrorBlock_; // block number for mirror FAT static uint32_t cacheMirrorBlock_; // block number for mirror FAT
#endif // USE_MULTIPLE_CARDS #endif // USE_MULTIPLE_CARDS
uint32_t allocSearchStart_; // start cluster for alloc search uint32_t allocSearchStart_; // start cluster for alloc search
uint8_t blocksPerCluster_; // cluster size in blocks uint8_t blocksPerCluster_; // cluster size in blocks
uint32_t blocksPerFat_; // FAT size in blocks uint32_t blocksPerFat_; // FAT size in blocks
@ -173,13 +174,13 @@ class SdVolume {
} }
cache_t* cache() {return &cacheBuffer_;} cache_t* cache() {return &cacheBuffer_;}
uint32_t cacheBlockNumber() {return cacheBlockNumber_;} uint32_t cacheBlockNumber() {return cacheBlockNumber_;}
#if USE_MULTIPLE_CARDS #if USE_MULTIPLE_CARDS
bool cacheFlush(); bool cacheFlush();
bool cacheRawBlock(uint32_t blockNumber, bool dirty); bool cacheRawBlock(uint32_t blockNumber, bool dirty);
#else // USE_MULTIPLE_CARDS #else // USE_MULTIPLE_CARDS
static bool cacheFlush(); static bool cacheFlush();
static bool cacheRawBlock(uint32_t blockNumber, bool dirty); static bool cacheRawBlock(uint32_t blockNumber, bool dirty);
#endif // USE_MULTIPLE_CARDS #endif // USE_MULTIPLE_CARDS
// used by SdBaseFile write to assign cache to SD location // used by SdBaseFile write to assign cache to SD location
void cacheSetBlockNumber(uint32_t blockNumber, bool dirty) { void cacheSetBlockNumber(uint32_t blockNumber, bool dirty) {
cacheDirty_ = dirty; cacheDirty_ = dirty;
@ -206,22 +207,22 @@ class SdVolume {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Deprecated functions - suppress cpplint warnings with NOLINT comment // Deprecated functions - suppress cpplint warnings with NOLINT comment
#if ALLOW_DEPRECATED_FUNCTIONS && !defined(DOXYGEN) #if ALLOW_DEPRECATED_FUNCTIONS && !defined(DOXYGEN)
public: public:
/** \deprecated Use: bool SdVolume::init(Sd2Card* dev); /** \deprecated Use: bool SdVolume::init(Sd2Card* dev);
* \param[in] dev The SD card where the volume is located. * \param[in] dev The SD card where the volume is located.
* \return true for success or false for failure. * \return true for success or false for failure.
*/ */
bool init(Sd2Card& dev) {return init(&dev);} // NOLINT bool init(Sd2Card& dev) {return init(&dev);} // NOLINT
/** \deprecated Use: bool SdVolume::init(Sd2Card* dev, uint8_t vol); /** \deprecated Use: bool SdVolume::init(Sd2Card* dev, uint8_t vol);
* \param[in] dev The SD card where the volume is located. * \param[in] dev The SD card where the volume is located.
* \param[in] part The partition to be used. * \param[in] part The partition to be used.
* \return true for success or false for failure. * \return true for success or false for failure.
*/ */
bool init(Sd2Card& dev, uint8_t part) { // NOLINT bool init(Sd2Card& dev, uint8_t part) { // NOLINT
return init(&dev, part); return init(&dev, part);
} }
#endif // ALLOW_DEPRECATED_FUNCTIONS #endif // ALLOW_DEPRECATED_FUNCTIONS
}; };
#endif // SdVolume
#endif #endif // SDVOLUME_H

View File

@ -20,17 +20,20 @@
* *
*/ */
#include <ctype.h> #include "../inc/MarlinConfig.h"
#include "cardreader.h"
#include "ultralcd.h"
#include "stepper.h"
#include "language.h"
#include "Marlin.h"
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#include "cardreader.h"
#include "../Marlin.h"
#include "../lcd/ultralcd.h"
#include "../module/stepper.h"
#include "../module/printcounter.h"
#include "../core/language.h"
#include <ctype.h>
#define LONGEST_FILENAME (longFilename[0] ? longFilename : filename) #define LONGEST_FILENAME (longFilename[0] ? longFilename : filename)
CardReader::CardReader() { CardReader::CardReader() {
@ -864,12 +867,15 @@ void CardReader::updir() {
#endif // SDCARD_SORT_ALPHA #endif // SDCARD_SORT_ALPHA
#if (ENABLED(SDCARD_SORT_ALPHA) && SDSORT_USES_RAM && SDSORT_CACHE_NAMES) uint16_t CardReader::get_num_Files() {
// if true - don't need to access the SD card for file names return
uint16_t CardReader::get_num_Files() {return nrFiles;} #if ENABLED(SDCARD_SORT_ALPHA) && SDSORT_USES_RAM && SDSORT_CACHE_NAMES
#else nrFiles // no need to access the SD card for filenames
uint16_t CardReader::get_num_Files() {return getnrfilenames(); } #else
#endif getnrfilenames()
#endif
;
}
void CardReader::printingHasFinished() { void CardReader::printingHasFinished() {
stepper.synchronize(); stepper.synchronize();

View File

@ -23,16 +23,11 @@
#ifndef CARDREADER_H #ifndef CARDREADER_H
#define CARDREADER_H #define CARDREADER_H
#include "MarlinConfig.h"
#if ENABLED(SDSUPPORT)
#define MAX_DIR_DEPTH 10 // Maximum folder depth #define MAX_DIR_DEPTH 10 // Maximum folder depth
#include "SdFile.h" #include "SdFile.h"
#include "types.h" #include "../inc/MarlinConfig.h"
#include "enum.h"
class CardReader { class CardReader {
public: public:
@ -166,27 +161,25 @@ private:
#endif #endif
}; };
extern CardReader card;
#define IS_SD_PRINTING (card.sdprinting)
#define IS_SD_FILE_OPEN (card.isFileOpen())
#if PIN_EXISTS(SD_DETECT) #if PIN_EXISTS(SD_DETECT)
#if ENABLED(SD_DETECT_INVERTED) #if ENABLED(SD_DETECT_INVERTED)
#define IS_SD_INSERTED (READ(SD_DETECT_PIN) != 0) #define IS_SD_INSERTED (READ(SD_DETECT_PIN) == HIGH)
#else #else
#define IS_SD_INSERTED (READ(SD_DETECT_PIN) == 0) #define IS_SD_INSERTED (READ(SD_DETECT_PIN) == LOW)
#endif #endif
#else #else
//No card detect line? Assume the card is inserted. //No card detect line? Assume the card is inserted.
#define IS_SD_INSERTED true #define IS_SD_INSERTED true
#endif #endif
#if ENABLED(SDSUPPORT)
#define IS_SD_PRINTING (card.sdprinting)
#define IS_SD_FILE_OPEN (card.isFileOpen())
#else #else
#define IS_SD_PRINTING (false)
#define IS_SD_FILE_OPEN (false)
#endif
#define IS_SD_PRINTING (false) extern CardReader card;
#define IS_SD_FILE_OPEN (false)
#endif // SDSUPPORT #endif // CARDREADER_H
#endif // __CARDREADER_H