fix variable issue?
This commit is contained in:
		
							parent
							
								
									d2a4cf3bc2
								
							
						
					
					
						commit
						a4ad0da943
					
				
					 1 changed files with 14 additions and 11 deletions
				
			
		
							
								
								
									
										25
									
								
								leds.py
									
										
									
									
									
								
							
							
						
						
									
										25
									
								
								leds.py
									
										
									
									
									
								
							|  | @ -7,14 +7,17 @@ | |||
| # | ||||
| 
 | ||||
| from time import sleep | ||||
| import sys | ||||
| import lcd_manager | ||||
| import light_manager | ||||
| import logging | ||||
| 
 | ||||
| level = 0 | ||||
| level_max = 14 | ||||
| level_state = 0 | ||||
| color_state = 0 | ||||
| this = sys.modules[__name__] | ||||
| 
 | ||||
| this.level = 0 | ||||
| this.level_max = 14 | ||||
| this.level_state = 0 | ||||
| this.color_state = 0 | ||||
| 
 | ||||
| 
 | ||||
| def lightlevel(lcd, level): | ||||
|  | @ -34,11 +37,11 @@ def color(lcd): | |||
| 
 | ||||
| 
 | ||||
| def get_state(): | ||||
|     if level_state > 0: | ||||
|         level_state -= 1 | ||||
|     if this.level_state > 0: | ||||
|         this.level_state -= 1 | ||||
|         return "level" | ||||
|     elif color_state > 0: | ||||
|         color_state -= 1 | ||||
|     elif this.color_state > 0: | ||||
|         this.color_state -= 1 | ||||
|         return "color" | ||||
|     else: | ||||
|         return "idle" | ||||
|  | @ -59,9 +62,9 @@ def loop(): | |||
|         state = get_state() | ||||
| 
 | ||||
|         if state == "level": | ||||
|             if lights.get_light_level() != (level / level_max): | ||||
|                 lights.set_light_level(level / level_max) | ||||
|             lightlevel(lcd, level) | ||||
|             if lights.get_light_level() != (this.level / this.level_max): | ||||
|                 lights.set_light_level(this.level / this.level_max) | ||||
|             lightlevel(lcd, this.level) | ||||
|         elif state == "color": | ||||
|             color(lcd) | ||||
|         else: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue