# LED Matrix method issue

**URL:** <https://openuc2.discourse.group/t/led-matrix-method-issue/47>\
**Category:** General\
**Tags:** uc2-esp\
**Created:** [June 24, 2024, 2:11pm UTC](https://openuc2.discourse.group/t/led-matrix-method-issue/47 "2024-06-24T14:11:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mstingl](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@mstingl](https://openuc2.discourse.group/u/mstingl)\
**Post date:** [June 24, 2024, 2:11pm UTC](https://openuc2.discourse.group/t/led-matrix-method-issue/47/1 "2024-06-24T14:11:37Z")

</div>

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](https://youseetoo.github.io/indexWebSerialTest.html) 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

---

<div class="post-metadata">

**Author:** ![AaronRiSa](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@AaronRiSa](https://openuc2.discourse.group/u/AaronRiSa)\
**Post date:** [June 25, 2024, 6:35am UTC](https://openuc2.discourse.group/t/led-matrix-method-issue/47/2 "2024-06-25T06:35:30Z")

</div>

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

HG

Aaron Rivera

---

<div class="post-metadata">

**Author:** ![benedictdied](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@benedictdied](https://openuc2.discourse.group/u/benedictdied)\
**Post date:** [June 25, 2024, 6:35am UTC](https://openuc2.discourse.group/t/led-matrix-method-issue/47/3 "2024-06-25T06:35:39Z")

</div>

Hey @mstingl, first of all: Congratulations! You found yet another bug - or a feature? 😉  
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.

> <https://github.com/beniroquai/sermon/blob/master/sermon/mSerial.py>

---

<div class="post-metadata">

**Author:** ![mstingl](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@mstingl](https://openuc2.discourse.group/u/mstingl)\
**Post date:** [July 3, 2024, 10:46am UTC](https://openuc2.discourse.group/t/led-matrix-method-issue/47/4 "2024-07-03T10:46:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![benedictdied](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@benedictdied](https://openuc2.discourse.group/u/benedictdied)\
**Post date:** [July 3, 2024, 6:47pm UTC](https://openuc2.discourse.group/t/led-matrix-method-issue/47/5 "2024-07-03T18:47:44Z")

</div>

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