Advertisement
AverageMan

AverageBot Menu Idea

Oct 31st, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. # SET INITIAL COUNT FOR DISPLAY BOARD MENU CODE
  2. count = 1
  3.  
  4. def menu():
  5.     global count
  6.     while 1:
  7.    
  8.         time.sleep(0.01)
  9.        
  10.         if GPIO.input(switch): #If button clicked
  11.        
  12.             if count == 1: #maybe each count can go to its own function?
  13.            
  14.                 #bus.write_byte_data(addr, 0x13, 7) #do we need this line?
  15.                 bus.write_byte_data(addr, 0x12, N1) #Show number 1 on display
  16.                
  17.                 time.sleep(1) # wait for second press ## perhaps we can just use a second button here for ease?
  18.                
  19.                 if GPIO.input(switch): #IF STILL HOLDING BUTTON after a second go to function
  20.                
  21.                     # GO TO FUNCTION
  22.                
  23.                 elif not GPIO.input(switch): #if switch no longer being pushed
  24.                
  25.                     count = 2# update count to 2
  26.                     menu()# start the menu again ## ANYTHING WRONG WITH DOING THIS?
  27.                
  28.             if count == 2:
  29.                 # same here
  30.            
  31.             if count == 3:
  32.                 # same here
  33.                
  34.             if count == 4:
  35.                 # same here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement