|
7 | 7 | #
|
8 | 8 |
|
9 | 9 | from time import sleep
|
10 |
| - |
| 10 | +import Adafruit_BBIO.GPIO as GPIO |
11 | 11 |
|
12 | 12 | class Adafruit_CharLCD(object):
|
13 | 13 |
|
@@ -53,18 +53,12 @@ class Adafruit_CharLCD(object):
|
53 | 53 | LCD_5x10DOTS = 0x04
|
54 | 54 | LCD_5x8DOTS = 0x00
|
55 | 55 |
|
56 |
| - def __init__(self, pin_rs=25, pin_e=24, pins_db=[23, 17, 21, 22], GPIO=None): |
57 |
| - # Emulate the old behavior of using RPi.GPIO if we haven't been given |
58 |
| - # an explicit GPIO interface to use |
59 |
| - if not GPIO: |
60 |
| - import RPi.GPIO as GPIO |
61 |
| - GPIO.setwarnings(False) |
| 56 | + def __init__(self, pin_rs="P8_31", pin_e="P8_32", pins_db=["P8_27","P8_28","P8_29","P8_30"]): |
62 | 57 | self.GPIO = GPIO
|
63 | 58 | self.pin_rs = pin_rs
|
64 | 59 | self.pin_e = pin_e
|
65 | 60 | self.pins_db = pins_db
|
66 | 61 |
|
67 |
| - self.GPIO.setmode(GPIO.BCM) |
68 | 62 | self.GPIO.setup(self.pin_e, GPIO.OUT)
|
69 | 63 | self.GPIO.setup(self.pin_rs, GPIO.OUT)
|
70 | 64 |
|
@@ -137,7 +131,7 @@ def blink(self):
|
137 | 131 | self.displaycontrol |= self.LCD_BLINKON
|
138 | 132 | self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol)
|
139 | 133 |
|
140 |
| - def DisplayLeft(self): |
| 134 | + def scrollDisplayLeft(self): |
141 | 135 | """ These commands scroll the display without changing the RAM """
|
142 | 136 | self.write4bits(self.LCD_CURSORSHIFT | self.LCD_DISPLAYMOVE | self.LCD_MOVELEFT)
|
143 | 137 |
|
@@ -206,5 +200,6 @@ def message(self, text):
|
206 | 200 |
|
207 | 201 | if __name__ == '__main__':
|
208 | 202 | lcd = Adafruit_CharLCD()
|
| 203 | + lcd.begin(16,2) |
209 | 204 | lcd.clear()
|
210 | 205 | lcd.message(" Adafruit 16x2\n Standard LCD")
|
0 commit comments