zestyping / openpixelcontrol

A simple stream protocol for controlling arrays of RGB lights.
http://openpixelcontrol.org/
353 stars 103 forks source link

Bug in layout generator - wall.py #33

Closed ghost closed 9 years ago

ghost commented 9 years ago

I'm working on a OPC LED project ( https://github.com/DecentralVan/sidewalk ) and I came across a bug in the python layout generator /layouts/wall.py/ ----> It creates rows that alternate direction.

the python code is:

spacing = 0.11  # m
lines = []
for c in range(-12, 13):
    rs = [range(50), reversed(range(50))][c % 2]
    for r in rs:
        lines.append('  {"point": [%.2f, %.2f, %.2f]}' %
                     (c*spacing, 0, (r - 24.5)*spacing))
print '[\n' + ',\n'.join(lines) + '\n]'

I replaced it with coffee-script code:

spacing = 0.08

cols = [-6..6]  #13 cols
rows = [-30..31] #62 rows

lines = []
for c in cols
  for r in rows
    lines.push
      "point" : [c*spacing,0,r*spacing]

json = JSON.stringify lines

# From the command line, create a layout by
# use coffee <this file>  >  <destinationJsonFile>
console.log json
zestyping commented 9 years ago

Interesting that it wasn't clear that the alternation was intentional. :) When a matrix of these addressable LEDs is wired up, the rows usually alternate direction so that they can be connected all in one long chain.

On Fri, Sep 4, 2015 at 6:22 PM, Taylor Singleton-Fookes < notifications@github.com> wrote:

I'm working on a OPC LED project ( https://github.com/DecentralVan/sidewalk ) and I came across a bug in the python layout generator /layouts/wall.py/ ----> It creates rows that alternate direction.

the python code is:

spacing = 0.11 # m lines = [] for c in range(-12, 13): rs = [range(50), reversed(range(50))][c % 2] for r in rs: lines.append(' {"point": [%.2f, %.2f, %.2f]}' % (c_spacing, 0, (r - 24.5)_spacing)) print '[\n' + ',\n'.join(lines) + '\n]'

I replaced it with coffee-script code:

spacing = 0.08

cols = [-6..6] #13 cols rows = [-30..31] #62 rows

lines = [] for c in cols for r in rows lines.push "point" : [c_spacing,0,r_spacing]

json = JSON.stringify lines

From the command line, create a layout by

use coffee >

console.log json

— Reply to this email directly or view it on GitHub https://github.com/zestyping/openpixelcontrol/issues/33.

zestyping commented 9 years ago

Really cool to see what you're doing with OPC though! :) Do you happen to have any videos?

On Fri, Sep 4, 2015 at 6:28 PM, Ka-Ping Yee zestyping@gmail.com wrote:

Interesting that it wasn't clear that the alternation was intentional. :) When a matrix of these addressable LEDs is wired up, the rows usually alternate direction so that they can be connected all in one long chain.

On Fri, Sep 4, 2015 at 6:22 PM, Taylor Singleton-Fookes < notifications@github.com> wrote:

I'm working on a OPC LED project ( https://github.com/DecentralVan/sidewalk ) and I came across a bug in the python layout generator /layouts/wall.py/ ----> It creates rows that alternate direction.

the python code is:

spacing = 0.11 # m lines = [] for c in range(-12, 13): rs = [range(50), reversed(range(50))][c % 2] for r in rs: lines.append(' {"point": [%.2f, %.2f, %.2f]}' % (c_spacing, 0, (r - 24.5)_spacing)) print '[\n' + ',\n'.join(lines) + '\n]'

I replaced it with coffee-script code:

spacing = 0.08

cols = [-6..6] #13 cols rows = [-30..31] #62 rows

lines = [] for c in cols for r in rows lines.push "point" : [c_spacing,0,r_spacing]

json = JSON.stringify lines

From the command line, create a layout by

use coffee >

console.log json

— Reply to this email directly or view it on GitHub https://github.com/zestyping/openpixelcontrol/issues/33.

ghost commented 9 years ago

Ok cool (we connected each row to an individual pin on the fadecandy boards). We'll take some videos of it soon :) and I'll send you links