Yes, that’s why I said it would only be available if the sketch used the Arduboy2 class, which pulls the font table and much of the text generation code in anyway.
The ideal length is going to depend on the actual purpose. (“stored” means stored in a non-volatile way, in this case in EEPROM, such that it survives power cycles):
- A “name” generally only stored once to identify a unit or its owner: e.g. “John Doe”. Since it’s only stored once, it can be quite long.
-
A text ID stored in multiple places, such as in each entry of a high score table. This should be long enough to allow many unique combinations but short enough not to take up too much space. 3 bytes is a common length used for this.
-
An ID used only to differentiate between multiple units for multi-unit/multi-player gaming, as discussed in this topic. This doesn’t even have to be human readable. It should be long enough to uniquely identify a fair number of units but short enough to allow any code written to compare them to be small and efficient. A 16 bit (2 byte) binary value would likely be sufficient for this. Even using only 1 byte would be good for up to 256 units but may require frequent changing to avoid conflicts.
How does this sound?:
Have both a 6 byte text ID and a 2 byte binary ID, making 8 bytes total stored in system EEPROM.
For the text ID, the get/set library functions would each accept a pointer to a null (0x00) terminated string array in RAM provided by the sketch. The allocated array would have to be at least 7 bytes long, to hold up to 6 characters plus a null terminator. It would probably be a good idea to disallow 0xFF, treating it as a null, since that’s the value of an erased EEPROM byte.
If a sketch wanted to pre-populate a high score entry, it could use the first 3 (or whatever) characters of the text ID then allow the user to change it if desired. This is no more difficult for the user than having to enter into a blank field.
For the binary ID, the get function would return a uint16_t and the set function would accept a uint16_t.
// prototypes in Arduboy2.h:
void setUnitName(uint8_t* name);
uint8_t getUnitName(uint8_t* name); // returns the actual length of the string
void setUnitID(uint16_t id);
uint16_t getUnitID();
// usage in sketch:
#include <Arduboy2.h>
Arduboy2 arduboy;
byte unitName[7];
unsigned int unitID;
arduboy.getUnitName(unitName);
arduoby.setUnitName(unitName);
unitID = arduboy.getUnitID();
arduoby.setUnitID(unitID);