Closed DurvalMenezes closed 10 months ago
Thanks, that's a neat trick! :heart:
The patch here was an incomplete solution and in the wrong place though, so I applied it to a different part of the code to make it cleaner and more robust.
Fixed in e00326a6db6671414b43ee15e092c57ea976102f.
Thanks, that's a neat trick! ❤️
Anytime. I'm glad I could contribute something of value.
The patch here was an incomplete solution and in the wrong place though, so I applied it to a different part of the code to make it cleaner and more robust.
I thought it was just perfect! :-) But seriously, I've just read through your commit (https://github.com/ToyKeeper/anduril/commit/e00326a6db6671414b43ee15e092c57ea976102f), compared it to mine (https://github.com/ToyKeeper/anduril/pull/4/commits/c4d6d744513f9da8caa0324607fe215fb28f4c8b) and I can see what you mean:
"incomplete" because my patch (as I noted) only worked when EEPROM_SIZE was defined in the AVR header files, while yours tries and calculates it from other macros when it isn't;
"in the wrong place" because, instead of checking the size of the struct to be written to the EEPROM right after it being defined (in ui/anduril/load-save-config-fsm.h as I did), it's more generic to do it infsm/eeprom.h, and it additionally handles USE_EEPROM_WL (splits EEPROM in half for wear levelling) which I wasn't aware of.
Thanks for your comment, now that I analyzed it I think I understand Anduril a little better.
As per the subject. Works automatically whenever the manufacturer's DFP include files define EEPROM_SIZE (it's not defined for all of them), so in case the EEPROM capacity is exceeded (ie, we try to store more code there than can fit), causes a compile-time error and at the same time has zero run-time overhead.
EDIT: has been extracted from my 8C-Quick_Aux_Switch mod, as they're completely independent of each other, and so they can be considered separately.