Need help with switch logic code
Don M
Posts: 1,653
Here is my code just for this discussions sake.
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
Comments