Hi everyone,
I have created this simple code that writes to the flash memory through a spark.function. I can then read what has been written through a Spark.variable. it seems to work fine but after calling the function about ten or twelve times, the core starts flashing red with 8 flashes between the sos. I believe that means “out of heap memory”. I’m not quite sure how to go about solving this?
#include "flashee-eeprom/flashee-eeprom.h"
using namespace Flashee;
FlashDevice* flash;
char buf1[20];
char bufr[20];
void setup() {
Spark.variable("memdata", &bufr, STRING);
Spark.function("timeset", memupdate);
varset();
/*Serial.begin(9600);
while(!Serial.available()) SPARK_WLAN_Loop();
Serial.println("hello!!!");*/
}
void loop() {
}
int memupdate(String newtriger)
{
FlashDevice* flash = Devices::createAddressErase();
newtriger.toCharArray(buf1, 16);
flash->writeString(buf1, 0);
varset();
return 10;
}
void varset()
{
FlashDevice* flash = Devices::createAddressErase();
flash->read(bufr, 0, 15);
Serial.println(bufr);
}
Thanks for your help.
I’ve edited your post to properly format the code. Please check out this post, so you know how to do this yourself in the future. Thanks in advance! ~Jordy