Go Down

Topic: read sd card into multiple arrays (Read 1 time) previous topic - next topic

jchalo99

i have 2 problems... one is deleting a line from a file. the second is reading data into multiple arrays from sd card file.

i have created a device that reads and parses data from serial. so i get data, i convert it into floating point numbers, and save number (and more but not interfering with the problems), the user can hit a delete button that will get rid of the data from the array how should i go about getting it off the sd card? (i am currently using the tinyfat library from http://henningkarlsen.com/electronics/a_l_tinyfat.php)

the next problem is every time the unit resets i have it add the line "reset". is there any way to get the file name to increment? (ex. "data1.txt, data2.txt, etc.) or is there a way to get it to scan for a line "reset" and split into array1, array2 etc.

the end result is i want the unit to take the history of data points (unknown number of both history and points) and graph each ?file? in a different color. say i have 5 "historys" 4 with 50 data points 1 with 25, i want them to be in 5 different colors all on the graph.

johnwasser

My only SD-card experience is with the Adafruif Data Logging Shield.  Their example shows how to generate a new filename:

Code: [Select]

  // create a new file
  char filename[] = "LOGGER00.CSV";
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = i/10 + '0';
    filename[7] = i%10 + '0';
    if (! SD.exists(filename)) {
      // only open a new file if it doesn't exist
      logfile = SD.open(filename, FILE_WRITE);
      break;  // leave the loop!
    }
  }

  if (! logfile) {
    error("couldnt create file");
  }

  Serial.print("Logging to: ");
  Serial.println(filename);


Adafruit also has a tutorial on how to graph data using a spreadsheet (like Open Office or Excel) or Gnuplot on Linux:
http://www.ladyada.net/make/logshield/lighttemp.html
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

jchalo99

thanks for the help with the file names... but i am using the ITDB02-3.2 (http://iteadstudio.com/store/index.php?main_page=product_info&cPath=57_58&products_id=54) to display data, and i have it graphing the data... it is a graphic tft screen. how would i go about reading the data from the files into an array.

Go Up