Variable name stopping Switch from working - weird!!!

Status
Not open for further replies.

bossredman

Well-known member
I've just spent the last few days troubleshooting a really annoying problem with a Teensy 3.6 project of mine.

I have 24 (3 x banks of 8) momentary switches connected to Digital inputs.
One switch toggles the state/mode of the top row - so that they can perform different things in differnt modes.

The strange thing is, when flipped to the 2nd mode, the 5th Switch stops working after the first time it is pressed.
All other switches work OK.
Even flipping back to mode 1 - switch 5 still does not work.
I had to reset the Teensy to get it to work again.

After confirming it wasn't a hardware/switch issue - I finally tracked down the lines of code that were causing the issue ... more specifically the 2 lines with "Param4_Value"

for (int i=0; i<Value_Len; ++i)
{
Param4_Value = {' '};
}

for (int i=0; i<Value_Len; ++i)
{
Param4_Value = MIDI.getSysExArray()[i+18];
}


This variable declared earlier as
char Param4_Value[8];
.

It is only called up in 1 other place & that is used to display the value on a screen.
mydisp[5].print(Param4_Value);
but I confirmed that that line was not causing the issue.

After reaching the verge of going crazy - for some reason I decided to rename the variable to "Param44_Value" & hey presto - everything works!

Although glad it's resolved, I'm desperate to understand why this was happening.
ANy ideas anyone pls?
 
I had similar experience and it had to docompiled. Errant caching of files during compiles. This went away with an upgrade to new arduino and teensyduino.
 
I had similar experience and it had to docompiled. Errant caching of files during compiles. This went away with an upgrade to new arduino and teensyduino.

hmmm- interesting - thanks.

TBH - I haven't updated either (IDE or Teensyduino) is a very long time.

Maybe now is the time.

Cheers
 
Status
Not open for further replies.
Back
Top