Yona-Appletree / LEDscape

Beagle Bone Black cape and firmware for driving a large number of WS281x LED strips.
126 stars 58 forks source link

A simple direct-connect example? #19

Open JetForMe opened 9 years ago

JetForMe commented 9 years ago

Hi. Thanks for all the hard work on this!

I'm trying to understand how to connect a single NeoPixel string. Mostly at this moment I'm trying to figure out which pins to reserve in my cape design. But reading the readme, it's not at all obvious. It says if I'm not using the LEDscape cape to refer to the Pin Mapping section below (btw, it's above), but that doesn't really help at all.

Also, it seems like node.js is required to use it? Is that true? I'm only interested in calling it from C (C++), but it seems that I have to use node.js to configure it. Hard to tell for sure.

I'd really appreciate some guidance. I'm just using a NeoPixel 24 ring as a backlight in a box.

Thanks!

Yona-Appletree commented 9 years ago

As specified by the documentation, you need to run the pinmap.js tool specifying the mapping that you wish to use. LEDscape supports arbitrary pin mappings, though at present, they must be based on the original 48 LEDscape pins.

If you're fine using the default mapping, simply invoke the tool like this:

node pru/pinmap.js

It will generate a table indicating which LEDscape channel is present on each of the headers of the beaglebone:

➜  LEDscape git:(master) ✗ node pru/pinmap.js
Using mapping: Original LEDscape from original-ledscape
                       Internal Channel Index
 Row  Pin#       P9        Pin#  |  Pin#       P8        Pin# Row
  1    1                    2    |   1                    2    1
  2    3                    4    |   3                    4    2
  3    5                    6    |   5                    6    3
  4    7                    8    |   7     25      26     8    4
  5    9                    10   |   9     28      27     10   5
  6    11    13      23     12   |   11    16      15     12   6
  7    13    14      21     14   |   13    10      11     14   7
  8    15    19      22     16   |   15    18      17     16   8
  9    17                   18   |   17    12      24     18   9
  10   19                   20   |   19     9             20   10
  11   21     1       0     22   |   21                   22   11
  12   23    20             24   |   23                   24   12
  13   25             7     26   |   25                   26   13
  14   27            47     28   |   27    41             28   14
  15   29    45      46     30   |   29    42      43     30   15
  16   31    44             32   |   31     5       6     32   16
  17   33                   34   |   33     4      40     34   17
  18   35                   36   |   35     3      39     36   18
  19   37                   38   |   37    37      38     38   19
  20   39                   40   |   39    35      36     40   20
  21   41     8       2     42   |   41    33      34     42   21
  22   43                   44   |   43    31      32     44   22
  23   45                   46   |   45    29      30     46   23

The numbers on the inside of the table indicate the LEDscape channel index. So, if you want to build your own cape / circuit to use channel 0, connect pin #22 to a 3v-5v level shifter and connect to your NeoPixel ring.

I'm sorry that this isn't clear in the documentation, but I think it is fairly plainly stated: "A human-readable pinout for a mapping can be generated by running..." You're welcome to send a pull request with better wording.

Best of luck with your cape, I'd love to see more details / photos / etc of the project.

JetForMe commented 9 years ago

Well, all I could see in the Pin Mapping was how to use LEDscape capes, so it didn't seem like I'd find what I needed for a single pin. I didn't realize it required the use of 48 pins. That's problematic for me, because I need some of those pins (MCASP/I2S). So far, it seems like the other GPIOs and analog inputs I'm using are not in conflict with LEDscape's pins, and for now that might be okay (I won't have the audio portion ready for some time).

I'm happy to show you what I'm working on, but I fear you'll find it terribly anti-climactic, as I'm not doing any cool animations with LEDs. I'm building a podcast player out of an antique radio. In it, you "tune" the dial to the podcast playlist you want to hear. It mixes in pink noise between stations to make it sound like static. The NeoPixels serve as a backlight for the mechanical frequency display. https://www.youtube.com/watch?v=yJ5C6Pq1OYA

JetForMe commented 9 years ago

Oh, wait. I don't think I can use this if it requires allocating 48 pins. That's basically all the available GPIOs, isn't it? In fact, it looks like a MCASP is still available, and a couple of GPIOs, but I need five. How hard is it to modify it to use fewer channels? I'll poke at the code, but you can probably tell me before I'll figure it out.

Yona-Appletree commented 9 years ago

Currently, we do use all pins, but it would be fairly easy to make a version of the pru/templates/ws281x.p file that only sends to the first pin. Ideally, we'd modify the template-processor to handle null pins which just aren't included in the output. That probably wouldn't be too hard, but it would require testing of all 48. Feel free to send a pull request. If I get inspired, I may implement it, but it's not a use case that has come up all that often for most users (though it is an interesting one, and one worth doing at some point).

JetForMe commented 9 years ago

I'd sure appreciate it! Would you like me to open an issue for it?

JetForMe commented 9 years ago

I will pay you cash to make the changes I need (support for communicating with a single LED strip on a single GPIO). The trick is, I need it fairly urgently (tomorrow?). Alternatively, if we could Skype for a while to go over the code a bit so I could see where to change it. I started reading the PRU docs, etc., but am mired in kernel hell right now, trying to get my DTB right for the GPIOs I'm using. I'm worried that I'm going to run out of time before I have to present this project. Thanks!

Yona-Appletree commented 9 years ago

I was offline yesterday, but I think the changes would be pretty easy to make. Does it matter which GPIO you get? Feel free to ping me at hypher at gmail to follow up.

JetForMe commented 9 years ago

Thanks, just sent you email.