arduino / Arduino

Arduino IDE 1.x
https://www.arduino.cc/en/software
Other
14.14k stars 7.01k forks source link

Error in the description of the library EEPROM.get () #3841

Open pakhontas opened 9 years ago

pakhontas commented 9 years ago

https://docs.arduino.cc/learn/built-in-libraries/eeprom#get

Now:

eeAddress = sizeof(float); //Move address to the next byte after float 'f'.

Need:

eeAddress += sizeof(float); //Move address to the next byte after float 'f'.
Chris--A commented 9 years ago

As the initial value is zero, adding sizeof(float) is no different to making it equal to sizeof(float). It is still moving to the byte after f.

pakhontas commented 9 years ago

In this case comment to row is wrong It's not move. in this description, I think more accurately comment: https://www.arduino.cc/en/Reference/EEPROMPut (eeAddress += sizeof(float);)

Chris--A commented 9 years ago

Yes, the address 'pointer' is moving to the location specified by the comment. Whether its explicit or compounded is irrelevant.

If its a confusing issue, I can however certainly modify my examples to alleviate this. I have an update to my library which fixes all warnings and improves performance. I'll change this over and the documentation can be updated once proposed & accepted.

pakhontas commented 9 years ago

if first value of eeAddress set to not zero. code in Get() becomes wrong. If you think that just fine, of course, that is your right. but I think that + = is understandable. thank.

Chris--A commented 9 years ago

Of course, there is an issue if the previous address is not 0. I guess for a newbie point of view, its always best to follow 'KISS' principles. I will update the bundled examples with my update.

pakhontas commented 9 years ago

Yes, it would be better for LEARNING section.