Keep buttons' and their LEDs' values on page change

@narayb I believe you’ve mentioned that all those press/long press values could also be set by my program occasionally. I am currently using this function to reset all LEDs to default when reloading my program like so this, so sending something to the GRID works and resets the press values.

// LEDs are numbered 9 to 12
for (int control = 9; control <= 12; control++) {
	ShortMessage message = new ShortMessage();
	// channel, CC number, value (0 = off)
	message.setMessage(ShortMessage.CONTROL_CHANGE, 0, control, 0);
	midiReceiver.send(message, -1);
}

However, when adapting this to also control the longpress values, it fails to get updated. This is with the press/longpress logic you’ve provided here. Can the longpress values not be set from the outside?

// LED values s are numbered 9 to 16
float value =127;
for (int control = 9; control <= 16; control++) {
	ShortMessage message = new ShortMessage();
	// channel, CC number, value (0 = off)
	message.setMessage(ShortMessage.CONTROL_CHANGE, 0, control, value);
	midiReceiver.send(message, -1);
}

This is Processing code, and only here to illustrate that sending a value to the short press button values works out (9 - 12 on my GRID), but doing the same for the long press button values (13 - 16 on my GRID) does not, using your (short) press / longpress logic.

I think that I just found my issue with the double state variable thing in this comment of yours.

If I have a function receiving a self in System, and that function is executed in an encoder and access a self variable from another encoder…would that be a variable scope issue?

Curiously the function can access with no-issue other entities in the encoder like the encoder value, but not the self variable stores in setup.

Still trying to wrap my mind around how things are scoped.

Do you guys have a system architecture diagram or several? Showing how the elements inter-connect, depend and when they get executed by default?

I think that a dependency/scope graph and a flowchart with all events would help.