LED Matrix method issue

Hi @all, @benedictdied,

We found a bug when setting a special pattern (outer ring) with the LED Matrix. Using the setAll() method works fine to set all LEDs on and off, but send_LEDMatrix_array() fails and returns a “communication interrupted” error.

This happens only when using a Windows laptop: testing with a Linux computer and with the Web Serial Tester works fine. I verified that both computers have the same repository and I have in both computers the latest pyserial version (3.5), I suspect at some point inside this library there’s some CR-LF formatting that makes the payload un-decodable. The payload is:

{'task': '/ledarr_act', 'led': {'LEDArrMode': 0, 'led_array': [{'id': 0, 'r': 255, 'g': 255, 'b': 255}, {'id': 1, 'r': 255, 'g': 255, 'b': 255}, {'id': 2, 'r': 255, 'g': 255, 'b': 255}, {'id': 3, 'r': 255, 'g': 255, 'b': 255}, {'id': 4, 'r': 255, 'g': 255, 'b': 255}, {'id': 5, 'r': 255, 'g': 255, 'b': 255}, {'id': 6, 'r': 255, 'g': 255, 'b': 255}, {'id': 7, 'r': 255, 'g': 255, 'b': 255}, {'id': 8, 'r': 255, 'g': 255, 'b': 255}, {'id': 9, 'r': 255, 'g': 255, 'b': 255}, {'id': 10, 'r': 255, 'g': 255, 'b': 255}, {'id': 11, 'r': 255, 'g': 255, 'b': 255}, {'id': 12, 'r': 255, 'g': 255, 'b': 255}, {'id': 13, 'r': 255, 'g': 255, 'b': 255}, {'id': 14, 'r': 255, 'g': 255, 'b': 255}, {'id': 15, 'r': 255, 'g': 255, 'b': 255}, {'id': 16, 'r': 255, 'g': 255, 'b': 255}, {'id': 17, 'r': 255, 'g': 255, 'b': 255}, {'id': 18, 'r': 255, 'g': 255, 'b': 255}, {'id': 19, 'r': 255, 'g': 255, 'b': 255}, {'id': 20, 'r': 255, 'g': 255, 'b': 255}, {'id': 21, 'r': 255, 'g': 255, 'b': 255}, {'id': 22, 'r': 255, 'g': 255, 'b': 255}, {'id': 23, 'r': 255, 'g': 255, 'b': 255}, {'id': 24, 'r': 255, 'g': 255, 'b': 255}]}, 'qid': 2}

I also noticed that the Web Serial Tester uses ‘LEDArrMode’: 8 (multi) to set the outer ring, so I tried with different values in the payload but it still fails.

I hope we can get some support on this from some Windows’ user that uses the Led Matrix for pseudo phase contrast.

Mit freundlichen Grüßen

Matías Stingl

Hi @mstingl,
I also faced some bugs when using different patterns on an LED array. I wanted to make a half-circle pattern with a total number of LEDs turned on equal to 15. Apparently, this is too much to handle in one single command using ‘task’: ‘/ledarr_act’. What I did as a temp solution (It is not really) was just splitting the commands up to say turn on less than 6 or 8 LEDs at the same time (same command) until the final pattern is built. You can try to check the amount of LEDs that are able to be turned on in a single command. I don’t know if this can help you as a provisional solution or it does not help at all and this issue is of other nature. We let @benedictdied help us giving follow up in the software part. :slight_smile:

HG

Aaron Rivera

Hey @mstingl, first of all: Congratulations! You found yet another bug - or a feature? :wink:
I must admit that the LED interface is nothing with which I’m very happy with. The long JSON strings that are sent back and forth are causing issues on the pyserial side (timeout, etc…) I’ve started rewriting this stack but didn’t finish it yet. I think @AaronRiSa had the same issues when testing the DPC stuff. What was the last state here?

I hope to push the serial update over the weekend.
Here is a current version. It essentially uses the pyserial way oc communication with proper read- and write locks. The ESP has no full duplex support as far as I understood, so there will always be limitations. And sorry again, all the developments are essentially from me, so I’m very certain they are not correct.

Hi @benedictdied , @AaronRiSa

Thank for both answers! I’ve tested the maximum number of leds it can handle: 16 leds on (255, 255, 255). I’ve modified some parts of the code to only send the ones on and avoid sending empty LEDs.

Thanks a lot. We may need to rewrite the json format. It takes quiet some overhead