EXT.IO Unit ERROR problem



  • 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 'EXT.IO Unit' I get the error below. It looks like there is a bug in the 'import unit' library or am I missing something!
    Can someone please point me in the right direction?

    Python code:
    from m5stack import *
    from m5ui import *
    from uiflow import *
    import unit

    setScreenColor(0x222222)
    ext_io0 = unit.get(unit.EXT_IO, unit.PORTA)

    Error on M5Stack display:
    ERROR
    local variable referenced before assignment

    Details:
    File "<string>", line 7, in <module>
    File "unit.py", line 97, in get
    File "<string>", line 1, in <module>
    File "units/_ext_io.py", line 20 in init
    File "units/_ext_io.py", line 25 in _available



  • thank you feedback. we will fix this bug as soon as possible



  • @samjami said in EXT.IO Unit ERROR problem:

    ERROR
    local variable referenced before assignment

    @samjami said in EXT.IO Unit ERROR problem:

    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 'EXT.IO Unit' I get the error below. It looks like there is a bug in the 'import unit' library or am I missing something!
    Can someone please point me in the right direction?

    Python code:
    from m5stack import *
    from m5ui import *
    from uiflow import *
    import unit

    setScreenColor(0x222222)
    ext_io0 = unit.get(unit.EXT_IO, unit.PORTA)

    Error on M5Stack display:
    ERROR
    local variable referenced before assignment

    Details:
    File "<string>", line 7, in <module>
    File "unit.py", line 97, in get
    File "<string>", line 1, in <module>
    File "units/_ext_io.py", line 20 in init
    File "units/_ext_io.py", line 25 in _available

    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. Python 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.



  • this bug has been fixed.