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_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
|
||||
# an explicit GPIO interface to use
|
||||
if not GPIO:
|
||||
|
@ -61,16 +61,20 @@ class Adafruit_CharLCD:
|
|||
self.GPIO = GPIO
|
||||
self.pin_rs = pin_rs
|
||||
self.pin_e = pin_e
|
||||
self.pin_b = pin_b
|
||||
self.pins_db = pins_db
|
||||
|
||||
self.GPIO.setwarnings(False)
|
||||
self.GPIO.setmode(GPIO.BCM)
|
||||
self.GPIO.setup(self.pin_e, GPIO.OUT)
|
||||
self.GPIO.setup(self.pin_rs, GPIO.OUT)
|
||||
self.GPIO.setup(self.pin_b, GPIO.OUT)
|
||||
|
||||
for pin in self.pins_db:
|
||||
self.GPIO.setup(pin, GPIO.OUT)
|
||||
|
||||
self.GPIO.output(self.pin_b, True)
|
||||
|
||||
self.write4bits(0x33) # initialization
|
||||
self.write4bits(0x32) # initialization
|
||||
self.write4bits(0x28) # 2 line 5x7 matrix
|
||||
|
@ -118,13 +122,13 @@ class Adafruit_CharLCD:
|
|||
|
||||
def noDisplay(self):
|
||||
""" Turn the display off (quickly) """
|
||||
|
||||
self.GPIO.output(self.pin_b, False)
|
||||
self.displaycontrol &= ~self.LCD_DISPLAYON
|
||||
self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol)
|
||||
|
||||
def display(self):
|
||||
""" Turn the display on (quickly) """
|
||||
|
||||
self.GPIO.output(self.pin_b, True)
|
||||
self.displaycontrol |= self.LCD_DISPLAYON
|
||||
self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol)
|
||||
|
||||
|
|
Loading…
Reference in a new issue