mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-01 07:22:00 +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
51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
/*
|
|
* Read the logfile created by the eventlog.ino example.
|
|
* Demo of pathnames and working directories
|
|
*/
|
|
#include <SPI.h>
|
|
#include "SdFat.h"
|
|
#include "sdios.h"
|
|
|
|
// SD chip select pin
|
|
const uint8_t chipSelect = SS;
|
|
|
|
// file system object
|
|
SdFat sd;
|
|
|
|
// define a serial output stream
|
|
ArduinoOutStream cout(Serial);
|
|
//------------------------------------------------------------------------------
|
|
void setup() {
|
|
int c;
|
|
Serial.begin(9600);
|
|
|
|
// Wait for USB Serial
|
|
while (!Serial) {
|
|
yield();
|
|
}
|
|
// Initialize at the highest speed supported by the board that is
|
|
// not over 50 MHz. Try a lower speed if SPI errors occur.
|
|
if (!sd.begin(chipSelect, SD_SCK_MHZ(50))) {
|
|
sd.initErrorHalt();
|
|
}
|
|
|
|
// set current working directory
|
|
if (!sd.chdir("logs/2014/Jan/")) {
|
|
sd.errorHalt("chdir failed. Did you run eventlog.ino?");
|
|
}
|
|
// open file in current working directory
|
|
ifstream file("logfile.txt");
|
|
|
|
if (!file.is_open()) {
|
|
sd.errorHalt("open failed");
|
|
}
|
|
|
|
// copy the file to Serial
|
|
while ((c = file.get()) >= 0) {
|
|
cout << (char)c;
|
|
}
|
|
|
|
cout << "Done" << endl;
|
|
}
|
|
//------------------------------------------------------------------------------
|
|
void loop() {} |