Advertisement
Munt

Hurray !! Thanks Duncan C

Oct 6th, 2014
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. void reJigFromMemory(){
  2.  
  3.   Serial.print("Eeprom read 1 :");
  4.   Serial.println(eepromReadOne);
  5.   Serial.print("EEprom read 2 :");
  6.   Serial.println(eepromReadTwo);
  7.   int tempArray[10];
  8.  
  9.   int charLength=eepromReadOne.length()+1;
  10.   char charBuff[charLength];
  11.   eepromReadOne.toCharArray(charBuff, charLength);
  12.  
  13. // new int version
  14.   int firstCharToInt,secondCharToInt;
  15.  
  16.   for (int i = 0; i <10 ; i++){
  17.     firstCharToInt=charBuff[i*2];
  18.     secondCharToInt=charBuff[(i*2)+1];
  19.     tempArray[i]=((firstCharToInt-'0')*10)+(secondCharToInt-'0');
  20.     Serial.print("I just translated :");
  21.     Serial.println(tempArray[i]);
  22.   }
  23.    
  24.   String tempArray2[10];
  25.   int fromLocation = 0;
  26.   int toLocation=0;
  27.  
  28. // updated to reflect Duncan C's suggestions
  29.  for (int i = 0; i <10 ; i++)
  30. {        
  31.  
  32.     toLocation += tempArray[i];
  33.  
  34.     tempArray2[i]=eepromReadTwo.substring(fromLocation,toLocation);
  35.     Serial.print("From Number = :");
  36.     Serial.println(fromLocation);
  37.     Serial.print("To number : ");
  38.     Serial.println(toLocation);
  39.     Serial.print("I just translated :");
  40.     Serial.println(tempArray2[i]);
  41.     fromLocation += tempArray[i];
  42.   }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement