Skip to content

Commit 2993a5a

Browse files
committed
Initial changes - WIP
1 parent 5501e78 commit 2993a5a

File tree

3 files changed

+96
-7
lines changed

3 files changed

+96
-7
lines changed

esp3d/src/modules/filesystem/esp_sd.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <time.h>
2424

2525
#include "esp_sd.h"
26-
26+
/*
2727
#define ESP_MAX_SD_OPENHANDLE 4
2828
#if (SD_DEVICE == ESP_SD_NATIVE) && defined(ARDUINO_ARCH_ESP8266)
2929
#define FS_NO_GLOBALS
@@ -138,6 +138,8 @@ bool ESP_SD::disableSharedSD() {
138138
bool ESP_SD::_started = false;
139139
uint8_t ESP_SD::_state = ESP_SDCARD_NOT_PRESENT;
140140
uint8_t ESP_SD::_spi_speed_divider = 1;
141+
*/
142+
141143
bool ESP_SD::_sizechanged = true;
142144
uint8_t ESP_SD::setState(uint8_t flag) {
143145
_state = flag;

esp3d/src/modules/filesystem/esp_sd.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,9 @@
2020

2121
#ifndef _ESP_SD_H
2222
#define _ESP_SD_H
23-
#include <time.h>
2423

25-
#include "../../core/esp3d_message.h"
2624
#include "../../include/esp3d_config.h"
27-
28-
#define ESP_SD_FS_HEADER "/SD"
29-
30-
#define ESP_MAX_SD_OPENHANDLE 4
25+
#include "sd/esp_sd_common.h"
3126

3227
class ESP_SDFile {
3328
public:
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
esp_sd_common.h - ESP3D SD support class
3+
4+
Copyright (c) 2014 Luc Lebosse. All rights reserved.
5+
6+
This code is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This code 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 GNU
14+
Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with This code; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
21+
#pragma once
22+
#include "../../../include/esp3d_config.h"
23+
24+
#define ESP_SD_FS_HEADER "/SD"
25+
26+
#define ESP_MAX_SD_OPENHANDLE 4
27+
28+
namespace ESP3D_SD {
29+
30+
#if (SD_DEVICE == ESP_SD_NATIVE) && defined(ARDUINO_ARCH_ESP8266)
31+
#define FS_NO_GLOBALS
32+
#define NO_GLOBAL_SD
33+
#include <SD.h>
34+
using ESP3D_File = fs::File;
35+
using ESP3D_SD_Class = SDClass;
36+
#endif // (SD_DEVICE == ESP_SD_NATIVE) && defined(ARDUINO_ARCH_ESP8266
37+
38+
#if ((SD_DEVICE == ESP_SDFAT) || (SD_DEVICE == ESP_SDFAT2)) && defined(ARDUINO_ARCH_ESP8266)
39+
#define FS_NO_GLOBALS
40+
#define NO_GLOBAL_SD
41+
#include <SdFat.h>
42+
#if SDFAT_FILE_TYPE == 1
43+
using ESP3D_File = File32;
44+
#elif SDFAT_FILE_TYPE == 2
45+
using ESP3D_File = ExFile;
46+
#elif SDFAT_FILE_TYPE == 3
47+
using ESP3D_File = FsFile;
48+
#else // SDFAT_FILE_TYPE
49+
#error Invalid SDFAT_FILE_TYPE
50+
#endif // SDFAT_FILE_TYPE
51+
using ESP3D_SD_Class = SdFat;
52+
#endif // ((SD_DEVICE == ESP_SDFAT) || (SD_DEVICE == ESP_SDFAT2)) && defined(ARDUINO_ARCH_ESP8266
53+
54+
#if ((SD_DEVICE == ESP_SDFAT) || (SD_DEVICE == ESP_SDFAT2)) && defined(ARDUINO_ARCH_ESP32)
55+
#define FS_NO_GLOBALS
56+
#define NO_GLOBAL_SD
57+
#include <SdFat.h>
58+
#if SDFAT_FILE_TYPE == 1
59+
using ESP3D_File = File32;
60+
#elif SDFAT_FILE_TYPE == 2
61+
using ESP3D_File = ExFile;
62+
#elif SDFAT_FILE_TYPE == 3
63+
using ESP3D_File = FsFile;
64+
#else // SDFAT_FILE_TYPE
65+
#error Invalid SDFAT_FILE_TYPE
66+
#endif // SDFAT_FILE_TYPE
67+
using ESP3D_SD_Class = SdFat;
68+
#endif // ((SD_DEVICE == ESP_SDFAT) || (SD_DEVICE == ESP_SDFAT2)) && defined(ARDUINO_ARCH_ESP32
69+
70+
#if (SD_DEVICE == ESP_SD_NATIVE) && defined(ARDUINO_ARCH_ESP32)
71+
#define FS_NO_GLOBALS
72+
#define NO_GLOBAL_SD
73+
#include <FS.h>
74+
#include <SD.h>
75+
using ESP3D_File = fs::File;
76+
using ESP3D_SD_Class = SDFileSystem;
77+
#endif // (SD_DEVICE == ESP_SD_NATIVE) && defined(ARDUINO_ARCH_ESP32
78+
79+
#if (SD_DEVICE == ESP_SDIO) && defined(ARDUINO_ARCH_ESP32)
80+
#define FS_NO_GLOBALS
81+
#define NO_GLOBAL_SD
82+
#include <FS.h>
83+
#include <SD_MMC.h>
84+
using ESP3D_File = fs::File;
85+
using ESP3D_SD_Class = SDMMCFS;
86+
#endif // (SD_DEVICE == ESP_SDIO) && defined(ARDUINO_ARCH_ESP32
87+
88+
89+
extern ESP3D_SD_Class ESP3D_SD_Card;
90+
extern ESP3D_File tSDFile_handle[ESP_MAX_SD_OPENHANDLE];
91+
92+
}

0 commit comments

Comments
 (0)