Pages: [1]   Go Down
Author Topic: glcd menu help  (Read 308 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello I am a beginner trying to figure out a way to make a 'blocking' menu to go to a loop.

This doesn't work. It gives: error: label ‘loop’ used but not defined

void menu(){

GLCD.print("start");
val=digitalRead(button1);
 
 if (val==HIGH){ goto loop;}}

void loop() {  code
}

Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I believe what you want is a function call:
Code:
void menu() {
  GLCD.print("start");
  val=digitalRead(button1);
  if (val==HIGH) doSomething();
}

void loop() { 
   …code...
}

void doSomething() {
  …code…
}

-br
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks. So I tried this with the accelstepper library (everything was defined earlier in the code):

So when I press the button2, the program breaks the menu and goes to the loop, running the stepper motor properly. However, when I go to the doSomething, the stepper motor does not work...I am sure I have defined everything correctly, but somehow the doSomething doesn't run the motor.

Code:
void menu() {
int ter=2;
while (ter==2){
  GLCD.print("start");
  but1=digitalRead(button1);
  but2=digitalRead(button2);
  if (but1==HIGH) doSomething();
if (but2==HIGH) {ter=0;GLCD.ClearScreen(); break;}
}
}

void loop() { 
...code...
for(int l=0; l<GLCD.Width; l++){
...code ...
int val=digitalRead(input1)
if (val<90){
stepper.setSpeed(80);
              stepper.runSpeed();}
              else if (val<70)
              {stepper.setSpeed(80);
              stepper.runSpeed();}
              else
              {stepper.setSpeed(50);
              stepper.runSpeed();}

}
}


void doSomething() {
 
int tt=3;
while (tt==3){
GLCD.ClearScreen();

GLCD.CursorToXY(50,5);
GLCD.print("Reverse");
stepper.setSpeed(50);
              stepper.runSpeed();}

}
Logged

Queens, New York
Online Online
Faraday Member
**
Karma: 86
Posts: 3468
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Could you please post the full code, and use better variable names.
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was able to figure out the problem. Thanks anyways!
Logged

Pages: [1]   Go Up
Jump to: