-
Notifications
You must be signed in to change notification settings - Fork 31
functions : setCursor
setCursor(x,y,[optional]);//position text cursor on screen
setCursor(x,y) works only with text and position text to the coordinates x,y but has optional parameters!
Working with optional parameters:
The third parameter is the autocenter flag and is quite effective since it takes count of font scale, spacing and real size of the string, do this type of calculations outside function can be hard and complicated so I have included in the library.
The complete setCursor function is:
setCursor(x,y,[NORM,SCREEN,REL_X,REL_Y,REL_XY]); The third parameter trigger autocenter in conjunction to x,y!
Center on Screen:
- setCursor(CENTER,CENTER,SCREEN); This center text exact in the center of the screen
- setCursor(x,CENTER,SCREEN); This center text in the Y axis but x is still arbitrary.
- setCursor(CENTER,y,SCREEN); This center text in the X axis but Y is still arbitrary.
- setCursor(x,y,SCREEN); Normal position, like setCursor(x,y)
Relative Center:
In this mode DO NOT use CENTER flag or text will fall down to setCursor(CENTER,CENTER,SCREEN)!!!
- setCursor(x,y,REL_X); This center text in the x position, y will still arbitrary.
- setCursor(x,y,REL_Y); This center text in the y position, x will still arbitrary.
- setCursor(x,y,REL_XY); This center text in the x,y position.
There's excetions on when use it?
No. The autocenter flag does his magic by tracking internal parameters but setCursors doesn't actually perform the trick, it just instruct text rendering to new parameters when text has to be printed. For this reason you can use autocenter flag even before text scaling. Of course library cannot write text that goes outside screen so take it in count.
Note
Using the CENTER parameter will always set the autocenter to setCursor([x,CENTER],[y,CENTER],SCREEN);!!!
So do like this: setCursor(CENTER,y); is the same as setCursor(CENTER,y,SCREEN);