getDeviceCount in LedControl Library

Hello everybody!

I am using 7-Segment Displays with MAX7219 using LedControl Library. I have a query regarding the getDeviceCount function.

LedControl lcDate = LedControl(1, 2, 3, 8);


void setup() {
  int devices=lc.getDeviceCount();
  for(int address=0;address<devices;address++) {         //we have to init all devices in a loop

     ....
     ....

}
  1. The getDeviceCount function retrieves the number of devices we have connected (which we have already defined in declaration). So what is the need of this function. As in my example I have specified that 8 devices will be used, then in later code I will assume the number of devices to be 8 itself.

  2. The number of devices in my case will be changed as per user’s settings. So I will store it in internal EEPROM. But most of the times I have seen the library object declaration before the Setup function as above. I have tried and it also works inside the setup function & may be in loop too. Is it ok to define it in code?

Thanks