Skip to content

Commit 14a7df0

Browse files
committed
Switch shift reg name to 74HC595.
1 parent 33e3306 commit 14a7df0

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

adafruit_character_lcd/character_lcd.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@
8989
_MCP23008_LCD_D7 = const(6)
9090
_MCP23008_LCD_BACKLIGHT = const(7)
9191

92-
# 74LS595 SPI backpack pin mapping from LCD logical pin to 74LS595 pin.
93-
_74LS595_LCD_RS = const(1)
94-
_74LS595_LCD_EN = const(2)
95-
_74LS595_LCD_D4 = const(6)
96-
_74LS595_LCD_D5 = const(5)
97-
_74LS595_LCD_D6 = const(4)
98-
_74LS595_LCD_D7 = const(3)
99-
_74LS595_LCD_BACKLIGHT = const(7)
92+
# 74HC595 SPI backpack pin mapping from LCD logical pin to 74HC595 pin.
93+
_74HC595_LCD_RS = const(1)
94+
_74HC595_LCD_EN = const(2)
95+
_74HC595_LCD_D4 = const(6)
96+
_74HC595_LCD_D5 = const(5)
97+
_74HC595_LCD_D6 = const(4)
98+
_74HC595_LCD_D7 = const(3)
99+
_74HC595_LCD_BACKLIGHT = const(7)
100100

101101
#pylint: enable-msg=bad-whitespace
102102

@@ -389,17 +389,17 @@ def __init__(self, spi, latch, cols, lines):
389389
columns and lines on the display.
390390
"""
391391
# See comment above on I2C class for why this is imported here:
392-
import adafruit_character_lcd.shift_reg_74ls595 as shift_reg_74ls595
393-
self._sr = shift_reg_74ls595.ShiftReg74LS595(spi, latch)
392+
import adafruit_character_lcd.shift_reg_74hc595 as shift_reg_74hc595
393+
self._sr = shift_reg_74hc595.ShiftReg74HC595(spi, latch)
394394
# Setup pins for SPI backpack, see diagram:
395395
# https://learn.adafruit.com/assets/35681
396-
reset = self._sr.DigitalInOut(_74LS595_LCD_RS, self._sr)
397-
enable = self._sr.DigitalInOut(_74LS595_LCD_EN, self._sr)
398-
dl4 = self._sr.DigitalInOut(_74LS595_LCD_D4, self._sr)
399-
dl5 = self._sr.DigitalInOut(_74LS595_LCD_D5, self._sr)
400-
dl6 = self._sr.DigitalInOut(_74LS595_LCD_D6, self._sr)
401-
dl7 = self._sr.DigitalInOut(_74LS595_LCD_D7, self._sr)
402-
backlight = self._sr.DigitalInOut(_74LS595_LCD_BACKLIGHT, self._sr)
396+
reset = self._sr.DigitalInOut(_74HC595_LCD_RS, self._sr)
397+
enable = self._sr.DigitalInOut(_74HC595_LCD_EN, self._sr)
398+
dl4 = self._sr.DigitalInOut(_74HC595_LCD_D4, self._sr)
399+
dl5 = self._sr.DigitalInOut(_74HC595_LCD_D5, self._sr)
400+
dl6 = self._sr.DigitalInOut(_74HC595_LCD_D6, self._sr)
401+
dl7 = self._sr.DigitalInOut(_74HC595_LCD_D7, self._sr)
402+
backlight = self._sr.DigitalInOut(_74HC595_LCD_BACKLIGHT, self._sr)
403403
# Call superclass initializer with shift register pins.
404404
super().__init__(reset, enable, dl4, dl5, dl6, dl7, cols, lines,
405405
backlight=backlight)
@@ -410,24 +410,24 @@ def _write8(self, value, char_mode=False):
410410
# slow with overhead of SPI communication).
411411
gpio = self._sr.gpio
412412
# Make sure enable is low.
413-
gpio = _set_bit(gpio, _74LS595_LCD_EN, False)
413+
gpio = _set_bit(gpio, _74HC595_LCD_EN, False)
414414
# Set character/data bit. (charmode = False).
415-
gpio = _set_bit(gpio, _74LS595_LCD_RS, char_mode)
415+
gpio = _set_bit(gpio, _74HC595_LCD_RS, char_mode)
416416
# Set upper 4 bits.
417-
gpio = _set_bit(gpio, _74LS595_LCD_D4, ((value >> 4) & 1) > 0)
418-
gpio = _set_bit(gpio, _74LS595_LCD_D5, ((value >> 5) & 1) > 0)
419-
gpio = _set_bit(gpio, _74LS595_LCD_D6, ((value >> 6) & 1) > 0)
420-
gpio = _set_bit(gpio, _74LS595_LCD_D7, ((value >> 7) & 1) > 0)
417+
gpio = _set_bit(gpio, _74HC595_LCD_D4, ((value >> 4) & 1) > 0)
418+
gpio = _set_bit(gpio, _74HC595_LCD_D5, ((value >> 5) & 1) > 0)
419+
gpio = _set_bit(gpio, _74HC595_LCD_D6, ((value >> 6) & 1) > 0)
420+
gpio = _set_bit(gpio, _74HC595_LCD_D7, ((value >> 7) & 1) > 0)
421421
self._sr.gpio = gpio
422422
# Send command.
423423
self._pulse_enable()
424424
# Now repeat for lower 4 bits.
425425
gpio = self._sr.gpio
426-
gpio = _set_bit(gpio, _74LS595_LCD_EN, False)
427-
gpio = _set_bit(gpio, _74LS595_LCD_RS, char_mode)
428-
gpio = _set_bit(gpio, _74LS595_LCD_D4, (value & 1) > 0)
429-
gpio = _set_bit(gpio, _74LS595_LCD_D5, ((value >> 1) & 1) > 0)
430-
gpio = _set_bit(gpio, _74LS595_LCD_D6, ((value >> 2) & 1) > 0)
431-
gpio = _set_bit(gpio, _74LS595_LCD_D7, ((value >> 3) & 1) > 0)
426+
gpio = _set_bit(gpio, _74HC595_LCD_EN, False)
427+
gpio = _set_bit(gpio, _74HC595_LCD_RS, char_mode)
428+
gpio = _set_bit(gpio, _74HC595_LCD_D4, (value & 1) > 0)
429+
gpio = _set_bit(gpio, _74HC595_LCD_D5, ((value >> 1) & 1) > 0)
430+
gpio = _set_bit(gpio, _74HC595_LCD_D6, ((value >> 2) & 1) > 0)
431+
gpio = _set_bit(gpio, _74HC595_LCD_D7, ((value >> 3) & 1) > 0)
432432
self._sr.gpio = gpio
433433
self._pulse_enable()

adafruit_character_lcd/shift_reg_74ls595.py renamed to adafruit_character_lcd/shift_reg_74hc595.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
"""74LS595 Serial to Paralllel Shift Register Driver
2-
Bare-bones driver for the 74LS595, as used by the character LCD
3-
backpack. This exposes the 74LS595 and its pins as standard CircuitPython
1+
"""74HC595 Serial to Paralllel Shift Register Driver
2+
Bare-bones driver for the 74HC595, as used by the character LCD
3+
backpack. This exposes the 74HC595 and its pins as standard CircuitPython
44
digitalio pins. Currently this is integrated in the character LCD class for
55
simplicity and reduction in dependent imports, but it could be broken out
66
into a standalone library later.
@@ -12,18 +12,18 @@
1212

1313
#pylint: disable-msg=too-few-public-methods
1414
#pylint: disable-msg=no-self-use
15-
class ShiftReg74LS595:
15+
class ShiftReg74HC595:
1616
"""Shift Register 74LS95 driver class"""
1717
class DigitalInOut:
18-
"""Digital input/output of the 74LS595. The interface is exactly the
18+
"""Digital input/output of the 74HC595. The interface is exactly the
1919
same as the digitalio.DigitalInOut class, however note that by design
2020
this device is OUTPUT ONLY! Attempting to read inputs or set
2121
direction as input will raise an exception.
2222
"""
2323

