<?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[Display.drawRawBuf example in UIFlow docs doesn&#x27;t work on M5StickC Plus2]]></title><description><![CDATA[<p dir="auto">Hi, I'm a new user of M5stack products, having got an M5StickC Plus2 recently. It's a nice device, but the documentation isn't always accurate which makes learning how to use it a slow process.<br />
I tried to use the example for drawing a raw buffer to the screen <a href="https://uiflow-micropython.readthedocs.io/en/2.4.2/hardware/display.html#Display.M5.Display.drawRawBuf" target="_blank" rel="noopener noreferrer nofollow ugc">here</a><br />
But it resulted in different garbled output each time and not a green rectangle.<br />
It seems that the len parameter is expecting 16-bit entries in the buffer so needs to be halved.<br />
Here's the code that works on my device (note the //2 for len parameter):</p>
<pre><code>width, height = 40, 30
green565 = 0x07E0
raw_buf = bytearray(width * height * 2)
for i in range(width * height):
    raw_buf[2*i]   = (green565 &gt;&gt; 8) &amp; 0xFF
    raw_buf[2*i+1] = green565 &amp; 0xFF
Display.drawRawBuf(raw_buf, 100, 100, width, height, len(raw_buf)//2, swap=False)
</code></pre>
<p dir="auto">Hopefully this will help others and eventually get changed in the docs - assuming it's the same for all UIFlow2 supported devices?</p>
<p dir="auto">If anybody knows a fix to make it work properly for lower than 16bit depth screens so I can draw a raw buffer to a 1-bit canvas properly, please let me know!</p>
]]></description><link>https://community.m5stack.com/topic/8159/display-drawrawbuf-example-in-uiflow-docs-doesn-t-work-on-m5stickc-plus2</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 04:48:21 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/8159.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 26 Mar 2026 11:29:04 GMT</pubDate><ttl>60</ttl></channel></rss>