Thanks for the beer donation 😁 - it will be used wisely hahah 😉
I do not have you full code (please consider posting it here either in a message or as an attachment), so I'll give you an idea what I'm thinking off.
The Leds are stored in an array, and this is how we change the colors of each led: change the entry in the array.
Now arrays can be confusing (see my little programming course for the Arduino on Arrays) - in this case, think of it as a list of variables, accessible by an index.
It is a little more complicated than that, since most led libraries add some extra functions to it, but we can ignore that for now.
The idea I have is to define another array, holding the indices of the LEDs that we are allowed to use (the workspace).
So basically all LEDs minus "1,2,3,4,5,6,7,8,9,10,11,20,21,30,31,40,41,50,51,60,61,70,71,80,81,90,91,92,93,94,95,96,97,98,99,100".
This array will be a list of 8x8 = 64 items.
You may remember that most functions rely on the NUM_LEDS constant, so for our "translation" array we should define something like that as well.
For example: NUM_WORKSPACE_LEDS
#define NUM_WORKSPACE_LEDS 64
Next we need to define out translation array:
int Workspace[NUM_WORKSPACE_LEDS];
This way however, the array is empty, but we can pre-populate it manually or with a few loops.
Manually (way in the beginning of your sketch, where the "#define" are as well):
int Workspace[NUM_WORKSPACE_LEDS] = { 12, 13, 14, 15, 16, 17, 18, 19,
22, 23, 24, 25, 26, 27, 28, 29,
32, 33, 34, 35, 36, 37, 38, 39,
42, 43, 44, 45, 46, 47, 48, 49,
52, 53, 54, 55, 56, 57, 58, 59,
62, 63, 64, 65, 66, 67, 68, 69,
72, 73, 74, 75, 76, 77, 78, 79,
82, 83, 84, 85, 86, 87, 88, 89 };
So the array only holds the leds in the workspace.
Now, when working with LEDs, we need to "translate" the position to a position in the workspace.
As an example, this is how we used to fill all out leds to white:
for(int i=0; i<NUM_LEDS; i++) {
Led.setpixelcolor( i, ledcolor(255,255,255) );
}
If we only want to fill the workspace, we have to change it to this:
for(int i=0; i<NUM_WORKSPACE_LEDS; i++) {
Led.setpixelcolor( Workspace[i], ledcolor(255,255,255) );
}
So when we call for "Workspace[0]", we get the value "12" returned from the array - we translated the first led (0) to its actual position (12).
Same for Workspace[1], which returns 13, etc etc.
Before we proceed I'd recommend testing this in your code, I do not have a 10x10 matrix to test. 😊 (I do have beer though! 😁🍺 )
Now the next step would be applying this to the meteor-rain effect, but since you do not seem to be using my code (from the LED effects project), I can only guess what it could be.
Here an illustration how this can be done, based on my LED Effects project, where the meteor-rain effect looks like this.
We see the usual NUM_LEDS and that we call our leds based on a number (index).
void meteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) {
setAll(0,0,0);
for(int i = 0; i < NUM_LEDS+NUM_LEDS; i++) {
// fade brightness all LEDs one step
for(int j=0; j<NUM_LEDS; j++) {
if( (!meteorRandomDecay) || (random(10)>5) ) {
fadeToBlack(j, meteorTrailDecay );
}
}
// draw meteor
for(int j = 0; j < meteorSize; j++) {
if( ( i-j <NUM_LEDS) && (i-j>=0) ) {
setPixel(i-j, red, green, blue);
}
}
showStrip();
delay(SpeedDelay);
}
}
To make this work only for the workspace, we need to replace:
- NUM_LEDS with NUM_WORKSPACE_LEDS,
- and every call where we need the LED index needs to be translated with our Workspace array (eg setPixel( led_index, color) becomes setPixel( WorkSpace[led_index], color) ).
I hope that makes sense.
!! Pay attention to the square brackets ( [ and ] ) for arrays, versus the round brackets ( ( and ) ) used with functions. !!
Also note that setting all LEDS to one color now requires you to think for a second and decide wether this should affect all leds or just the LEDs in the workspace (see comment in the code below).
Modifying the code as such will result in something this (which will make the effect go zig-zag):
void meteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) {
// setAll(0,0,0); should not be used as it would erase your border
// instead only make workspace black like so:
for(int i = 0; i < NUM_WORKSPACE_LEDS; i++) {
setPixel(Workspace[i], 0, 0, 0);
}
// optional, to make black workspace visible:
// showStrip();
for(int i = 0; i < NUM_WORKSPACE_LEDS+NUM_WORKSPACE_LEDS; i++) {
// fade brightness all LEDs one step
for(int j=0; j<NUM_WORKSPACE_LEDS; j++) {
if( (!meteorRandomDecay) || (random(10)>5) ) {
fadeToBlack(Workspace[j], meteorTrailDecay );
}
}
// draw meteor
for(int j = 0; j < meteorSize; j++) {
if( ( i-j <NUM_WORKSPACE_LEDS) && (i-j>=0) ) {
setPixel(Workspace[i-j], red, green, blue);
}
}
showStrip();
delay(SpeedDelay);
}
}
You can see that NUM_LEDS simply get replaced by NUM_WORKSPACE_LEDS and each LED index is translated thought our Workspace array.
I hope this makes sense 😊
Caution though:
1) Do not blindly copy this code since your code seems to rely on something else, maybe the NeoPixel library? (I'd recommend FastLED though, as it is faster and more mature than NeoPixel)
2) I hope I didn't overlook any code where the index value for Workspace exceeds the array size (which could cause an error).
3) Again: untested code.