How to center a text?
- 
					
					
					
					
 Hello everyone, 
 Quiz, I have a question, how can I do to center my text on the screen.My code:void Display_WiFi_Connected() { 
 M5.Lcd.clear(BLACK);
 M5.Lcd.setTextSize(2);
 M5.Lcd.print("M5Stack has been connected");
 }I know I can use the function M5.Lcd.setCursor(); but I would like it to center my text according to its size ???? 
 Thanks
- 
					
					
					
					
 use: 
 setTextDatum(uint8_t datum);https://github.com/m5stack/M5Stack/blob/master/src/utility/In_eSPI.h#L554 and available options: 
 https://github.com/m5stack/M5Stack/blob/master/src/utility/In_eSPI.h#L331
- 
					
					
					
					
 Thank you so much, I did'nt see this function 
 But where should I put the function in my code?void Display_WiFi_Connected() { 
 M5.Lcd.clear(BLACK);
 M5.Lcd.setTextSize(2);
 M5.Lcd.print("M5Stack has been connected");
 }
- 
					
					
					
					
 @pépémax 在 How to center a text? 中说: Hello everyone, 
 Quiz, I have a question, how can I do to center my text on the screen.My code:void Display_WiFi_Connected() { 
 M5.Lcd.clear(BLACK);
 M5.Lcd.setTextSize(2);
 M5.Lcd.print("M5Stack has been connected");
 }I know I can use the function M5.Lcd.setCursor(); but I would like it to center my text according to its size ???? 
 ThanksTry this: M5.Lcd.drawCentreString("your string", x, y, font); So your code should be: M5.Lcd.drawCentreString("M5Stack has been connected", 160, 120, 2); to write a string size 2 on the center of the screen. You also have the option to write a right aligned string. I love reading C++ headers :) 
- 
					
					
					
					
 For safe use in the future, better way is: void Display_WiFi_Connected() { M5.Lcd.clear(BLACK); M5.Lcd.setTextDatum(CC_DATUM); M5.Lcd.drawString("M5Stack has been connected", 160, 120, 2); }because drawCentreString is marked as deprecated 
- 
					
					
					
					
 
- 
					
					
					
					
 what is your screen orientation? landscape or portrait ?? 
 where is your text?
 try to swap values 160 with 120 for portrait mode
 or use this instead:M5.Lcd.drawString("M5Stack has been connected", (int)(M5.Lcd.width()/2), (int)(M5.Lcd.height()/2), 2);which calculates values for current orientation. I do not have hw for tests 
- 
					
					
					
					
 Excuse me but it's my fault 
- 
					
					
					
					
 but it's working or not? 
- 
					
					
					
					
 Yes yes it's working 
