Quick summary:
- using the LedControl library
- 2- MAX chips (chained) (they are actually two physical/separate pcb's)..
- the 'second' MAX chip/pcb gets (physically) removed and re-inserted back into the running circuit/code
I need to re-initialize the 'second' MAX chip again, once it is connected back into the circuit.. (more specific, since they are chained I have been re-initializing them both. Targeting both or just the second chip, to shutdown = false; has made no difference, I have been sticking with going through both chips as that is what I initially in the sketch upon power-up)
Problem:
the second MAX chip/pcb is not behaving correctly upon re-inserting into the circuit.
I end up with 1 of two outcomes/scenarios:
a.) only the FIRST GROUP of 8 leds (DIG0 / SEGDP-G)... turns back on/displays & updates correctly (rest of the 30 leds are turned off)
b.) the bargraph does turn fully on and 'respond'.. (but sometimes immediately or after a couple of seconds,.. or few triggered events (button presses/fire) ...the project freezes, resets, audio and/or serial output stops when Im watching the code flow/execution)
-----------------------[detailed info below]-------------------------------
I can purposefully command results A or B by commenting out one line... but before that..
here is how I set up the chips when the project gets power..
LedControl lc=LedControl(3, 6, 5, 2); //scab board (2 max chips)
and then in the setup() loop...
byte devices=lc.getDeviceCount();
//we have to init all devices in a loop
for(byte address=0;address<devices;address++) {
/*The MAX72XX is in power-saving mode on startup*/
lc.shutdown(address,false);
/* Set the brightness to a medium values */
lc.setIntensity(address,15);
/* and clear the display */
lc.clearDisplay(address);
}
normal stuff.. and in no way a problem.. (just background info)..
however.. (as noted) the problem is when I take the pcb (chip) out of the rest of the circuit, and re-insert it.
I must obviously re-initialize the second chip (once it has gained power..etc).. because they start in shutdown mode..etc..
so I have stable code that tells me when the 'pcb/chip' has been re-inserted.. (because I am using another pin/switch to inform me when the pcb (connector/plug) connection has been made...(works fine.. letting you know I have a 'trigger' that tells me when to try and initialize that second chip again)
So when I get this 'trigger' letting me know I can attempt to re-initialize the second MAX chip and send it some data.....
I have tried this:
targetting ONLY the second chip by device ID (1)
lc.shutdown(1,false);
lc.setIntensity(1,15);
lc.clearDisplay(1);
and this: (thinking maybe I needed to re-initialize BOTH chips again being as they are daisy chained together)
byte devices=lc.getDeviceCount();
//we have to init all devices in a loop
for(byte address=0;address<devices;address++) {
/*The MAX72XX is in power-saving mode on startup*/
lc.shutdown(address,false);
/* Set the brightness to a medium values */
lc.setIntensity(address,15);
/* and clear the display */
//lc.clearDisplay(address); <-- do not clear out address 0/3-digit display
}
doing EITHER of the two approaches above yields the follow results:
- the bargraph ONLY has the first 8 leds of the 30 total lit up/or displaying the correct 'amount' (as this is a counter)
- rest of the 'code/sketch' is stable.. does NOT freeze, reset, loose audio or serial output
if I pull the pcb/chip and re-insert again.... (only that first group of 8 leds is back on/responsive)
thinking maybe not enough time for power up >> sending re-initialization code attempts.. I have thrown delays in there to debunk this. (waiting seconds even to try and re-initialize and send new data to it,...again only first 8)
If I add this line:
LedControl lc=LedControl(3, 6, 5, 2); //scab board (2 max chips)
as in
LedControl lc=LedControl(3, 6, 5, 2); //scab board (2 max chips)
byte devices=lc.getDeviceCount();
//we have to init all devices in a loop
for(byte address=0;address<devices;address++) {
/*The MAX72XX is in power-saving mode on startup*/
lc.shutdown(address,false);
/* Set the brightness to a medium values */
lc.setIntensity(address,15);
/* and clear the display */
//lc.clearDisplay(address); <-- do not clear out address 0/3-digit display
}
or
LedControl lc=LedControl(3, 6, 5, 2); //scab board (2 max chips)
lc.shutdown(1,false);
lc.setIntensity(1,15);
lc.clearDisplay(1);
the bargraph DOES all light back up (fully).. or correctly display the right amount..
but then either immediately.. freezes,, or when you press a button it resets, stop audio/serial output..etc..
it makes sens that I WOULDNT have to re-create the class/instance/constructor...
but if NOT there.. then the rest of the leds are not 'working'..
adding it obviously is NOT just overwriting the old one..and leading to a RAM problem?
hope that helps explain the issue.
thanks.