UIFlow initiates AtomMatrix not correct when switching
-
I have been trying to get the AtomMatrix to work with the AtomicQR on UIFlow v1.6.5.
When setting the device to AtomMatrix in UIFlow web and running Atomic_QR.m5f on the device, I get an error from the device:
Traceback (most recent call last): File "flow/m5cloud.py", line 82, in _exec_fun File "<string>", line 6, in <module> File "units/_rgb_multi.py", line 47, in set_screen IndexError: list index out of range
For testing I set UIFlow Web to Atom ("lite") and ran Atomic_QR.m5f on my AtomMAtrix - and it runs fine.
Now I found the reason: when switching from Atom ("lite") to AtomMatrix, UIFlow is adding
rgb.set_screen([])
But this is incorrect, it should be
rgb.set_screen([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
Cheers
Mike -
How to reproduce:
- Load AtomicQR in UIFlow
- Switch device Atom ("lite") to AtomMatrix
- Check Python code
-
I can now manually change in Python view
rgb.set_screen([])
to
rgb.set_screen([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
but then I can not go back to Blockly.
-
@mb said in UIFlow initiates AtomMatrix not correct when switching:
I can now manually change in Python view
rgb.set_screen([])
to
rgb.set_screen([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
but then I can not go back to Blockly.
Put that rgb.set_screen command in an execute block. Then you will be able to go back and forth between Blockly and Python.
-
I am not sure how this can be done.
- Load AtomicQR in UIFlow
- Switch device AtomBase to AtomMatrix
The problem is that the line
rgb.set_screen([])
does not show up in Blockly at all. It does not show up as an execute block. And as soon as I change the line in Python it will not go back to Blockly without loosing the change.UIFlow with execute block
Execute block does not influence wrong code line on top
As stated before, I can not remove or change the wrong code line and go back to Blockly:
"Blockly does not retain your newly created python. Are you sure you want to return it?"I think this is a bug in UIFlow v1.6.5 and needs to be fixed by M5Stack.
-
Even when I take the AtomicQR example code for the AtomBase ("lite") and use a text editor to replace
"type":"atom"
with"type":"atom-matrix"
and open the file in UIFlow v1.6.5, it seems it will automatically add the wrong linergb.set_screen([])
to it. Neitherrgb
norset_screen
is contained in the original source code.When you create a new project with UIFlow v1.6.5 it will automatically include the lines:
from m5stack import * from m5ui import * from uiflow import * rgb.set_screen([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
But when you open file AtomicQR (even when manually changed to "atom-matrix") it will include the lines:
from m5stack import * from m5ui import * from uiflow import * import machine rgb.set_screen([])
But
rgb.set_screen([])
will cause an error. -
I finally managed to merge AtomicQR with AtomMatrix to get working UIFlow Blockly code for the AtomMatrix with QR Base.
{ "components": [], "type": "atom-matrix", "versions": "Beta", "units": [], "hats": [], "blockly": "<block type=\"basic_on_setup\" id=\"setup_block\" deletable=\"false\" x=\"50\" y=\"50\"><next><block type=\"uart\" id=\"?fn[P[:J${RC=F_+t,[E\"><field name=\"VAR\">uart1</field><field name=\"BAUD\">9600</field><field name=\"USE_TIMER\">1</field><value name=\"TX\"><shadow type=\"math_number\" id=\"/v~ODpPaPMacN~b)e%3|\"><field name=\"NUM\">19</field></shadow></value><value name=\"RX\"><shadow type=\"math_number\" id=\"t{||%=B[`ol|-!k+*5-x\"><field name=\"NUM\">22</field></shadow></value><next><block type=\"pin_pinout\" id=\"#k4qw=Uw~A/5w7f0a}-^\"><field name=\"PINGS\">pin0</field><field name=\"MODE\">OUT</field><field name=\"PULL\">PULL_UP</field><value name=\"PIN\"><shadow type=\"math_number\" id=\"-$jE|Sww9C$TF4Pfd}xn\"><field name=\"NUM\">23</field></shadow></value><next><block type=\"pin_pinout\" id=\";%K*ZpEPpzJlT:T+*3P{\"><field name=\"PINGS\">pin1</field><field name=\"MODE\">IN</field><field name=\"PULL\">PULL_DOWN</field><value name=\"PIN\"><shadow type=\"math_number\" id=\"2}*8p.~{8|}]XHMVAIKv\"><field name=\"NUM\">33</field></shadow></value><next><block type=\"pin_on\" id=\"VuqU8LZj|hj[kX~/Ps,X\"><field name=\"PINGS\">pin0</field><next><block type=\"basic_on_loop\" id=\"n{5z6s%WT44qnt{uNh2C\"><statement name=\"LOOP\"><block type=\"controls_if\" id=\"c8M!qA~V,S:|Ti1m1@L5\"><mutation else=\"1\"></mutation><value name=\"IF0\"><block type=\"button_ispressed\" id=\"y5PP+AesoCHkhvFJ1)WE\"><field name=\"BUTTON\">A</field><field name=\"EVENT\">isPressed</field></block></value><statement name=\"DO0\"><block type=\"pin_off\" id=\"lml]5dygiyXx6$A=}WL}\"><field name=\"PINGS\">pin0</field></block></statement><statement name=\"ELSE\"><block type=\"pin_on\" id=\"(X9Myos7r9S;Wd$D@9*v\"><field name=\"PINGS\">pin0</field></block></statement><next><block type=\"controls_if\" id=\"ZSs!^*HGbr%:y!@IIZu4\"><value name=\"IF0\"><block type=\"logic_compare\" id=\".Z/`p-1|xx.P76}BA^_h\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"pin_get_value\" id=\"]kAKQw,)AP(n%bN[JNuf\"><field name=\"PINGS\">pin1</field></block></value><value name=\"B\"><block type=\"logic_boolean\" id=\"ifHp5cP.Ia%~4m1dZxV.\"><field name=\"BOOL\">TRUE</field></block></value></block></value><statement name=\"DO0\"><block type=\"controls_if\" id=\"LL+//#;X:xeg](]o7e1?\"><value name=\"IF0\"><block type=\"uart_any\" id=\"j0X[6=oMHpt8aCSPNK.$\"><field name=\"VAR\">uart1</field></block></value><statement name=\"DO0\"><block type=\"text_print\" id=\"hiXPavq2wbGV6tPYGkpz\"><value name=\"TEXT\"><block type=\"decode_str\" id=\"_T~_|Ey5w]oVdv$Ic[T@\"><value name=\"VALUE\"><block type=\"uart_read\" id=\"^,r~#VGXi80VO0aUta_?\"><field name=\"VAR\">uart1</field></block></value></block></value></block></statement></block></statement></block></next></block></statement></block></next></block></next></block></next></block></next></block></next></block>", "Blockly.Remotes": [], "modules": [ "imu", "rgb", "machine" ], "matrix": [ "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111", "#111111" ] }
Before it would always crash because UIFlow web v1.6.5 would insert
rgb.set_screen([])
when switching from Atom to AtomMatrix. -
Looks like you got it working, but what I was referring to with the Execute block was adding the full command like this to see if it would override the first.
In the Python tab it looks like the command duplicated. I don't have the AtomQR to test with, so I'm not sure if this works or not...
However, I found another workaround without the Execute block. After loading the AtomicQR example flow, then switch from Atom-Lite to Atom-Matrix in the settings, it will indeed add
rgb.set_screen([])
on the Python tab. This is the bug. If you just select one of the 25 LED squares in the UI editor to change it to white, then select the same square again to change it back to black. Check the Python tab again and it will now showrgb.set_screen([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
automatically.If you save that as a new program (ex: Atomic_QR-Matrix), the next time you load the file, it should have the Matrix as the hardware type and the correct rgb.set_screen command in the python tab.