Project:USB Disco Dance Floor/v1/firmware: Difference between revisions

From London Hackspace Wiki

Added details about ordering
(Finished adding details for all commands)
(Added details about ordering)
Line 26: Line 26:


A scroll spec consists of two two-bit values and two one-bit values packed into a single byte, with the bit pattern: <tt>xxyy0w0h</tt>. The number of pixels to scroll along the X and Y axes is specified by <tt>xx</tt> and <tt>yy</tt>, and the direction is negative along the X/Y axis if <tt>w</tt> or <tt>h</tt> are set, respectively.
A scroll spec consists of two two-bit values and two one-bit values packed into a single byte, with the bit pattern: <tt>xxyy0w0h</tt>. The number of pixels to scroll along the X and Y axes is specified by <tt>xx</tt> and <tt>yy</tt>, and the direction is negative along the X/Y axis if <tt>w</tt> or <tt>h</tt> are set, respectively.
=== Ordering ===
When commands refer to regions of the floor and some ordering of the data is needed it will be sorted in a fixed format, with the X co-ordinate increasing until it would fall outside the region. The X co-ordinate is then reset and the Y co-ordinate increased by 1, until the region is defined.
For example, the region: (1, 0) to (2, 2) would be ordered as follows: (1, 0), (2, 0), (1, 1), (2, 1), (1, 2), (2, 2). The code for this algorithm might look something like:
for j in range(y, h+1):
  for i in range(x, w+1):
    output(pixel[x][y])
and going back the other way:
<!-- TODO: check this code -->
pos=0
while (col = read()):
  i = x + (pos % (w-x))
  j = y + (pos / (h-y))
  pixel[x][y] = col


== Commands ==
== Commands ==
Anonymous user