 File myFile;
 File myFile1;
 File myFile2;
+
 RRDSD archiveRRD;//
 RRDSD archiveRRD2;
-
 RRDSD myRRD;//
 
-char timestampchar[19];
 char dataBuffer[3];
 char timestampBuffer[19]; 
-
- 
-
 
 int average(int intArray[], int length)
 {

    return;
  }
  Serial.println(F("initialization done."));
  
  //archiveRRD.resetFile();
  //myRRD.resetFile();
  //SD.remove("testArch.txt");
  //SD.remove("testRRD.txt");
  
  //archiveRRD.resetFile();
  archiveRRD2 = RRDSD("testArc2.txt",4,12,22,2);
  archiveRRD = RRDSD("testArch.txt",2,4,22,2,&archiveRRD2,&average);
  myRRD = RRDSD("testRRD.txt",1,2,22,2,&archiveRRD,&average);
  myRRD.resetFile();
  archiveRRD.resetFile();
  archiveRRD2.resetFile();
  
  //Serial.println(myRRD.getLength());
  //Serial.println(myRRD.getArchiveLength());

  //archiveRRD.log("50");
  /*
  myRRD.log("80");
  myRRD.log("75");
  myRRD.log("60");
  myRRD.log("90");
  myRRD.log("20");
  //myRRD.log("90");
  */
  
 
  
  
  
//  // open the file. note that only one file can be open at a time,
//  // so you have to close this one before opening another.
//  myFile = SD.open("test.txt", FILE_WRITE);
//  
//  // if the file opened okay, write to it:
//  if (myFile) {
//    myFile.seek(0);
//    Serial.print("Position: ");
//    Serial.println(myFile.position());
//    
//    Serial.print("Writing to test.txt...");
//    
//    myFile.println("testing 1, 2, 3");
//	// close the file:
//    
//    Serial.println("done.");
//    Serial.print("Position: ");
//    Serial.println(myFile.position());
//    myFile.close();
//  } else {
//    // if the file didn't open, print an error:
//    Serial.println("error opening test.txt");
//  }
//  
//  // re-open the file for reading:
//  myFile = SD.open("test.txt");
//  if (myFile) {
//    Serial.println("test.txt:");
//    
//    // read from the file until there's nothing else in it:
//    while (myFile.available()) {
//    	Serial.write(myFile.read());
//    }
//    // close the file:
//    myFile.close();
//  } else {
//  	// if the file didn't open, print an error:
//    Serial.println("error opening test.txt");
//  }
}

void loop()
{
  
//  String timestamp=String(hour());
//  timestamp+=":";
//  timestamp+=String(minute());
//  timestamp+=":";
//  timestamp+=String(second());
//  timestamp+=",";
//  timestamp+=String(day());
//  timestamp+="/";
//  timestamp+=String(month());
//  timestamp+="/";
//  timestamp+=String(year());
//  char timestampchar[timestamp.length()+1];
//  timestamp.toCharArray(timestampchar, timestamp.length()+1);
   getTimestamp(&timestampchar[0]);
  Serial.println(timestampchar);
  //Serial.print(F("freeMemory()="));Serial.println(freeMemory());
    boolean archive = myRRD.log("50",&timestampchar[0], &dataBuffer[0], &timestampBuffer[0]);
  if (archive){
    //Serial.print(F("freeMemory()="));Serial.println(freeMemory());
    //Serial.print(F("databuffer: ")); Serial.println(dataBuffer);

   archiveRRD2.log(&dataBuffer[0],&timestampBuffer[0]); 
  }
  }

  
  Serial.print(F("freeMemory()="));Serial.println(freeMemory());
   
