modifications mineures
This commit is contained in:
parent
9bcb6805c4
commit
15614f9f1d
91
src/main.cpp
91
src/main.cpp
|
@ -42,6 +42,7 @@ RTC_DS3231 rtc; //déclaration de la rtc
|
|||
unsigned long freq_ecriture = 60000; // durée entre deux écritures sur la carte SD en micro secondes
|
||||
int fichier = 0;
|
||||
char horodatage[25]; //création du tableau pour contenir l'horodatage
|
||||
char fileName[5];
|
||||
|
||||
//////////////////////////////////
|
||||
/* DÉFINITIONS DU DRIVER MOTEUR */
|
||||
|
@ -156,55 +157,6 @@ void stop_moteur() {
|
|||
/// FONCTIONS SD CARD ///
|
||||
/////////////////////////
|
||||
|
||||
void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
|
||||
Serial.printf("Listing directory: %s\n", dirname);
|
||||
|
||||
File root = fs.open(dirname);
|
||||
if(!root){
|
||||
Serial.println("Failed to open directory");
|
||||
return;
|
||||
}
|
||||
if(!root.isDirectory()){
|
||||
Serial.println("Not a directory");
|
||||
return;
|
||||
}
|
||||
|
||||
File file = root.openNextFile();
|
||||
while(file){
|
||||
if(file.isDirectory()){
|
||||
Serial.print(" DIR : ");
|
||||
Serial.println(file.name());
|
||||
if(levels){
|
||||
listDir(fs, file.name(), levels -1);
|
||||
}
|
||||
} else {
|
||||
Serial.print(" FILE: ");
|
||||
Serial.print(file.name());
|
||||
Serial.print(" SIZE: ");
|
||||
Serial.println(file.size());
|
||||
}
|
||||
file = root.openNextFile();
|
||||
}
|
||||
}
|
||||
|
||||
void createDir(fs::FS &fs, const char * path){
|
||||
Serial.printf("Creating Dir: %s\n", path);
|
||||
if(fs.mkdir(path)){
|
||||
Serial.println("Dir created");
|
||||
} else {
|
||||
Serial.println("mkdir failed");
|
||||
}
|
||||
}
|
||||
|
||||
void removeDir(fs::FS &fs, const char * path){
|
||||
Serial.printf("Removing Dir: %s\n", path);
|
||||
if(fs.rmdir(path)){
|
||||
Serial.println("Dir removed");
|
||||
} else {
|
||||
Serial.println("rmdir failed");
|
||||
}
|
||||
}
|
||||
|
||||
void readFile(fs::FS &fs, const char * path){
|
||||
Serial.printf("Reading file: %s\n", path);
|
||||
|
||||
|
@ -253,15 +205,6 @@ void appendFile(fs::FS &fs, const char * path, const char * message){
|
|||
file.close();
|
||||
}
|
||||
|
||||
void renameFile(fs::FS &fs, const char * path1, const char * path2){
|
||||
Serial.printf("Renaming file %s to %s\n", path1, path2);
|
||||
if (fs.rename(path1, path2)) {
|
||||
Serial.println("File renamed");
|
||||
} else {
|
||||
Serial.println("Rename failed");
|
||||
}
|
||||
}
|
||||
|
||||
void deleteFile(fs::FS &fs, const char * path){
|
||||
Serial.printf("Deleting file: %s\n", path);
|
||||
if(fs.remove(path)){
|
||||
|
@ -314,41 +257,13 @@ void testFileIO(fs::FS &fs, const char * path){
|
|||
}
|
||||
|
||||
void sd_init(){
|
||||
if(!SD.begin()){
|
||||
Serial.println("Card Mount Failed");
|
||||
errorCode(1);
|
||||
return;
|
||||
}
|
||||
uint8_t cardType = SD.cardType();
|
||||
|
||||
if(cardType == CARD_NONE){
|
||||
Serial.println("No SD card attached");
|
||||
errorCode(3);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Serial.print("SD Card Type: ");
|
||||
if(cardType == CARD_MMC){
|
||||
Serial.println("MMC");
|
||||
} else if(cardType == CARD_SD){
|
||||
Serial.println("SDSC");
|
||||
} else if(cardType == CARD_SDHC){
|
||||
Serial.println("SDHC");
|
||||
} else {
|
||||
Serial.println("UNKNOWN");
|
||||
} */
|
||||
|
||||
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
|
||||
Serial.printf("SD Card Size: %lluMB\n", cardSize);
|
||||
|
||||
// créer un dossier avec un numéro incrémental
|
||||
|
||||
writeFile(SD, fileName, horodatage );
|
||||
|
||||
}
|
||||
|
||||
void scribe_sd (){
|
||||
fichier ;
|
||||
writeFile(SD, "tr/min", horodatage);
|
||||
appendFile(SD, fileName, horodatage);
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
|
|
Loading…
Reference in a new issue