test backlight changes
This commit is contained in:
		
							parent
							
								
									78d39b3eaa
								
							
						
					
					
						commit
						16fc4aa682
					
				
					 1 changed files with 7 additions and 3 deletions
				
			
		
							
								
								
									
										10
									
								
								leds.py
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								leds.py
									
										
									
									
									
								
							|  | @ -53,7 +53,7 @@ class Adafruit_CharLCD: | ||||||
|     LCD_5x10DOTS = 0x04 |     LCD_5x10DOTS = 0x04 | ||||||
|     LCD_5x8DOTS = 0x00 |     LCD_5x8DOTS = 0x00 | ||||||
| 
 | 
 | ||||||
|     def __init__(self, pin_rs=24, pin_e=23, pins_db=[17, 18, 27, 22], GPIO=None): |     def __init__(self, pin_rs=24, pin_e=23, pin_b=04, pins_db=[17, 18, 27, 22], GPIO=None): | ||||||
|         # Emulate the old behavior of using RPi.GPIO if we haven't been given |         # Emulate the old behavior of using RPi.GPIO if we haven't been given | ||||||
|         # an explicit GPIO interface to use |         # an explicit GPIO interface to use | ||||||
|         if not GPIO: |         if not GPIO: | ||||||
|  | @ -61,16 +61,20 @@ class Adafruit_CharLCD: | ||||||
|         self.GPIO = GPIO |         self.GPIO = GPIO | ||||||
|         self.pin_rs = pin_rs |         self.pin_rs = pin_rs | ||||||
|         self.pin_e = pin_e |         self.pin_e = pin_e | ||||||
|  |         self.pin_b = pin_b | ||||||
|         self.pins_db = pins_db |         self.pins_db = pins_db | ||||||
| 
 | 
 | ||||||
|         self.GPIO.setwarnings(False) |         self.GPIO.setwarnings(False) | ||||||
|         self.GPIO.setmode(GPIO.BCM) |         self.GPIO.setmode(GPIO.BCM) | ||||||
|         self.GPIO.setup(self.pin_e, GPIO.OUT) |         self.GPIO.setup(self.pin_e, GPIO.OUT) | ||||||
|         self.GPIO.setup(self.pin_rs, GPIO.OUT) |         self.GPIO.setup(self.pin_rs, GPIO.OUT) | ||||||
|  |         self.GPIO.setup(self.pin_b, GPIO.OUT) | ||||||
| 
 | 
 | ||||||
|         for pin in self.pins_db: |         for pin in self.pins_db: | ||||||
|             self.GPIO.setup(pin, GPIO.OUT) |             self.GPIO.setup(pin, GPIO.OUT) | ||||||
| 
 | 
 | ||||||
|  |         self.GPIO.output(self.pin_b, True) | ||||||
|  |          | ||||||
|         self.write4bits(0x33)  # initialization |         self.write4bits(0x33)  # initialization | ||||||
|         self.write4bits(0x32)  # initialization |         self.write4bits(0x32)  # initialization | ||||||
|         self.write4bits(0x28)  # 2 line 5x7 matrix |         self.write4bits(0x28)  # 2 line 5x7 matrix | ||||||
|  | @ -118,13 +122,13 @@ class Adafruit_CharLCD: | ||||||
| 
 | 
 | ||||||
|     def noDisplay(self): |     def noDisplay(self): | ||||||
|         """ Turn the display off (quickly) """ |         """ Turn the display off (quickly) """ | ||||||
| 
 |         self.GPIO.output(self.pin_b, False) | ||||||
|         self.displaycontrol &= ~self.LCD_DISPLAYON |         self.displaycontrol &= ~self.LCD_DISPLAYON | ||||||
|         self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol) |         self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol) | ||||||
| 
 | 
 | ||||||
|     def display(self): |     def display(self): | ||||||
|         """ Turn the display on (quickly) """ |         """ Turn the display on (quickly) """ | ||||||
| 
 |         self.GPIO.output(self.pin_b, True) | ||||||
|         self.displaycontrol |= self.LCD_DISPLAYON |         self.displaycontrol |= self.LCD_DISPLAYON | ||||||
|         self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol) |         self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue