SOS/S.O.S. when I change a variable name?!?

Hey has anyone else experienced SOS hard faults with minor changes on working code?

I do somewhat frequently, it is confusing and annoying. I wish there was a better way to debug things like this then SOS lights.

Here is my current one. (snippet for larger code) this compiles and works fine:

#define DATAPIN3   D2
#define CLOCKPIN3  D3
Adafruit_DotStar BOTLEFT = Adafruit_DotStar(NUMPIXELS, DATAPIN3, CLOCKPIN3, DOTSTAR_BGR);

#define DATAPIN4   D4
#define CLOCKPIN4  D5
Adafruit_DotStar BOTRIGHT = Adafruit_DotStar(NUMPIXELS, DATAPIN4, CLOCKPIN4, DOTSTAR_BGR);

this causes a SOS hardfault (all I did was swap the variable names BOTLEFT and BOTRIGHT

#define DATAPIN3   D2
#define CLOCKPIN3  D3
Adafruit_DotStar BOTRIGHT = Adafruit_DotStar(NUMPIXELS, DATAPIN3, CLOCKPIN3, DOTSTAR_BGR);

#define DATAPIN4   D4
#define CLOCKPIN4  D5
Adafruit_DotStar BOTLEFT = Adafruit_DotStar(NUMPIXELS, DATAPIN4, CLOCKPIN4, DOTSTAR_BGR);

I “undo” and re-flash and everything is back to normal.

WHY DOES THIS MATTER? Please help me understand…

I don’t see a reason why the naming should make a difference, but try to do this instead

Adafruit_DotStar BOTRIGHT(NUMPIXELS, DATAPIN3, CLOCKPIN3, DOTSTAR_BGR);
Adafruit_DotStar BOTLEFT(NUMPIXELS, DATAPIN4, CLOCKPIN4, DOTSTAR_BGR);

The other way you’ll first create a BOTRIGHT and a temporary object and then assign the temp object to the original BOTRIGHT and the same for BOTLEFT.

1 Like

sorry to have disappeared, thanks for the feedback. That is clear thinking, as far as declaration goes I was mindlessly using the example code from the library.
-but it didn’t help…

It turns out that the panic is happening when I call this one function… it got a <0 value for something that didn’t like it apparently. How the variable name or pin assignment related, I don’t know. I have fixed this bug and now things seem fine as far as renaming variables, maybe someday I’ll dig around to find out why.

1 Like