Don M
11-08-2011, 09:57 PM
Here is my code just for this discussions sake.
OBJ
encdr : "encoder"
oled : "oleddriver"
PUB main
repeat
case encdr.read
1 :
oled.moveto(1, 4)
oled.str(string("Routine 1 "))
if encdr.ispushed == 1
routine1
2 :
oled.moveto(1, 4)
oled.str(string("Routine 2 "))
if encdr.ispushed == 1
routine2
pri routine1
oled.moveto(1, 2)
oled.str(string ("Routine 1 "))
oled.moveto(1, 3)
oled.str(string ("Select option.... "))
repeat
case encdr.read
1 :
oled.moveto(1, 4)
oled.str(string("Option 1 "))
if encdr.ispushed == 1
oled.moveto(1, 4)
oled.str(string("Option 1 done..."))
pause(1000)
2 :
oled.moveto(1, 4)
oled.str(string("Exit to Main Menu "))
if encdr.ispushed == 1
oled.moveto(1, 2)
oled.str(string ("Main Menu "))
oled.moveto(1, 3)
oled.str(string ("Select Routine.... "))
return
pri routine2
oled.moveto(1, 2)
oled.str(string ("Routine 2 "))
oled.moveto(1, 3)
oled.str(string ("Select option.... "))
repeat
case encdr.read
1 :
oled.moveto(1, 4)
oled.str(string("Option 1 "))
if encdr.ispushed == 1
oled.moveto(1, 4)
oled.str(string("Option 1 complete..."))
pause(1000)
2 :
oled.moveto(1, 4)
oled.str(string("Option 2 "))
if encdr.ispushed == 1
oled.moveto(1, 4)
oled.str(string("Option 2 complete... "))
pause(1000)
3 :
oled.moveto(1, 4)
oled.str(string("Option 3 "))
if encdr.ispushed == 1
oled.moveto(1, 4)
oled.str(string("Option 3 complete... "))
pause(1000)
4 :
oled.moveto(1, 4)
oled.str(string("Option 4 "))
if encdr.ispushed == 1
oled.moveto(1, 4)
oled.str(string("Option 4 complete... "))
pause(1000)
5 :
oled.moveto(1, 4)
oled.str(string("Exit to Main Menu "))
if encdr.ispushed == 1
oled.moveto(1, 2)
oled.str(string ("Main Menu "))
oled.moveto(1, 3)
oled.str(string ("Select Routine.... "))
return
What I am trying to figure out is when the button is pushed (encdr.ispushed == 1) how do you make it so that the "1" that is set is not carried into the next routine? For example when it is in the Main loop and you rotate the encoder to "Routine 1" and then push the button it goes into routine1 and invokes"Option 1" right away and shows "Option 1 done".
Thanks. Don
OBJ
encdr : "encoder"
oled : "oleddriver"
PUB main
repeat
case encdr.read
1 :
oled.moveto(1, 4)
oled.str(string("Routine 1 "))
if encdr.ispushed == 1
routine1
2 :
oled.moveto(1, 4)
oled.str(string("Routine 2 "))
if encdr.ispushed == 1
routine2
pri routine1
oled.moveto(1, 2)
oled.str(string ("Routine 1 "))
oled.moveto(1, 3)
oled.str(string ("Select option.... "))
repeat
case encdr.read
1 :
oled.moveto(1, 4)
oled.str(string("Option 1 "))
if encdr.ispushed == 1
oled.moveto(1, 4)
oled.str(string("Option 1 done..."))
pause(1000)
2 :
oled.moveto(1, 4)
oled.str(string("Exit to Main Menu "))
if encdr.ispushed == 1
oled.moveto(1, 2)
oled.str(string ("Main Menu "))
oled.moveto(1, 3)
oled.str(string ("Select Routine.... "))
return
pri routine2
oled.moveto(1, 2)
oled.str(string ("Routine 2 "))
oled.moveto(1, 3)
oled.str(string ("Select option.... "))
repeat
case encdr.read
1 :
oled.moveto(1, 4)
oled.str(string("Option 1 "))
if encdr.ispushed == 1
oled.moveto(1, 4)
oled.str(string("Option 1 complete..."))
pause(1000)
2 :
oled.moveto(1, 4)
oled.str(string("Option 2 "))
if encdr.ispushed == 1
oled.moveto(1, 4)
oled.str(string("Option 2 complete... "))
pause(1000)
3 :
oled.moveto(1, 4)
oled.str(string("Option 3 "))
if encdr.ispushed == 1
oled.moveto(1, 4)
oled.str(string("Option 3 complete... "))
pause(1000)
4 :
oled.moveto(1, 4)
oled.str(string("Option 4 "))
if encdr.ispushed == 1
oled.moveto(1, 4)
oled.str(string("Option 4 complete... "))
pause(1000)
5 :
oled.moveto(1, 4)
oled.str(string("Exit to Main Menu "))
if encdr.ispushed == 1
oled.moveto(1, 2)
oled.str(string ("Main Menu "))
oled.moveto(1, 3)
oled.str(string ("Select Routine.... "))
return
What I am trying to figure out is when the button is pushed (encdr.ispushed == 1) how do you make it so that the "1" that is set is not carried into the next routine? For example when it is in the Main loop and you rotate the encoder to "Routine 1" and then push the button it goes into routine1 and invokes"Option 1" right away and shows "Option 1 done".
Thanks. Don