LED Matrix Control

I am attempting to control an 8X8 LED Matrix based on inputs. The easiest way I can see to do this is with an 8X8 integer array in which I can control the integers to either be a 0 or a 1. I am using the MAX7219 LED matrix driver. I can send it the entire matrix with the following code segments:

#include <LedControl.h>
int DIN = 12;
int CS =  11;
int CLK = 10;

int fill[8][8] = {
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
};

LedControl lc=LedControl(DIN,CLK,CS,0);

void setup(){
 lc.shutdown(0,false);       
 lc.setIntensity(0,15); 
 lc.clearDisplay(0);         
}

void loop(){ 
delay(1000);
   for (int i = 0; i < 8; i++){
      for (int j = 0; j < 8; j++){
         fill[i][j] = 1;
      }
   }
   Print(fill);
   delay(1000);
   for (int i = 0; i < 8; i++){
      for (int j = 0; j < 8; j++){
         fill[i][j] = 0;
      }
   }
   Print(fill);

}//End Void Loop


void Print(int a[8][8]){
    for (int q = 0; q < 8; q++){
        for (int w = 0; w < 8; w++){
            if (a[q][w] == 1){
                lc.setLed(0,q,w,true);
            }
            else{
                lc.setLed(0,q,w,false);
            }
        }
    }
}

I have had no issues with getting this to work, however, I am not a fan of how when it fills the matrix by setting each LED individually, you can see the sweep of the LEDs as they light up individually across the screen. I would prefer it to be nearly instantaneous.

This code appears to do it instantly, but I am not sure how to control each LED individually based on inputs.

#include <LedControl.h>

int DIN = 12;
int CS =  11;
int CLK = 10;


byte full[8]= {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
byte empty[8]= {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

LedControl lc=LedControl(DIN,CLK,CS,0);

void setup(){
 lc.shutdown(0,false);
 lc.setIntensity(0,15);
 lc.clearDisplay(0); 
}

void loop(){ 
    printByte(full);
    delay(1000);
    printByte(empty);
    delay(1000);
}



void printByte(byte character [])
{
  int i = 0;
  for(i=0;i<8;i++)
  {
    lc.setRow(0,i,character[i]);
  }
}

So my main questions is: Is there an easy way to control each LED easily (like in the 8X8 matrix in the first code segment) and convert the 8 integers in a row into one byte to print (like in the second code segment)? This way I could run a function to convert the matrix to a series of 8 bytes to send to the matrix.

I am a mechanical engineer, so am not extremely familiar with code. I am trying to learn though!

Thank you in advance for your comments!

The way this is normally done is to have an internal buffer between the setting code and device, with updates suspended until all changes are made to the buffer and then all the changes output at once. This is normally implemented in the device library.

Does LedControl have a class method to suspend updates to the device and then restart them?

If not, then an alternative you may want to try is the MD_MAX72xx library (link in the signature block below). If you do try and change it, please read the doc on how to configure the library to your hardware (matrix) type. There are many different styles of wiring the matrix to the MAX7219 IC.

The easiest way I can see to do this is with an 8X8 integer array in which I can control the integers to either be a 0 or a 1.

Why use ints when bytes would do and use half as much memory ?
Why use bytes when bits would do and use one eighth of the memory ?

Once you have the bits of your 8 row bytes set appropriately you can write them to the display.

setRow() is the fastest method in the class, because it does a SPI transfer directly. So try and design your for loops around that fact.