JamesHarrison / faderuby

Fadecandy/Open Pixel Control protocol client for Ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

There needs to be an index method somewhere

estiens opened this issue · comments

If you just want to control a strip on any other output other than 0, it is currently impossible without going through all the other pixels first. There should be an index method so, for example, you could just address the 64 pixels attached to output 2, and not the ones at 0 and 1. For example in the processing java program.

void led(int index, int x, int y)  
  {
    // For convenience, automatically grow the pixelLocations array. We do want this to be an array,
    // instead of a HashMap, to keep draw() as fast as it can be.
    if (pixelLocations == null) {
      pixelLocations = new int[index + 1];
    } else if (index >= pixelLocations.length) {
      pixelLocations = Arrays.copyOf(pixelLocations, index + 1);
    }

    pixelLocations[index] = x + width * y;
  }

I'll think about it and try to get a PR. It might also be nice to have helper methods like

set_n_pixels(16) where you can address arbitrary chunks of pixels