Electric Potato
Well-known member
Hey yall, I've got a real nut-blaster of a problem going on over here with the nrf24, and figure maybe someone in here can help me regain some sanity. I've got a wireless midi controller that has generally been coming along swimmingly for a few weeks. It's a fairly small batch of code, about 40,000 bytes, 10,000 memory, and the wireless portion of it had been working just great. As I am now trying to finally finish it, I'm finding that seemingly insignificant changes are severing the wireless connection. I could bore you with a number of examples but I think this is the best one:
this singular if statement is in the main loop:
If I comment this one little if statement out, wireless works fine. I press buttons on the controller and the receiver responds. If I leave the statement in, the controller just sluggishly times out as I push the buttons and the receiver never responds. What's killing me is that patchSlot is never 2, it's only ever 1, so it's not even getting between the brackets, which I can confirm with the serial monitor. So I can't understand how it can be impacting anything. Actually, what is killing me worse is that this:
will also run fine, but THIS:
WONT! This is just a dummy boolean that otherwise only exists in its declaration so how can it possibly affect the wireless connection? I should also mention that the controller is SENDING midi packets like it always does, which I can check via serial...it's just that the receiver is ignoring them. This is strictly an issue with the wireless interaction.
In short, I can take a hardware/software setup that works perfectly fine on both ends, and break it by placing aLittleTeapot within an if statement whose condition isn't met. I should also mention that just putting it in there followed by a semicolon, i.e no operator, doesn't break wireless.
All I can surmise is that this has to do with memory in some way, but I have no idea how. And this is just one example...I can actually leave THIS if statement in without changing a thing, and remove a completely unrelated chunk of code from later on, and wireless works fine. Similarly, I originally declared AudioMemory(10) because I planned to use the DAC to emit info tones, but ended up not needing it. I found that by removing this declaration (during a time when wireless wasn't working) wireless started working again. I figured I had solved the problem, but after adding some new variables, some if statements, and maybe a timer, wireless was back to being problematic.
Am I missing something? Have I totally lost it? I hope someone can help me get my pants back on here because I'm nearing the point of wandering the streets to a melancholy jazz soundtrack
this singular if statement is in the main loop:
Code:
if(patchSlot==2){
Serial.println(patchSlot);
if(patchSlot2BlinkTimer>200 && !binaryFlicker){
yellowsOn = !yellowsOn;
patchSlot2BlinkTimer=0;
updateBinaryLEDS();
}
}
If I comment this one little if statement out, wireless works fine. I press buttons on the controller and the receiver responds. If I leave the statement in, the controller just sluggishly times out as I push the buttons and the receiver never responds. What's killing me is that patchSlot is never 2, it's only ever 1, so it's not even getting between the brackets, which I can confirm with the serial monitor. So I can't understand how it can be impacting anything. Actually, what is killing me worse is that this:
Code:
if(patchSlot==2){
Serial.println(patchSlot);
if(patchSlot2BlinkTimer>200 && !binaryFlicker){
}
}
will also run fine, but THIS:
Code:
if(patchSlot==2){
Serial.println(patchSlot);
if(patchSlot2BlinkTimer>200 && !binaryFlicker){
aLittleTeapot = !aLittleTeapot;
}
}
WONT! This is just a dummy boolean that otherwise only exists in its declaration so how can it possibly affect the wireless connection? I should also mention that the controller is SENDING midi packets like it always does, which I can check via serial...it's just that the receiver is ignoring them. This is strictly an issue with the wireless interaction.
In short, I can take a hardware/software setup that works perfectly fine on both ends, and break it by placing aLittleTeapot within an if statement whose condition isn't met. I should also mention that just putting it in there followed by a semicolon, i.e no operator, doesn't break wireless.
All I can surmise is that this has to do with memory in some way, but I have no idea how. And this is just one example...I can actually leave THIS if statement in without changing a thing, and remove a completely unrelated chunk of code from later on, and wireless works fine. Similarly, I originally declared AudioMemory(10) because I planned to use the DAC to emit info tones, but ended up not needing it. I found that by removing this declaration (during a time when wireless wasn't working) wireless started working again. I figured I had solved the problem, but after adding some new variables, some if statements, and maybe a timer, wireless was back to being problematic.
Am I missing something? Have I totally lost it? I hope someone can help me get my pants back on here because I'm nearing the point of wandering the streets to a melancholy jazz soundtrack
Last edited: