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

Your thoughts? #26

Closed
ghost opened this issue Nov 8, 2016 · 7 comments
Closed

Your thoughts? #26

ghost opened this issue Nov 8, 2016 · 7 comments

Comments

@ghost
Copy link

ghost commented Nov 8, 2016

Hi!

I'm (slowly) trying to clean up/improve(?) your ws2812 i2s code:
https://github.com/cranphin/esp8266-dev/blob/master/esp8266-neo/dev/driver/ws2812_i2s.c

One thing I'd like to do is actually enable/use DMA interrupts.
This is certainly possible, someone has done this rather elegantly (I think) for the Arduino core:
https://github.com/Makuna/NeoPixelBus/blob/master/src/internal/NeoEsp8266DmaMethod.h#L282
But he has the benefit of the yield() method the Arduino core provides:
https://github.com/Makuna/NeoPixelBus/blob/master/src/internal/NeoEsp8266DmaMethod.h#L241
Which he uses to 'block' the update call until the DMA buffer has space, I don't think it's easy to do something like that in esp-open-sdk/Espressif NON-OS.

My current idea is to store the received/update bytes (just the RGB bytes) in a buffer, possibly a ring buffer size 2, with each part the length of the led string size. And then a far smaller DMA buffer (ring buffer as well I think, with at least 2 parts for converted RGB bytes), which is fed in small parts from the previous buffer in the interrupt, possibly in combination with a 'zero' buffer once it's done.
So the update method writes to the first buffer (overwriting the previous value if we get data faster then we can send it to the leds), And the interrupt moves it in small parts to the two DMA buffers, marking the first buffer done when it's finished.

Any thoughts on this? I'm really not used to working with interrupts and DMA, usually I work in Java :)
You seem pretty awesome at it though ;)

@cnlohr
Copy link
Owner

cnlohr commented Nov 23, 2016

hey, I'm really sorry it took so long to get back in the swing of things.

You can totally just call whatever you want from inside the interrupt. You can actually do a fair bit in there. That's how I did a lot of the stuff for my Channel3 project. I would STRONGLY recommend bigger buffers though, and there is so much overhead when getting an interrupt called. Function calls aren't free.

That's not to say some degree of buffering wouldn't be good. It is annoying to give up such a huge buffer :-/... so I don't really know what the right answer is.

@ghost
Copy link
Author

ghost commented Nov 23, 2016

Thanks for your thoughts :) I've been tinkering a lot towards this already. Last code is here:
https://github.com/cranphin/esp8266-dev/blob/master/esp8266-neo/dev/driver/ws2812_i2s.c
though there is no interrupt handling in there, -YET- :)
My local code does have it, and it almost works? :)
But I think I'm running exactly into what you're suggesting, possibly.. at 32 byte buffers, the interrupt might not finish fast enough to actually fill the next buffer before it's used.. :)

Will try and test more, could be another bug.. I also need more rgb leds.. XD 8 is not enough to test with larger buffers.. :) Should have a string of 30 here soon ;)

@cnlohr
Copy link
Owner

cnlohr commented Nov 23, 2016

30? We routinely use 300+! Rolls are ~$25, you don't have an excuse :-p

@ghost
Copy link
Author

ghost commented Nov 23, 2016

I have to justify expenses with my better half, it's a limiting factor :)
And 30 leds I'm confident of driving of a usb charger, more I might have to look into better power supplies, and things add up :) But we'll see how 30 goes, then consider going up more ;)

@geekmaster
Copy link

geekmaster commented May 12, 2017

Do you actually have source code for the stuff in the web folder?

Right now, it seems to be just symlink paths in the .c files...

Or is this supposed to be relative to YOUR entire github layout (not a standalone project)?

@con-f-use
Copy link
Collaborator

con-f-use commented May 12, 2017

A little of colmun B.

The symlinks you refer to, point to files in the ./esp82xx directory, which is a git-submodule. Think of submodules as a link to a specific commit in another repository. By default, git does not clone submodules when you clone a root project. I suspect, that is what's throwing you off.

To mitigate that you have either make recursive cloning default (git config --global alias.clone = 'clone --recursive') or use

    git clone --recursive https://github.com/cnlohr/esp82xx.git

every time you clone a repository that uses submodules. With an already cloned repository you'll need to run

git submodule update --init --recursive

Submodules are the most common way to include other code and split up development effort. The next most common way would be subtrees.

You should look into the basics of git.

@cnlohr
Copy link
Owner

cnlohr commented May 13, 2017

Just as a reminder by me. Thank you, @con-f-use for making "make" get the recurse if you forget to do it the first time.

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