Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for stacked coordinate layout (64x64 with 2x64x32 panels) in addition to side by side (128x32) #3

Closed
marcmerlin opened this issue Dec 25, 2018 · 20 comments

Comments

@marcmerlin
Copy link
Contributor

I tried your library, it worked fine on my ESP32, thank you.
For 64x32 it just works.
That said, I have chained panels and would like to try 64x64 and ultimately 64x96 which does work with Louis' SmartMatrix already
I went in your library edited ESP32-RGB64x32MatrixPanel-I2S-DMA.h
#define MATRIX_HEIGHT 64

Once I do, I get this
23:24:18.962 -> Setting up parallel I2S bus at I2S1
23:24:18.963 -> I2S setup done.
23:24:18.964 -> Flushing buffer 0Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
0x400d12af: RGB64x32MatrixPanel_I2S_DMA::updateMatrixDMABuffer(short, short, unsigned char, unsigned char, unsigned char) at /home/merlin/Arduino/libraries/ESP32-RGB64x32MatrixPanel-I2S-DMA/ESP32-RGB64x32MatrixPanel-I2S-DMA.cpp line 266
0x400d0c11: RGB64x32MatrixPanel_I2S_DMA::flushDMAbuffer() at /home/merlin/Arduino/libraries/ESP32-RGB64x32MatrixPanel-I2S-DMA/ESP32-RGB64x32MatrixPanel-I2S-DMA.h line 233
0x400d0c5c: setup() at /home/merlin/Arduino/libraries/ESP32-RGB64x32MatrixPanel-I2S-DMA/ESP32-RGB64x32MatrixPanel-I2S-DMA.h line 182
0x400e5a77: loopTask(void*) at /home/merlin/Arduino/hardware/espressif/esp32/cores/esp32/main.cpp line 15

Details:
23:24:18.859 -> *****************************************************
23:24:18.861 -> HELLO !
23:24:18.862 -> *****************************************************
23:24:18.863 -> lsbMsbTransitionBit of 0 requires 198304 RAM, 113792 available, leaving -84512 free:
23:24:18.863 -> lsbMsbTransitionBit of 1 requires 149152 RAM, 113792 available, leaving -35360 free:
23:24:18.894 -> lsbMsbTransitionBit of 2 requires 124576 RAM, 113792 available, leaving -10784 free:
23:24:18.896 -> lsbMsbTransitionBit of 3 requires 112288 RAM, 113792 available, leaving 1504 free:
23:24:18.898 -> Raised lsbMsbTransitionBit to 3/7 to fit in RAM
23:24:18.898 -> ns per latch: 3200:
23:24:18.899 -> nsPerFrame: 3481600:
23:24:18.900 -> lsbMsbTransitionBit of 3 gives 287 Hz refresh:
23:24:18.925 -> Raised lsbMsbTransitionBit to 3/7 to meet minimum refresh rate
23:24:18.928 -> Descriptors for lsbMsbTransitionBit 3/7 with 32 rows require 12288 bytes of DMA RAM
23:24:18.930 -> SmartMatrix Mallocs Complete
23:24:18.930 -> Heap Memory Available: 367940 bytes total, 113792 bytes largest free block:
23:24:18.931 -> 8-bit Accessible Memory Available: 279436 bytes total, 113792 bytes largest free block:
23:24:18.933 -> 32-bit Memory Available: 367940 bytes total, 113792 bytes largest free block:
23:24:18.960 -> DMA Memory Available: 279436 bytes total, 113792 bytes largest free block:
23:24:18.961 -> Performing I2S setup.
23:24:18.962 -> Setting up parallel I2S bus at I2S1
23:24:18.963 -> I2S setup done.
23:24:18.964 -> Flushing buffer 0Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
23:24:18.964 -> Core 1 register dump:
23:24:18.965 -> PC : 0x400d12af PS : 0x00060730 A0 : 0x800d0c14 A1 : 0x3ffb1f10
23:24:18.993 -> A2 : 0x3ffc2420 A3 : 0x00000000 A4 : 0x00000000 A5 : 0x00000002
23:24:18.995 -> A6 : 0x00000000 A7 : 0x00001f82 A8 : 0x00000002 A9 : 0x00000000
23:24:18.997 -> A10 : 0x00000000 A11 : 0x00000000 A12 : 0x00000001 A13 : 0x00000008
23:24:18.998 -> A14 : 0x00000002 A15 : 0x00000004 SAR : 0x00000020 EXCCAUSE: 0x0000001c
23:24:19.025 -> EXCVADDR: 0x00000002 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xffffffff
23:24:19.026 ->
23:24:19.027 -> Backtrace: 0x400d12af:0x3ffb1f10 0x400d0c11:0x3ffb1f60 0x400d0c5c:0x3ffb1f80 0x400e5a77:0x3ffb1fa0
23:24:19.028 ->
23:24:19.028 -> Rebooting...

