Due to high demand expect some shipping delays at this time, orders may not ship for 3-4 business days. On MLK Day no orders will be shipped.
0

Saving Images in an External Flash Memory
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Saving Images in an External Flash Memory

by TheArduinoob on Sat Nov 27, 2021 12:03 am

Hi! I'm currently using the Adafruit TTL Camera to take pictures in conjunction with my Arduino (using an ATMEGA328P). I already downloaded the camera's library on GitHub, and am trying to understand one of its examples, which essentially just takes a picture and saves it to an SD card. However, I plan to try and save the images on an external flash memory instead (here's its datasheet.) Any tips on how I could achieve this?

If it helps, I plan to use some libraries to interface with the flash (SPIMemory and SerialFlash; hopefully they work!) However, I think a problem I'm seeing is that I don't think there's a filesystem for flash (or my flash at least. I may be wrong.) Currently wondering if just storing the image data on the memory addresses of the flash without making a file (and retrieving the data the same way) would work. Any thoughts on this too?

For additional reference, shown below is the code snippet mainly responsible for both creating the file in the SD card, as well as performing all the needed reading and writing. What I think I need to do is try to implement what it does but for a flash memory (erase, read, write?)

Code: Select all | TOGGLE FULL SIZE
// Open the file for writing
  File imgFile = SD.open(filename, FILE_WRITE);

  // Get the size of the image (frame) taken 
  uint16_t jpglen = cam.frameLength();
  Serial.print("Storing ");
  Serial.print(jpglen, DEC);
  Serial.print(" byte image.");

  int32_t time = millis();
  pinMode(8, OUTPUT);
  // Read all the data up to # bytes!
  byte wCount = 0; // For counting # of writes
  while (jpglen > 0) {
    // read 32 bytes at a time;
    uint8_t *buffer;
    uint8_t bytesToRead = min((uint16_t)32, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
    buffer = cam.readPicture(bytesToRead);
    imgFile.write(buffer, bytesToRead);
    if(++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up
      Serial.print('.');
      wCount = 0;
    }
    //Serial.print("Read ");  Serial.print(bytesToRead, DEC); Serial.println(" bytes");
    jpglen -= bytesToRead;
  }
  imgFile.close();


Also, as my username suggests, I'm a bit of a noob on coding, so any and all help is greatly appreciated! Thanks in advance!

TheArduinoob
 
Posts: 1
Joined: Fri Nov 26, 2021 11:40 pm

Please be positive and constructive with your questions and comments.