Here is the code I am using to perform the save:
Code: Select all
void saveActiveSequence(uint8_t as, char *filename)
{
File file;
if(file = arcada.open(filename, FILE_READ))
{
StaticJsonDocument<2048> doc;
yield();
DeserializationError error = deserializeJson(doc, file);
yield();
serializeJson(doc, Serial);
if(error)
{
Serial.println("Sequence save error.");
Serial.println(error.c_str());
}
else
{
file.close();
file = arcada.open(filename, FILE_WRITE);
Serial.print("Storing: ");Serial.println(as);
doc["activeSequence"] = as;
size_t serror = serializeJson(doc, Serial);
serror = serializeJson(doc, file);
if(serror == 0)
{
Serial.println("Failed to write to file.");
}
else
{
Serial.print("Saved: ");Serial.println(serror);
}
}
file.close();
}
}
Here is the contents of the file:ArcadaFileSys : open cwd '//sequence.eye'
{"hazel":10,"fish_eyes":10,"demon":10,"doom-red":10}
ArcadaFileSys : open cwd '//sequence.eye'
Storing: 3
{"hazel":10,"fish_eyes":10,"demon":10,"doom-red":10,"activeSequence":3}Saved: 71
Code: Select all
{
"hazel" : 10,
"fish_eyes":10,
"demon":10,
"doom-red":10
}
Thanks!