Post topics, source code that relate to the Arduino Platform

User avatar
By gavspav
#57130 I can hold one image in ram, so I thought I could just store the arrays in flash memory and load them into ram when necessary. I don't think speed will be an issue for me.

I saved the data via spiffs using a hexeditor and am reading it back but the board is resetting:
soft wdt reset cause 2 bootmode (3,6) (which seems to translate as reset pin, flash
Is this because I'm running out of Ram?

Thanks for the POV tips. I'll check them out. Here's my code:

Code: Select all#include "FS.h"
unsigned int imagearray[7744];
void setup() {
  Serial.begin(115200);

  // always use this to "mount" the filesystem
  bool result = SPIFFS.begin();
  Serial.println("SPIFFS opened: " + result);

  // this opens the file "f.txt" in read-mode
  File f = SPIFFS.open("/f", "r");
 
  if (!f) {
    Serial.println("File doesn't exist");
  } else {
    // we could open the file
    Serial.println("File loaded");
    char buffer[3];
    while(f.available()) {
      for (int i=0;i<7744;i++) {
      //read file into buffer
      f.readBytes(buffer,3);
      imagearray[i]=buffer[0]*65536+(buffer[1]*256)+buffer[2];
    } 
  }
  }
  f.close();
  for (int i=0;i<7744;i++) {
    Serial.println(imagearray[i]);
  }
}

void loop() {
  // nothing to do for now, this is just a simple test

}
User avatar
By martinayotte
#57131 Ah ! Ok !
@mkeyno had higher expectations : Animated POV, using multiple files, kind of video streaming.
In your case, if only 7744 * RGB is needed, if it is already fits into memory, simply throw array in and out into SPIFFS,
Code: Select all      uint8 rgb_buffer[7744 * 3];
      f.read((uint8_t *)rgb_buffer, sizeof(rgb_buffer));
      f.write((uint8_t *)rgb_buffer, sizeof(rgb_buffer));