<?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[Canvas don&#x27;t work on M5Stack Core 2]]></title><description><![CDATA[<p dir="auto">I'm try run simple code:</p>
<pre><code>import lvgl as lv

def LV_IMG_BUF_SIZE_ALPHA_1BIT(w, h):
    return int(((w / 8) + 1) * h)

def LV_IMG_BUF_SIZE_INDEXED_1BIT(w, h):
    return LV_IMG_BUF_SIZE_ALPHA_1BIT(w, h) + 4 * 2

def LV_CANVAS_BUF_SIZE_INDEXED_1BIT(w, h):
    return LV_IMG_BUF_SIZE_INDEXED_1BIT(w, h)

CANVAS_WIDTH  = 50
CANVAS_HEIGHT = 50

# Create a buffer for the canvas
cbuf= bytearray(LV_CANVAS_BUF_SIZE_INDEXED_1BIT(CANVAS_WIDTH, CANVAS_HEIGHT))

# Create a canvas and initialize its the palette
canvas = lv.canvas(lv.scr_act(), None)
canvas.set_buffer(cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, lv.img.CF.INDEXED_1BIT)
canvas.set_palette(0, lv.color_hex(0x00ff00))
canvas.set_palette(1, lv.color_hex(0xff0000))

# Create colors with the indices of the palette
c0 = lv.color_t()
c1 = lv.color_t()

c0.full = 0
c1.full = 1

# Transparent background
canvas.fill_bg(c1, lv.OPA.TRANSP)

# Create hole on the canvas
for y in range(10,30):
    for x in range(5,20):
        canvas.set_px(x, y, c0)
</code></pre>
<p dir="auto">An error occurs when running the code.</p>
<pre><code>Traceback (most recent call last):
  File "&lt;stdin&gt;", line 19, in &lt;module&gt;
AttributeError: 'NoneType' object has no attribute '__dereference__'
</code></pre>
<p dir="auto">But everything works in the lvgl simulator.</p>
]]></description><link>https://community.m5stack.com/topic/4719/canvas-don-t-work-on-m5stack-core-2</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 12:22:52 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/4719.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 16 Oct 2022 19:26:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Canvas don&#x27;t work on M5Stack Core 2 on Mon, 17 Oct 2022 13:30:59 GMT]]></title><description><![CDATA[<p dir="auto">code:</p>
<pre><code>import lvgl as lv
canvas = lv.canvas(lv.scr_act(), None)
</code></pre>
<p dir="auto">error:</p>
<pre><code>Traceback (most recent call last):
  File "&lt;stdin&gt;", line 2, in &lt;module&gt;
AttributeError: 'NoneType' object has no attribute '__dereference__'
</code></pre>
]]></description><link>https://community.m5stack.com/post/19013</link><guid isPermaLink="true">https://community.m5stack.com/post/19013</guid><dc:creator><![CDATA[pavelprosto]]></dc:creator><pubDate>Mon, 17 Oct 2022 13:30:59 GMT</pubDate></item><item><title><![CDATA[Reply to Canvas don&#x27;t work on M5Stack Core 2 on Sun, 16 Oct 2022 19:43:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/pavelprosto" aria-label="Profile: pavelprosto">@<bdi>pavelprosto</bdi></a> Its very hard to diagnose issue in MP as sometimes the error message does not actually point to the issue!<br />
The error could be<br />
canvas.fill_bg(c1, lv.OPA.TRANSP)</p>
<p dir="auto">or<br />
canvas.set_palette(1, lv.color_hex(0xff0000))</p>
]]></description><link>https://community.m5stack.com/post/18997</link><guid isPermaLink="true">https://community.m5stack.com/post/18997</guid><dc:creator><![CDATA[ajb2k3]]></dc:creator><pubDate>Sun, 16 Oct 2022 19:43:44 GMT</pubDate></item></channel></rss>