You've already forked TEF6686_ESP32
Format SPIFFS when it is corrupted
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "config.h"
|
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#include "language.h"
|
|
||||||
|
|
||||||
String UDPlogold = "";
|
String UDPlogold = "";
|
||||||
|
|
||||||
@@ -188,37 +187,42 @@ void handleDownloadCSV() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool handleCreateNewLogbook() {
|
bool handleCreateNewLogbook() {
|
||||||
|
// Quick check if SPIFFS is mounted and accessible
|
||||||
|
if (!SPIFFS.exists("/")) { // "/" should always exist if mounted
|
||||||
|
// SPIFFS not accessible, try to format and remount
|
||||||
|
if (!SPIFFS.format()) {
|
||||||
|
return false; // format failed
|
||||||
|
}
|
||||||
|
if (!SPIFFS.begin()) {
|
||||||
|
return false; // remount failed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the file "logbook.csv" already exists
|
// Check if the file "logbook.csv" already exists
|
||||||
if (SPIFFS.exists("/logbook.csv")) {
|
if (SPIFFS.exists("/logbook.csv")) {
|
||||||
// If it exists, delete the file
|
// If it exists, delete the file
|
||||||
if (!SPIFFS.remove("/logbook.csv")) {
|
if (!SPIFFS.remove("/logbook.csv")) {
|
||||||
// Return false if the file could not be deleted
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new "logbook.csv" file in write mode
|
// Create a new "logbook.csv" file in write mode
|
||||||
fs::File file = SPIFFS.open("/logbook.csv", "w");
|
fs::File file = SPIFFS.open("/logbook.csv", "w");
|
||||||
|
|
||||||
// Check if the file was successfully created
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
// Return false if file creation fails
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the header to the new CSV file
|
// Write the header to the new CSV file
|
||||||
String header = "Date,Time,Frequency,PI,Signal,Stereo,TA,TP,PTY,ECC,PS,Radiotext\n";
|
String header = "Date,Time,Frequency,PI,Signal,Stereo,TA,TP,PTY,ECC,PS,Radiotext\n";
|
||||||
file.print(header); // Ensure that the header is written properly
|
file.print(header);
|
||||||
|
|
||||||
// Make sure the data is written before closing the file
|
file.flush();
|
||||||
file.flush(); // Ensure that everything is written to the file
|
file.close();
|
||||||
file.close(); // Close the file after writing
|
|
||||||
|
|
||||||
|
logcounter = 0;
|
||||||
logcounter = 0; // Reset logcounter
|
|
||||||
EEPROM.writeUInt(EE_UINT16_LOGCOUNTER, logcounter);
|
EEPROM.writeUInt(EE_UINT16_LOGCOUNTER, logcounter);
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
// Return true if the function runs without problems
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "config.h"
|
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
|
|
||||||
void doTouchEvent(uint16_t x, uint16_t y) {
|
void doTouchEvent(uint16_t x, uint16_t y) {
|
||||||
|
|||||||
Reference in New Issue
Block a user