AbstractBeliefs

Untitled

Mar 14th, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. void centreText(char target[], char input[], byte width=LCDWIDTH){
  2.   byte sLen = strlen(input);  // Get the length of the string
  3.   byte spaces = width - sLen; // Find the number of required spaces
  4.  
  5.   byte index = 0;
  6.   for (byte i = 0; i < spaces/2; i++){  // Add the leading padding
  7.     target[index] = ' ';
  8.     index++;
  9.   }
  10.  
  11.   memmove(target+(spaces/2), input, sLen); // move in the string after the spaces
  12.   return;
  13.  }
Advertisement
Add Comment
Please, Sign In to add comment