Grid - LEDs not updating (grid studies JS)

Hello!

My grid has had a problem since day one where it will occasionally stop responding to any LED values sent to it. It still reports key presses so its still running fine, but the LEDs won’t update.

I’m using the grid studies JS file as a template to go off on this current project - I have a redraw function and i’m updating an array of LED values. This all goes thru a /level/led/map

It’ll work fine for 30 seconds and then stop updating - I’ve tried running the redraw function really fast as a stress test and it responds completetly fine, then out of nowhere it’ll stop updating.

Has anybody ran into a similar issue?

The only solution I’ve got is to disconnect then reconnect the usb cable

can you provide OS details?

does this happen with non-js applications?

what grid edition is this?

I’m on windows 10

I did a test last night where I made a patch that randoms changes leds on the grid without using JS, it ran for a few hours and didn’t crash. I’ve only had this issue when working with JS.

I believe this is a 2012 grids.

Here’s my code…

outlets = 3;
var leds = new Array(128)
var buffer = new Array(64)

var selectedPresets = [0, 0, 0, 0, 0, 0, 0, 0]
var activeTrigs = new Array(8)

var recallMap = {
0: [1, 2, 0],
1: [1, 2, 0.25],
2: [2, 1, 0.25],
3: [2, 1, 0],
4: [1, 3, 0],
5: [1, 5, 0.25],
6: [2, 3, 0.25],
7: [2, 4, 0.25],
8: [3, 1, 0.25],
9: [3, 2, 0.25],
10: [4, 1, 0.25],
11: [4, 2, 0.25],
12: [3, 4, 0],
13: [3, 4, 0.25],
14: [4, 3, 0.25],
15: [4, 3, 0]
}

function redraw() {
handleActiveSteps()
handleSelectedPresets()
// output OSC for first quadrant
  for(i1=0;i1<8;i1++)
  for(i2=0;i2<8;i2++)
  buffer[i1*8+i2] = leds[i1*16+i2];
  outlet(0,"osc","/monome/grid/led/level/map",0,0,buffer);

  // output OSC for second quadrant
  for(i1=0;i1<8;i1++)
  for(i2=0;i2<8;i2++)
      buffer[i1*8+i2] = leds[i1*16+i2+8];
  outlet(0,"osc","/monome/grid/led/level/map",8,0,buffer);
}

function clear() {
for (i =0; i< 129; i++ ){
		leds[i] = 0;
	}
}

function displayTrigs () {
activeTrigs = arrayfromargs(arguments);
outlet(1, "bang")
}

function handleActiveSteps () {
for(i1=0;i1<8;i1++){
    for(i2 = 0; i2< 16; i2++){
        if (activeTrigs[i1] === 1){
            leds[i1*16 + i2] = 4
        }
        else {
            leds[i1*16 + i2] = 0
        }
    }
}
}

function handleSelectedPresets () {
for(i1=0;i1<8;i1++){
    var rowNum = i1* 16
    leds[rowNum + selectedPresets[i1]] = 10
}
}

function key (x, y, z) {
if (z === 0){
    return
}
selectedPresets[y] = x
if (y === 0){
    outlet(2, "recall", "euclidean-strip", recallMap[x])
}
else {
    var eucl = "euclidean-strip[" + y + "]"
    outlet(2, "recall", eucl, recallMap[x])
}
}

clear()

I have a similar problem with the LEDs on my 40h grid. my LEDs just flicker and spaz out except for in loom which works perfectly.
have you found any solutions to this?

Can you share your .maxpatch?

ehhh maybe? how would i go about doing that? thanks tyler!

You can either zip it up and use the “upload” button above the comment text entry window or select everything and then choose “Copy Compressed” from the Edit menu. Then you can paste that in as code.