feat: started game design

This commit is contained in:
2021-12-10 17:15:22 +01:00
parent 94017d771c
commit 7e73a3fbd4
18 changed files with 351 additions and 146 deletions

View File

@@ -21,17 +21,17 @@
void listDir(fs::FS &fs, const char *dirname, uint8_t levels)
{
Serial.printf("Listing directory: %s\r\n", dirname);
log_i("Listing directory: %s\r\n", dirname);
File root = fs.open(dirname);
if (!root)
{
Serial.println("- failed to open directory");
log_e("- failed to open directory");
return;
}
if (!root.isDirectory())
{
Serial.println(" - not a directory");
log_e(" - not a directory");
return;
}
@@ -40,15 +40,14 @@ void listDir(fs::FS &fs, const char *dirname, uint8_t levels)
{
if (file.isDirectory())
{
Serial.print(" DIR : ");
log_i(" DIR : ");
#ifdef CONFIG_LITTLEFS_FOR_IDF_3_2
Serial.println(file.name());
#else
Serial.print(file.name());
time_t t = file.getLastWrite();
struct tm *tmstruct = localtime(&t);
Serial.printf(" LAST WRITE: %d-%02d-%02d %02d:%02d:%02d\n", (tmstruct->tm_year) + 1900, (tmstruct->tm_mon) + 1, tmstruct->tm_mday, tmstruct->tm_hour, tmstruct->tm_min, tmstruct->tm_sec);
log_i("FILE: %s LAST WRITE: %d-%02d-%02d %02d:%02d:%02d\n",file.name(), (tmstruct->tm_year) + 1900, (tmstruct->tm_mon) + 1, tmstruct->tm_mday, tmstruct->tm_hour, tmstruct->tm_min, tmstruct->tm_sec);
#endif
if (levels)
@@ -58,17 +57,13 @@ void listDir(fs::FS &fs, const char *dirname, uint8_t levels)
}
else
{
Serial.print(" FILE: ");
Serial.print(file.name());
Serial.print(" SIZE: ");
#ifdef CONFIG_LITTLEFS_FOR_IDF_3_2
Serial.println(file.size());
#else
Serial.print(file.size());
time_t t = file.getLastWrite();
struct tm *tmstruct = localtime(&t);
Serial.printf(" LAST WRITE: %d-%02d-%02d %02d:%02d:%02d\n", (tmstruct->tm_year) + 1900, (tmstruct->tm_mon) + 1, tmstruct->tm_mday, tmstruct->tm_hour, tmstruct->tm_min, tmstruct->tm_sec);
log_i(" FILE: %s, SIZE: %d LAST WRITE: %d-%02d-%02d %02d:%02d:%02d" ,file.name(), file.size(), (tmstruct->tm_year) + 1900, (tmstruct->tm_mon) + 1, tmstruct->tm_mday, tmstruct->tm_hour, tmstruct->tm_min, tmstruct->tm_sec);
#endif
}
file = root.openNextFile();
@@ -78,16 +73,16 @@ void listDir(fs::FS &fs, const char *dirname, uint8_t levels)
void readFile(fs::FS &fs, const char *path)
{
Serial.printf("Reading file: %s\r\n", path);
log_i("Reading file: %s\r\n", path);
File file = fs.open(path);
if (!file || file.isDirectory())
{
Serial.println("- failed to open file for reading");
log_e("- failed to open file for reading");
return;
}
Serial.println("- read from file:");
log_i("- read from file:");
while (file.available())
{
Serial.write(file.read());
@@ -99,7 +94,7 @@ void initStorage()
{
if (!LITTLEFS.begin(FORMAT_LITTLEFS_IF_FAILED))
{
Serial.println("LITTLEFS Mount Failed");
log_e("LITTLEFS Mount Failed");
return;
}
listDir(LITTLEFS, "/", 0);