I have uploaded a simply sketch that allows you to capture and store a single piece of text into the EEPROM - I have used it for a high score table but I am sure there are a million uses.
In the samepl sketch you will see the constant 123 - this can be changed to whatever EEPROM location you wish. The NAME_LENGTH constant is exactly that - how long should the text be.
I only allow upper and lower case alpha characters and the space but the code can easily be change to expand / shrink that range.
Feel free to use / abuse it … enhancements and feedback welcome.
Nice … except you seem to have screwed up the brackets.
Just kidding, nice enhancements. Do a PR and I will merge it together!
Edit:
constexpr bool isLower(char c)
{
return (c >= 'a' && c <= 'a');
}
… doesn’t look right.
Also, I think I prefer my switches in the incrementChar and decrementChar from a readability point of view. Don’t like x as a loop incrementer - using i is so old school.
I wasn’t intending to necessarily replace the original.
If you’re happy with all my changes then I can make PR if you want,
but the point was more for the sake of practice.
That said, I would definately class the templating, removal of macros and minor change to the loading code as improvements.
(The loading code change was because when I ran it I was getting things like pilcrows turning up.)
Yep, my finger slipped.
I don’t like using compiler extensions if I can avoid it.
Except that case ASCII_CAPITAL_A ... ASCII_CAPITAL_Y: is non-standard syntax and won’t work on other compilers.
Not unless it’s a coordinate and/or there’s a corresponding y. :P
Only the EEPROM bit is Arduino specific,
I could see rest of the NameEditor class being ported to something else.
But more importantly I’m worried about less experienced programmers looking at the code and thinking “I didn’t know you could do that”, getting into the habit of using GCC’s case-range syntax and then later having a massive headache when their case-range switches won’t compile on some other platform.