<?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[EXT.IO Unit ERROR problem]]></title><description><![CDATA[<p dir="auto">I have spent several hours trying to use an Extend IO Unit with M5Stack Fire (and also tried an M5Stack Grey) but when running any simple UIFlow code including the '<a href="http://EXT.IO" target="_blank" rel="noopener noreferrer nofollow ugc">EXT.IO</a> Unit' I get the error below.  It looks like there is a bug in the 'import unit' library or am I missing something!<br />
Can someone please point me in the right direction?</p>
<p dir="auto">Python code:<br />
from m5stack import *<br />
from m5ui import *<br />
from uiflow import *<br />
import unit</p>
<p dir="auto">setScreenColor(0x222222)<br />
ext_io0 = unit.get(unit.EXT_IO, unit.PORTA)</p>
<p dir="auto">Error on M5Stack display:<br />
ERROR<br />
local variable referenced before assignment</p>
<p dir="auto">Details:<br />
File "&lt;string&gt;", line 7, in &lt;module&gt;<br />
File "<a href="http://unit.py" target="_blank" rel="noopener noreferrer nofollow ugc">unit.py</a>", line 97, in get<br />
File "&lt;string&gt;", line 1, in &lt;module&gt;<br />
File "units/_ext_io.py", line 20 in <strong>init</strong><br />
File "units/_ext_io.py", line 25 in _available</p>
]]></description><link>https://community.m5stack.com/topic/2063/ext-io-unit-error-problem</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 05:35:32 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/2063.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 22 Jun 2020 12:17:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to EXT.IO Unit ERROR problem on Wed, 28 Oct 2020 08:09:04 GMT]]></title><description><![CDATA[<p dir="auto">this bug has been fixed.</p>
]]></description><link>https://community.m5stack.com/post/10507</link><guid isPermaLink="true">https://community.m5stack.com/post/10507</guid><dc:creator><![CDATA[m5stack]]></dc:creator><pubDate>Wed, 28 Oct 2020 08:09:04 GMT</pubDate></item><item><title><![CDATA[Reply to EXT.IO Unit ERROR problem on Mon, 26 Oct 2020 06:52:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/samjami" aria-label="Profile: samjami">@<bdi>samjami</bdi></a> said in <a href="/post/9097">EXT.IO Unit ERROR problem</a>:</p>
<blockquote>
<p dir="auto">ERROR<br />
local variable referenced before assignment</p>
</blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/samjami" aria-label="Profile: samjami">@<bdi>samjami</bdi></a> said in <a href="/post/9097">EXT.IO Unit ERROR problem</a>:</p>
<blockquote>
<p dir="auto">I have spent several hours trying to use an Extend IO Unit with M5Stack Fire (and also tried an M5Stack Grey) but when running any simple UIFlow code including the '<a href="http://EXT.IO" target="_blank" rel="noopener noreferrer nofollow ugc">EXT.IO</a> Unit' I get the error below.  It looks like there is a bug in the 'import unit' library or am I missing something!<br />
Can someone please point me in the right direction?</p>
<p dir="auto">Python code:<br />
from m5stack import *<br />
from m5ui import *<br />
from uiflow import *<br />
import unit</p>
<p dir="auto">setScreenColor(0x222222)<br />
ext_io0 = unit.get(unit.EXT_IO, unit.PORTA)</p>
<p dir="auto">Error on M5Stack display:<br />
ERROR<br />
local variable referenced before assignment</p>
<p dir="auto">Details:<br />
File "&lt;string&gt;", line 7, in &lt;module&gt;<br />
File "<a href="http://unit.py" target="_blank" rel="noopener noreferrer nofollow ugc">unit.py</a>", line 97, in get<br />
File "&lt;string&gt;", line 1, in &lt;module&gt;<br />
File "units/_ext_io.py", line 20 in <strong>init</strong><br />
File "units/_ext_io.py", line 25 in _available</p>
</blockquote>
<p dir="auto">The Unboundlocalerror: local variable referenced before assignment is raised when you try to use a variable before it has been assigned in the local context. <a href="http://net-informations.com/python/iq/default.htm" target="_blank" rel="noopener noreferrer nofollow ugc">Python</a> doesn't have variable declarations , so it has to figure out the scope of variables itself. It does so by a simple rule: If there is an assignment to a variable inside a function, that variable is considered local .   To solve this problem, you can explicitly say it's a global by putting global declaration in your function. The global statement does not have to be at the beginning of the function definition, but that is where it is usually placed. Wherever it is placed, the global declaration makes a variable to global variable everywhere in the function.</p>
]]></description><link>https://community.m5stack.com/post/10475</link><guid isPermaLink="true">https://community.m5stack.com/post/10475</guid><dc:creator><![CDATA[berkninan]]></dc:creator><pubDate>Mon, 26 Oct 2020 06:52:15 GMT</pubDate></item><item><title><![CDATA[Reply to EXT.IO Unit ERROR problem on Tue, 23 Jun 2020 09:34:37 GMT]]></title><description><![CDATA[<p dir="auto">thank you feedback.  we will fix this bug as soon as possible</p>
]]></description><link>https://community.m5stack.com/post/9108</link><guid isPermaLink="true">https://community.m5stack.com/post/9108</guid><dc:creator><![CDATA[m5stack]]></dc:creator><pubDate>Tue, 23 Jun 2020 09:34:37 GMT</pubDate></item></channel></rss>