Cleanup, apply standards to SD lib, cardreader

This commit is contained in:
Scott Lahteine
2017-11-14 22:48:40 -06:00
parent d8b1343279
commit 2390f6d3ab
15 changed files with 1439 additions and 1752 deletions

View File

@@ -20,8 +20,8 @@
*
*/
#ifndef CARDREADER_H
#define CARDREADER_H
#ifndef _CARDREADER_H_
#define _CARDREADER_H_
#include "MarlinConfig.h"
@@ -30,7 +30,6 @@
#define MAX_DIR_DEPTH 10 // Maximum folder depth
#include "SdFile.h"
#include "types.h"
#include "enum.h"
@@ -40,13 +39,15 @@ public:
void initsd();
void write_command(char *buf);
//files auto[0-9].g on the sd card are performed in a row
//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
// Files auto[0-9].g on the sd card are performed in sequence.
// This is to delay autostart and hence the initialisation of
// the sd card to some seconds after the normal init, so the
// device is available soon after a reset.
void checkautostart(bool x);
void openFile(char* name, bool read, bool push_current=false);
void openLogFile(char* name);
void removeFile(char* name);
void removeFile(const char * const name);
void closefile(bool store_location=false);
void release();
void openAndPrintFile(const char *name);
@@ -148,8 +149,7 @@ private:
uint8_t file_subcall_ctr;
uint32_t filespos[SD_PROCEDURE_DEPTH];
char proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
uint32_t filesize;
uint32_t sdpos;
uint32_t filesize, sdpos;
millis_t next_autostart_ms;
bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
@@ -164,27 +164,27 @@ private:
#endif
};
extern CardReader card;
#define IS_SD_PRINTING (card.sdprinting)
#define IS_SD_FILE_OPEN (card.isFileOpen())
#if PIN_EXISTS(SD_DETECT)
#if ENABLED(SD_DETECT_INVERTED)
#define IS_SD_INSERTED (READ(SD_DETECT_PIN) != 0)
#define IS_SD_INSERTED (READ(SD_DETECT_PIN) == HIGH)
#else
#define IS_SD_INSERTED (READ(SD_DETECT_PIN) == 0)
#define IS_SD_INSERTED (READ(SD_DETECT_PIN) == LOW)
#endif
#else
//No card detect line? Assume the card is inserted.
// No card detect line? Assume the card is inserted.
#define IS_SD_INSERTED true
#endif
#else
#define IS_SD_PRINTING (false)
#define IS_SD_FILE_OPEN (false)
extern CardReader card;
#endif // SDSUPPORT
#endif // __CARDREADER_H
#if ENABLED(SDSUPPORT)
#define IS_SD_PRINTING (card.sdprinting)
#define IS_SD_FILE_OPEN (card.isFileOpen())
#else
#define IS_SD_PRINTING (false)
#define IS_SD_FILE_OPEN (false)
#endif
#endif // _CARDREADER_H_