Feature/custom charset - #24
Conversation
…n changing characters
|
Been running this branch on an 8 module display for a while — thanks for it, the custom charset is genuinely useful. One thing I ran into that you may want to look at: the constructor derives the flap count from the length of the string, and never reads the if (len < 37) {
charSetSize = numChars = 37; // charsetSize ignored
} else if (len >= 37) {
charSetSize = numChars = (len >= 48) ? 48 : 37; // charsetSize ignored
} else {
// unreachable: len < 37 and len >= 37 already cover everything
}Two consequences:
The settings page already validates that the string length equals What worked for me is letting charSetSize = numChars = (charsetSize == 48) ? 48 : 37;
if ((int) charsetStr.length() == numChars) {
usingCustomChars = true;
for (int i = 0; i < numChars; i++) {
customChars[i] = charsetStr[i];
}
} else {
usingCustomChars = false;
const char *fallback = (numChars == 48) ? ExtendedChars : StandardChars;
for (int i = 0; i < numChars; i++) {
customChars[i] = fallback[i];
}
// ...and say so on serial, so a mismatch is diagnosable
}
customChars[numChars] = '\0';A mismatched string then falls back to the built-in set for the size you actually selected, instead of quietly changing the size. Also drops the unreachable third branch. Happy to open this as a PR against your branch if it's useful — didn't want to push at your work uninvited. |
No description provided.