@mrcodetastic
Copy link
Owner

Hello. Can you see if adjusting the same lines as outlined in issue #6 resolves the issue? Given I had hard-coded this library to work on an ESP32 for a 64x32 (2048) pixel matrix, I had pretty much trial-and-error hard coded values that gave the best output (for my purposes). I think what is happening here is the ESP32 is simply out of memory (after I purposely force the library to keep 110k free etc.).

@marcmerlin
Copy link
Contributor Author

I tried 50, 100, 150, 200 for

    ramrequired += 200000; // HACK Hard Coded: Keep at least 100k free!

and they all crashed for 64 height.
You can easily reproduce this by changing the number if you'd like.
#define MATRIX_HEIGHT 64

That said, I just wrote my own GFX library on top of SmartMatrix, so admittedly I don't need this anymore:
https://github.com/marcmerlin/SmartMatrix_GFX
Still, the DMA approach of your library is interesting, especially the full frame refresh approach as opposed to line refresh approach that SmartMatrix does (albeit with more bits per pixel), so it would be worth keeping IMO.

@mrcodetastic
Copy link
Owner

mrcodetastic commented Jan 3, 2019

Ah.. I'm not sure if vertically stacked panels will work with this library. I did set the WIDTH to 128 (i.e simple horizontal chain of panels) and it seemed to run.

I'm thinking I might as well just port Louis's or your library and add DMA at some point.

This library is 24 bit, but the test_shapes demo isn't the best guide to use. The plasma wave demo draws directly to the DMA buffer with 24 bit colour (i.e, doesn't go through the adafruit GFX library).

This library doesn't have a framebuffer etc. It writes pixel updates directly to the only buffer - the DMA buffer, as such, memory usage is greatly reduced, at the expense of layering stuff etc.

What type of ESP device are you using?

@marcmerlin
Copy link
Contributor Author

marcmerlin commented Jan 3, 2019

@mrfaptastic interesting, so you do support 4096 pixels as long as they are 128x32 and not 64x64, so at least it's not a memory problem.
Can you confirm that 64x64 crashes for you too?

For what you can do long term, I know Louis would be grateful to have your DMA support in his lib. I'm assuming it's less work to port your DMA code to his lib than his entire lib to your driver.
My lib does not contain drivers at all, unless you count a virtual framebuffer, a driver :) I wrote it as a layer to put on top of Louis' library to add GFX and FastLED API support.
If you can, have a look at https://github.com/marcmerlin/FastLED_NeoMatrix_SmartMatrix_LEDMatrix_GFX_Demos/
it contains a lot of cool demos that will now run on top of SmartMatrix via SmartMatrix::GFX . Most won't work out of the box on your lib because they also use the FastLED array of CRGB API, but the fontzoom demo will work since I wrote that one and it only uses GFX.
See video: https://youtube.com/watch?v=bPLuH3Ln9gU
Code: https://github.com/marcmerlin/FastLED_NeoMatrix_SmartMatrix_LEDMatrix_GFX_Demos/tree/master/GFX/fontzoom

SmartMatrix::GFX could be made to work on top of your library with minimal effort, but given that it crashes for me in 64x64 .
Oh, I didn't realize your lib was 24bpp. The GFX library is 16bpp by the way.
I noticed you were using dma_display.color444 when GFX is 565 natively, but now I see that you have a 24bit bypass draw function just like I do.
I just updated https://github.com/marcmerlin/SmartMatrix_GFX/blob/master/README.md to correct the bit about your lib not being 24bpp (review in #7 if you have time, although it seems I corrected the major wrong thing I wrote about your library)

ESP32, I'm using a bare chip with level shifters. Do you care which one exactly?
Picture/video here: https://www.youtube.com/watch?v=FjBL09Qceqs

mrcodetastic pushed a commit that referenced this issue Jan 3, 2019
Move malloc from static class constructor to begin(). Possible fix for #3
@mrcodetastic
Copy link
Owner

mrcodetastic commented Jan 3, 2019

