Save History Sync on flash, still some issues in deleting previous file
This commit is contained in:
@@ -189,10 +189,10 @@ void loop()
|
||||
auto *temp = active_history;
|
||||
active_history = writable_history; // switch active and writable buffers
|
||||
writable_history = temp; // ensure writable_history points to the buffer we just filled
|
||||
dataSaveParams save_params{
|
||||
dataSaveParams save_params {
|
||||
.history = writable_history,
|
||||
.file_path = "ignition_history.csv"};
|
||||
saveHistoryTask(&save_params); // directly call the save task function to save without delay, since we already switched buffers and writable_history is now empty and ready for new data
|
||||
save_history(*writable_history, "ignition_history.csv"); // directly call the save task function to save without delay, since we already switched buffers and writable_history is now empty and ready for new data
|
||||
// if (SAVE_HISTORY_TO_SPIFFS)
|
||||
// if (pdFAIL ==
|
||||
// xTaskCreatePinnedToCore(
|
||||
@@ -220,10 +220,12 @@ void loop()
|
||||
Serial.println("Waiting for data... ");
|
||||
if (!partial_save && counter > 0) // if timeout occurs but we have unsaved data, save it before next timeout
|
||||
{
|
||||
active_history->resize(counter); // resize active history to actual number of records received to avoid saving empty records
|
||||
save_history(*active_history, "ignition_history.csv");
|
||||
active_history->resize(max_history); // resize back to max history size for next data cycle
|
||||
counter = 0; // reset counter after saving
|
||||
partial_save = true;
|
||||
Serial.println("Saving history to SPIFFS...");
|
||||
save_history(*active_history, "ignition_history.csv");
|
||||
first_save = true;
|
||||
}
|
||||
delay(500);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user