<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[drawString() - positioning confusion]]></title><description><![CDATA[<p dir="auto">Working through some examples to learn how to use the screen on my DinMeter...</p>
<p dir="auto">The example code uses the snippet below to display a value manipulated by the encoder knob - the numeric text is always centered on the display...</p>
<pre><code>DinMeter.Display.drawString(String(newPosition),
                                              DinMeter.Display.width() / 2,
                                              DinMeter.Display.height() / 2);
</code></pre>
<p dir="auto">Researching the functions, it seems like <strong>drawCentreString()</strong> should do that ???  Shouldn't drawString() reference the top left of the current setTextDatum() command?  If I need to display text in a specific area, how do you code that?</p>
<p dir="auto">PS - looks like I'm the only one here lol</p>
]]></description><link>https://community.m5stack.com/topic/7410/drawstring-positioning-confusion</link><generator>RSS for Node</generator><lastBuildDate>Mon, 09 Mar 2026 23:43:34 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/7410.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 Mar 2025 18:22:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to drawString() - positioning confusion on Thu, 20 Mar 2025 21:30:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/86465">@TomKatt</a> BTW, I love your Blown Away by Maxell.<br />
The ‘Canvas’ is M5’s name for TFT_eSPI !<br />
Keep up the good work!</p>
]]></description><link>https://community.m5stack.com/post/28576</link><guid isPermaLink="true">https://community.m5stack.com/post/28576</guid><dc:creator><![CDATA[teastain]]></dc:creator><pubDate>Thu, 20 Mar 2025 21:30:06 GMT</pubDate></item><item><title><![CDATA[Reply to drawString() - positioning confusion on Thu, 20 Mar 2025 20:45:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/7508">@teastain</a><br />
Found the issue - this was hidden in the Setup routine:</p>
<pre><code>DinMeter.Display.setTextDatum(middle_center);
</code></pre>
<p dir="auto">The default is top left as expected, this line overrides the code below.  Problem solved - user error strikes again lol</p>
<p dir="auto">On the topic of different libraries - I note you have suggested the Canvas API before...  Is this preferred over the TFT_eSPI API ?</p>
<p dir="auto">Thanks!</p>
]]></description><link>https://community.m5stack.com/post/28575</link><guid isPermaLink="true">https://community.m5stack.com/post/28575</guid><dc:creator><![CDATA[TomKatt]]></dc:creator><pubDate>Thu, 20 Mar 2025 20:45:55 GMT</pubDate></item><item><title><![CDATA[Reply to drawString() - positioning confusion on Thu, 20 Mar 2025 20:01:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/7508">@teastain</a><br />
Hello again!</p>
<p dir="auto">Yes, I've been experimenting and replaced the references to the display width and height with literal values and the result was as expected - the specified xy position is the center of the drawn string.  Beyond the confusion of expecting xy to locate the string by upper left corner, the <a href="https://github.com/m5stack/m5-docs/blob/master/docs/en/api/lcd.md" target="_blank" rel="noopener noreferrer nofollow ugc">API</a> states this is how <a href="https://docs.m5stack.com/en/arduino/m5core2/lcd_api" target="_blank" rel="noopener noreferrer nofollow ugc">drawString()</a> should work...</p>
<pre><code>drawString()
Description:

Draw a character

Syntax:

drawString(const char *string, int32_t poX, int32_t poY, uint8_t font);

drawString(const char *string, int32_t poX, int32_t poY);

drawString(const String&amp; string, int32_t poX, int32_t poY, uint8_t font);

drawString(const String&amp; string, int32_t poX, int32_t poY);

Function argument:

argument	type	Description
**poX	int32_t	Coordinate X (upper left)**
**poY	int32_t	Coordinate Y (upper left)**
string	const char * / String &amp;	String
font	uint8_t	1: If use the loaded font
Function return value:

None
</code></pre>
]]></description><link>https://community.m5stack.com/post/28574</link><guid isPermaLink="true">https://community.m5stack.com/post/28574</guid><dc:creator><![CDATA[TomKatt]]></dc:creator><pubDate>Thu, 20 Mar 2025 20:01:28 GMT</pubDate></item><item><title><![CDATA[Reply to drawString() - positioning confusion on Thu, 20 Mar 2025 19:28:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/86465">@TomKatt</a> Sure, there's lots of us  here.</p>
<p dir="auto">You have to consider the world is on a 24hr cycle.<br />
I would help you but it would not be what you want.<br />
This is TFT_eSPI  one of the most famous graphics drivers:<br />
GFX, LVGL, TFT_eSPI .<br />
LOTS of reference and examples.<br />
As I said you have a M5StampS3 which is an ESP32 S3 wth a ST7789V2 LCD, also very common. All small M5Stack products use it. The one from the CardPuter will work in an old StickCPlus.<br />
Here is the Canvas API:<br />
<a href="https://docs.m5stack.com/en/arduino/m5gfx/m5gfx_canvas" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.m5stack.com/en/arduino/m5gfx/m5gfx_canvas</a></p>
<p dir="auto">Have you tried replacing<br />
DinMeter.Display.width() / 2, DinMeter.Display.height() / 2);<br />
with literals, like 50, 50?<br />
Experiment, research, have fun.</p>
]]></description><link>https://community.m5stack.com/post/28573</link><guid isPermaLink="true">https://community.m5stack.com/post/28573</guid><dc:creator><![CDATA[teastain]]></dc:creator><pubDate>Thu, 20 Mar 2025 19:28:17 GMT</pubDate></item></channel></rss>