I'm fairly new to this, and I haven't been able to find any answers after searching repeatedly.
I have a Startscreen() function that I run during my setup sequence, and within that function i use various while loops and if/else conditionals. This function runs the startup screen of my program on my touch screen.
Well, when certain conditions are met inside a switch case, inside a while loop, I want to load my main screen and then immediately stop the whole Startscreen() function, like this:
LoadMainScreen();
return;
However, I end up seeing my main screen load up, and then my Startscreen() function continues!
Apparently, "return;" does not work as advertised. If I wanted to break out of the current loop, I'd use "break;", right?
So my question is, does it matter that I'm using return; inside a while loop, inside a switch case? How do I exit the whole top-level function completely?
I already tried breaking out of the function and going straight to my main loop this way:
LoadMeasScrn();
loop();
return;
and the same thing happens. Here's a bit of pseudocode that will hopefully show how I have things organized:
void setup(){
Startscreen(); //this screen provides user options
}
void loop(){
do all the other main functions of the program;
}
void Startscreen(){
if this thing, show this
if that thing, show that
take readings
switch(reading){
case(number):
while(1){
check for button presses
if (this){
if (that){
LoadMainScreen();
return; //this is supposed to quit the startscreen function completely and allow the program to move on to the main loop
case(other number);
do other stuff
break;
} //end of case stuff
Do other stuff that the startscreen program may need to do //this is what I'm seeing after calling return. should not see happening