CyberBrick Reciever Code actions slow

Hi,

I have been playing with code actions on CyberBrick. I have tried to toggle all the neopixels, and add some more logic to them. However when I press the button on the remote the execution of the code is slow. Any idea how to make this faster?

Also any way to debug these actions, it is hard to see if it runs, or fails or just takes slow.

Any help is appreciated!
Thanks

You can let the CyberBrick Core run in REPL terminal and then e.g. output (your added) debug data to the terminal. Source code is located on your ESP32-C3 MicroPython partition or also under: CyberBrick_Controller_Core/src/app_rc/bbl/leds.py at master · CyberBrick-Official/CyberBrick_Controller_Core · GitHub

See Arduino Lab for MicroPython IDE or Thonny.

Thanks for the help!

I have successfully connected to REPL. What I found is that if I have an action which only has a print in it it runs almost instantly, but my action with much more characters (~1500) takes a lot of time to load and then executes instantly (the first print in the action takes time then everything comes at the same time). So probably the issue is with the code parsing the scripts every time they are run

1500 characters is quite a long action script. Can you post your *.JSON or the rc_config file from the root of your ESP32-C3 (rc_config is the *.JSON file you load via app CyberBrick_Controller_Core/src/app_rc/app/rc_main.py at b5fc07d44d65143cfef1164ae6234099fcb11d62 · CyberBrick-Official/CyberBrick_Controller_Core · GitHub). You could also check mem_info from library micropython: micropython – access and control MicroPython internals — MicroPython for CyberBrick V01.00.00.02 documentation and garbage collector memory allocation: gc – control the garbage collector — MicroPython for CyberBrick V01.00.00.02 documentation
Possibly your system runs out of memory and needs to trigger time consuming garbage collector.

I placed the meminfo in the beginning of the action. It gave me the following output:

GC: total: 94720, used: 82576, free: 12144, max new split: 8704
No. of 1-blocks: 1063, 2-blocks: 270, max blk sz: 377, max free sz: 203

Since I can’t upload JSON files here is the configuration on pastebin: {"version":"0.0.21","config_type":"custom","design_id":"00000000000000000000","r - Pastebin.com

EDIT: I have tested a file which in charachters are bout the same size only containing lines of

print(“testing123”)

This also runs after a long time. So in my opinion the issue might be with the core code.

I had a quick look how original CyberBrick MicroPython code parses the JSON, especially the effect code segments:

After _parse_codes() is called, the garbage collector is executed and that likely is where the slow-down stems from:

I see you are also using ESP32 nvs lib, which again is time-consuming.

In your code:

nvs.set_i32("pf", int(flat))
nvs.commit()
nvs.set_i32("xy", int(f"{x}{y}"))
nvs.commit()

I also do believe you can combine the time consuming commits together to one:

nvs.set_i32("pf", int(flat))
nvs.set_i32("xy", int(f"{x}{y}"))
nvs.commit()

I’ll try that, but as I said in my edit an action only having a lot of prints takes a lot of time to start executing. Also NVS might not be that slow since the time between the first print in the first line and the Action executed output is nearly instant.

I do not know how to fix this, I am trying to reduce charachter count since it is the only thing I found that correlates with execution start speed.