mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-07-30 21:52:01 +08:00

* Update WebSocket library * Update SSDP library * Update TFT_eSPI library * Update EspLuaEngine library * Update SDFat library * Change to pioarduino * Make ESP3DMessageFIFO and ESP3DMessage more thread safe * Fix sanity checks for BT * Add some C6 support * Refactor ethernet code * Split Ethernet Sta / WiFi sta ESP Commands and settings * Simplify wait and wdtFeed code * Set C3 with 4MB by default in platformio.ini * Apply Disable brown out only on ESP32 to avoid crash e.g:ESP32S3 * Add missing entries in platformio.ini
61 lines
1.4 KiB
C++
61 lines
1.4 KiB
C++
// Create a text file on the SD with this path using short 8.3 names.
|
|
#define SFN_PATH "/DIR/TEST.TXT"
|
|
|
|
// Modify CS_PIN for your chip select pin.
|
|
#define CS_PIN SS
|
|
|
|
// Set USE_SD_H to one for SD.h or zero for SdFat.
|
|
#define USE_SD_H 0
|
|
|
|
#if USE_SD_H
|
|
#include "SD.h"
|
|
File file;
|
|
#else
|
|
#include "SdFat.h"
|
|
// Setting ENABLE_DEDICATED_SPI to zero saves over 200 more bytes.
|
|
#if ENABLE_DEDICATED_SPI
|
|
#warning \
|
|
"Set ENABLE_DEDICATED_SPI zero in SdFat/src/SdFatConfig.h for minimum size"
|
|
#endif // ENABLE_DEDICATED_SPI
|
|
// Insure FAT16/FAT32 only.
|
|
SdFat32 SD;
|
|
// FatFile does not support Stream functions, just simple read/write.
|
|
FatFile file;
|
|
#endif
|
|
|
|
void error(const char* msg) {
|
|
Serial.println(msg);
|
|
while (true) {
|
|
}
|
|
}
|
|
void setup() {
|
|
int n;
|
|
char buf[4];
|
|
|
|
Serial.begin(9600);
|
|
while (!Serial) {
|
|
}
|
|
Serial.println("Type any character to begin");
|
|
while (!Serial.available()) {
|
|
}
|
|
|
|
if (!SD.begin(CS_PIN)) error("SD.begin");
|
|
|
|
#if USE_SD_H
|
|
file = SD.open(SFN_PATH);
|
|
if (!file) error("open");
|
|
#else
|
|
// Open existing file with a path of 8.3 names.
|
|
// Directories will be opened O_RDONLY files O_RDWR.
|
|
if (!file.openExistingSFN(SFN_PATH)) error("open");
|
|
#endif
|
|
while ((n = file.read(buf, sizeof(buf)))) {
|
|
Serial.write(buf, n);
|
|
}
|
|
// close() is only needed if you write to the file. For example, read
|
|
// config data, modify the data, rewind the file and write the data.
|
|
// file.close();
|
|
}
|
|
|
|
void loop() {}
|