Pointer struct on Ir Library

Hi to everyone. I have a project where I need to save different IR codes in the EEPROM to use them later. The EEPROM is not my problem right now. I'm using the IR library.

This is my function:

decode_results results;

//setup, void, etc.

void getCode(decode_results *results)
{
  int  posicion = (datoTv-1)*8;
  codeByte4=EEPROM.read(posicion);
  codeByte3=EEPROM.read(posicion+1);
  codeByte2=EEPROM.read(posicion+2);
  codeByte1=EEPROM.read(posicion+3);
  typeByte2=EEPROM.read(posicion+4);
  typeByte1=EEPROM.read(posicion+5);
  lenByte2 =EEPROM.read(posicion+6);
  lenByte1 =EEPROM.read(posicion+7);
  
  results->value = (((codeByte1 << 0) & 0xFF) + ((codeByte2 << 8) & 0xFFFF) + ((codeByte3 << 16) & 0xFFFFFF) + ((codeByte4 << 24) & 0xFFFFFFFF));
  results->bits = (((lenByte1 << 0) & 0xFF) + (lenByte2 << 8));
  results->decode_type = (((typeByte1 << 0) & 0xFF) + (typeByte2 << 8));
}

Nevermind the bit operations, that's ok. My problem is that I can't modify the struct values (value, bits, and decode_type). Those values are only modified when I recieve a new code, so the struct only holds the last code I recieve.

On the library example I have:

if (irrecv.decode(&results))
    storeCode(&results);

So I believe the struct values are modified when I call irrecv.decode(&results).

How can I modify the struct, like writing the data I hold in the EEPROM to the fields value, bits and decode_type?? I think I'm messing with the & and * :confused:

Thank you veery much

monti73:
Hi to everyone. I have a project where I need to save different IR codes in the EEPROM to use them later. The EEPROM is not my problem right now. I'm using the IR library.

<...>
How can I modify the struct, like writing the data I hold in the EEPROM to the fields value, bits and decode_type?? I think I'm messing with the & and * :confused:

Thank you veery much

Maybe a Union where you declare a 32-bit and two 16-bit vars

That way you can shift bits within the union rather than your current struct. But I have no idea if the compiler will barf because of the explicit read-only nature of the existing struct.

Ray