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

Higher level LED methods? #6

Open
domchristie opened this issue Jan 20, 2022 · 2 comments
Open

Higher level LED methods? #6

domchristie opened this issue Jan 20, 2022 · 2 comments

Comments

@domchristie
Copy link
Contributor

The monome protocol specifies that messages for LED rows, columns, and maps target a "quad", i.e. an 8x8 segment with an x/y offset. The webmonome API reflects this, but I'm wondering if we could add some higher level methods to make it easier to set LED states in one call.

For example, in mlr, a single LED tracks the sample's play position. In JavaScript we might track this with an array of 16 items:

let row = [0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0]

To convey is to a device, we have to split the array into two chunks of 8, then call gridLedRow twice with offsets:

let chunks = chunk(row, 8) // [[0,0,0,0,0,0,0,0],[0,0,0,0,0,1,0,0]]
chunks.forEach((chunk, i) => monome.gridLedRow(i * 8, rowNumber, chunk))

I'm wondering if a nicer API might be:

monome.gridLedRow(rowNumber, row)

(and perhaps rename the current methods to gridLedRowQuad, or something?

@domchristie
Copy link
Contributor Author

(and perhaps rename the current methods to gridLedRowQuad, or something?

or rather just allow both signature types:

monome.gridLedRow(xOffset, yOffset, states) // up to 8 leds
monome.gridLedRow(yOffset, states) // up to 16 leds

@halvves
Copy link
Owner

halvves commented Mar 22, 2022

Sorry I never responded to this issue. Part of me me really wants to keep webmonome simple and ~1:1 with monome protocol, but I definitely like the idea of maybe making row/col/map more flexible. We can maybe keep the api as is, and make some assumptions if the "states" array is different lengths: 8 vs 16 etc. If the states array is longer we can just assume the the intent is to extend further down/right. gridLedMap might be a bit trickier, maybe optional dataWidth/dataHeight params and otherwise assume extending the map in width?

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

2 participants