Try again now. I don't have access to a 64x64 panel, or own two 64 (wide) x 32 (high) panels to able to test chaining... but it seems to compile and run for 128 wide x 32 high, and 64 high x 64 wide, now.

I just updated https://github.com/marcmerlin/SmartMatrix_GFX/blob/master/README.md to correct the bit about your lib not being 24bpp (review in #7 if you have time, although it seems I corrected the major wrong thing I wrote about your library)

Thank you. I'll take a look at this guide over the coming weekends.

@mrcodetastic
Copy link
Owner

mrcodetastic commented Jan 3, 2019

Assuming the above change works (given I can't test it), I should note (you would already know this though :-), if you're using a single 64x64 pixel panel, you'll need to assign a E_PIN I think for this library to work with it.

If you're using 2 x 64*32 panels and sitting them on top of each other, this library isn't designed for that. You'll need to set the width to 128 and height to 32px in the library and in your animation code, do the necessary virtual co-ordinate mapping (i.e. if y > 32 then y = y - 32, x = x+64).

@marcmerlin
Copy link
Contributor Author

I have both 64x64 with E address that I know your library doesn't support, and 64x32x2 chained but as 64x64, not 32x128. SmartMatrix supports 64x64 without changing my code to remap the pixels from 32x128, to 64x64, so I'll probably stick with that for now.
Is it not reasonably easy to add in the lib itself? (yes I understand I can do it in code too, but it's a bit of a pain and something the lib should support :) )

@mrcodetastic
Copy link
Owner

Did my change not work? It's probably easier just use the smart matrix code. It would be easy to add support I think, but I can't as I don't have the physical panels to test.

@marcmerlin
Copy link
Contributor Author

I'm in a plane and travelling for the next 3 days, so I may not have time to play with my panels for a little bit.
If 32x128 works for you, I'm sure it'll work for me too, but indeed direct 64x64 mapping with SmartMatrix is easier for me, especially because Ultimately I'm doing this for my new shirt that will have 64x96 resolution (3 panels of 64x32 on top of one another).
While it's not my priority, it would however still be good that I switch to your driver if/when it can support this, because I'm sure your driver is less resource incentive than SmartMatrix which does big banging instead of DMA.

@mrcodetastic
Copy link
Owner

I believe there is already a SmartMatrix experimental branch which uses the same DMA library.

https://github.com/pixelmatix/SmartMatrix/tree/teensylc

@marcmerlin
Copy link
Contributor Author

It adds support for ESP32 (not supported in the main branch), but I don't think it supports DMA. Louis is actually the person who told me to try your branch for DMA :)
(that said, I didn't inspect the driver code, I assumed it still did bit banging, but I didn't verify it)

@mrcodetastic
Copy link
Owner

It's both ESP32 and DMA per his README.

@marcmerlin
Copy link
Contributor Author

you are correct, my bad (was re-reading the wrong README).
I think the difference he outlined then was that he was still doing line level PWM while you were doing full page PWM, which shows up on video where I get streaks if the refresh rate is too low with his lib, while with yours I get a rolling shutter effect which is not as bad.

@marcmerlin
Copy link
Contributor Author

Ok, I was just able to confirm that 32x128 works like you suggested, while 64x64 crashes, so it's "just" a layout problem in the coordinate mapping like you suggested.
I'll update the description accordingly.

@marcmerlin marcmerlin changed the title Support for bigger panels than 32x64? Support for stacked coordinate layout (64x64 with 2x64x32 panels) in addition to side by side (128x32) Jan 5, 2019
@mrcodetastic
Copy link
Owner

Closed.

@marcmerlin
Copy link
Contributor Author

Are stacked panels supported now? (64x64, not 32x128)

@mrcodetastic
Copy link
Owner

@marcmerlin
Copy link
Contributor Author

woohoo, well done.

@maglevize
Copy link

pardon me, I try to use stacked chain with VirtualMatrixPanel class. but can't call flipDMABuffer() and showDMABuffer().
is it unsupported?
I try to animate scroll text, but it so flickering. I'm using virtualDisp.fillscreen(0) each loop.

@mrcodetastic
Copy link
Owner

Can you post a video?

You don't call flipDMABuffer etc via the virtualDisplay class, you need to call the underlying DMA class. i.e. dma_display.flipDMABuffer();
virtualDisplay.()// do your painting
dma_display.showDMABuffer();

mrcodetastic pushed a commit that referenced this issue Jan 30, 2023
…ions/cache-3

Bump actions/cache from 2 to 3
mrcodetastic pushed a commit that referenced this issue Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants