Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void centreText(char target[], char input[], byte width=LCDWIDTH){
- byte sLen = strlen(input); // Get the length of the string
- byte spaces = width - sLen; // Find the number of required spaces
- byte index = 0;
- for (byte i = 0; i < spaces/2; i++){ // Add the leading padding
- target[index] = ' ';
- index++;
- }
- memmove(target+(spaces/2), input, sLen); // move in the string after the spaces
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment