-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Current version of displayText function:
void TM1638lite::displayText(String text) {
uint8_t length = text.length();
for (uint8_t i = 0; i < length; i++) {
for (uint8_t position = 0; position < 8; position++) {
displayASCII(position, text[position]);
}
}
}
Has unnecessary for loop and can be reduced to:
void TM1638lite::displayText(String text) {
uint8_t length = text.length();
for (uint8_t position = 0; position < 8 && position < length; position++)
displayASCII(position, text[position]);
}
As of my own testing this change have reduced function execution time by 22millis (from 25millis to 3millis).
This function can be further improved to display "."(dot) symbol next to the previous symbol instead of new symbol:
void TM1638lite::displayText(String text) {
uint8_t length = text.length();
for (uint8_t position = 0; position < 8 && position < length; position++){
if(position+1 < length)
if(text[position+1] == '.'){
displayASCIIwDot(position, text[position]);
text.remove(position,1);
}
else
displayASCII(position, text[position]);
else
displayASCII(position, text[position]);
}
}
void TM1638lite::displayASCIIwDot(uint8_t position, uint8_t ascii) {
displaySS(position, ss[ascii] + 128);
}
Execution time with "."(dot) handling is 3.14millis.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels