 |
ESP3D
3.0
Firmware for ESP boards connected to 3D Printer
|
Go to the documentation of this file.
20 #include "../../../include/esp3d_config.h"
21 #if defined (ARDUINO_ARCH_ESP32) && defined(SD_DEVICE)
22 #if (SD_DEVICE == ESP_SD_NATIVE)
23 #include "../esp_sd.h"
24 #include "../../../core/genLinkedList.h"
25 #include "../../../core/settings_esp3d.h"
31 #define ESP_SPI_FREQ 4000000
37 #if defined(ESP_SD_DETECT_PIN) && ESP_SD_DETECT_PIN != -1
43 #endif //ESP_SD_DETECT_PIN
58 if ( SD.cardSize() > 0 ) {
67 #if (ESP_SD_CS_PIN != -1) || (ESP_SD_MISO_PIN != -1) || (ESP_SD_MOSI_PIN != -1) || (ESP_SD_SCK_PIN != -1)
74 if (_spi_speed_divider <= 0) {
75 _spi_speed_divider = 1;
89 return SD.totalBytes();
94 return SD.usedBytes();
99 return (SD.totalBytes() - SD.usedBytes());
104 return SD.rename(oldpath,newpath);
123 if (path[0] !=
'/') {
129 p.remove(p.lastIndexOf(
'/') +1);
144 if (strcmp(path,
"/") == 0) {
147 res = SD.exists(path);
159 return SD.remove(path);
164 return SD.mkdir(path);
176 while (pathlist.
count() > 0) {
177 File
dir = SD.open(pathlist.
getLast().c_str());
179 bool candelete =
true;
181 if (f.isDirectory()) {
183 String newdir = f.
name();
184 pathlist.
push(newdir);
194 if (pathlist.
getLast() !=
"/") {
195 res = SD.rmdir(pathlist.
getLast().c_str());
222 _iswritemode = iswritemode;
234 if (_name.endsWith(
"/")) {
235 _name.remove( _name.length() - 1,1);
238 if (_name[0] ==
'/') {
241 int pos = _name.lastIndexOf(
'/');
243 _name.remove( 0, pos+1);
245 if (_name.length() == 0) {
266 if (_iswritemode && !_isdir) {
267 File ftmp = SD.open(_filename.c_str());
270 _lastwrite = ftmp.getLastWrite();
282 if ((_index == -1) || !_isdir) {
288 log_esp3d(
"tmp name :%s %s %s", tmp.name(), (tmp.isDirectory())?
"isDir":
"isFile", _filename.c_str());
289 String s = tmp.name() ;
292 ESP_SDFile esptmp(&tmp, tmp.isDirectory(),
false, s.c_str());
302 return _name.c_str();
310 #endif //SD_DEVICE == ESP_SD_NATIVE
311 #endif //ARCH_ESP32 && SD_DEVICE
#define ESP_SDCARD_NOT_PRESENT
static ESP_SDFile open(const char *path, uint8_t mode=ESP_FILE_READ)
ESP_GBFile openNextFile()
static uint64_t totalBytes()
static uint64_t freeBytes()
static bool remove(const char *path)
static bool rmdir(const char *path)
static bool mkdir(const char *path)
const char * name() const
ESP_SDFile openNextFile()
#define ESP_SD_DETECT_VALUE
static uint8_t getState(bool refresh)
ESP_SDFile(void *handle=nullptr, bool isdir=false, bool iswritemode=false, const char *path=nullptr)
static const char * FilesystemName()
static bool format(ESP3DOutput *output=nullptr)
size_t printERROR(const char *s, int code_error=200)
const char * shortname() const
#define log_esp3d(format,...)
static bool rename(const char *oldpath, const char *newpath)
static uint8_t read_byte(int pos, bool *haserror=NULL)
static bool exists(const char *path)
#define ESP_MAX_SD_OPENHANDLE
File tSDFile_handle[ESP_MAX_SD_OPENHANDLE]
#define ESP_SD_DETECT_PIN
static uint64_t usedBytes()