reconstructing 3 byte array to long after EEPROM read


i have written program saves 3 axis encoder information eeprom when arduino mega powers down. not waste unneeded eeprom writes. this, had break 3 signed long 3 bytes each (although considering changing unsigned). 9 bytes. via way,
code: [select]
     location[0] = numberx & 0xff;
     location[1] = (numberx >> 8) & 0xff;
     location[2] = (numberx >> 16) & 0xff; // last bit x coordinate
     location[3] = numbery & 0xff;
     location[4] = (numbery >> 8) & 0xff;
     location[5] = (numbery >> 16) & 0xff; // last bit y coordinate
     location[6] = numberz & 0xff;
     location[7] = (numberz >> 8) & 0xff;
     location[8] = (numberz >> 16) & 0xff; // last bit z coordinate

in void setup() read eeprom see if information encoders saved , is. , put 9 byte array
code: [select]
   for(int r = 0; r < 9;r++){
   eread[r] = eeprom.read(r);}
   this see.
code: [select]
16    47    1    191    167    0    186    93    0 have tried bitshift other way whacky results not putting numbers original format i.e. x,y,z 3 bytes each.
code: [select]

  enc[0]=0;
  enc[1] += eread[0] << 16;
  enc[2] += eread[1] << 8;
  no matter keep confusing myself reconstructed numbers near right. not change original numbers read correctly thousandth of millimeter on displays. if use 2 bytes close off appreciated.

a long 4 bytes not three.

just match shifts in reconstruction part shifts in deconstruction part. not doing this.


Arduino Forum > Using Arduino > Programming Questions > reconstructing 3 byte array to long after EEPROM read


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support