2424
def __init__(self, pin_number, shift_reg_74ls595):
2525
"""Specify the pin number of the shift register (0...7) and
26-
ShiftReg74LS595 instance.
26+
ShiftReg74HC595 instance.
2727
"""
2828
self._pin = pin_number
2929
self._sr = shift_reg_74ls595
@@ -35,12 +35,12 @@ def switch_to_output(self, value=False):
3535

3636
def switch_to_input(self):
3737
"""do not call switch_to_input"""
38-
raise RuntimeError('Unable to use 74LS595 as digital input!')
38+
raise RuntimeError('Unable to use 74HC595 as digital input!')
3939

4040
@property
4141
def value(self):
4242
"""do not call value"""
43-
raise RuntimeError('Unable to use 74LS595 as digital input!')
43+
raise RuntimeError('Unable to use 74HC595 as digital input!')
4444

4545
@value.setter
4646
def value(self, val):
@@ -61,7 +61,7 @@ def direction(self):
6161
def direction(self, val):
6262
"""Can only be set as OUTPUT!"""
6363
if val != digitalio.Direction.OUTPUT:
64-
raise RuntimeError('Unable to use 74LS595 as digital input!')
64+
raise RuntimeError('Unable to use 74HC595 as digital input!')
6565

6666
@property
6767
def pull(self):
@@ -72,7 +72,7 @@ def pull(self):
7272
def pull(self, val):
7373
"""Only supports null/no pull state."""
7474
if val is not None:
75-
raise RuntimeError('Unable to set 74LS595 pull!')
75+
raise RuntimeError('Unable to set 74HC595 pull!')
7676

7777

7878
def __init__(self, spi, latch):

0 commit comments

Comments
 (0)