54
54
55
55
# pylint: disable-msg=bad-whitespace
56
56
# Commands
57
- _LCD_CLEARDISPLAY = const (0x01 )
58
- _LCD_RETURNHOME = const (0x02 )
59
- _LCD_ENTRYMODESET = const (0x04 )
60
- _LCD_DISPLAYCONTROL = const (0x08 )
61
- _LCD_CURSORSHIFT = const (0x10 )
62
- _LCD_FUNCTIONSET = const (0x20 )
63
- _LCD_SETCGRAMADDR = const (0x40 )
64
- _LCD_SETDDRAMADDR = const (0x80 )
57
+ _LCD_CLEARDISPLAY = const (0x01 )
58
+ _LCD_RETURNHOME = const (0x02 )
59
+ _LCD_ENTRYMODESET = const (0x04 )
60
+ _LCD_DISPLAYCONTROL = const (0x08 )
61
+ _LCD_CURSORSHIFT = const (0x10 )
62
+ _LCD_FUNCTIONSET = const (0x20 )
63
+ _LCD_SETCGRAMADDR = const (0x40 )
64
+ _LCD_SETDDRAMADDR = const (0x80 )
65
65
66
66
# Entry flags
67
- _LCD_ENTRYLEFT = const (0x02 )
67
+ _LCD_ENTRYLEFT = const (0x02 )
68
68
_LCD_ENTRYSHIFTDECREMENT = const (0x00 )
69
69
70
70
# Control flags
71
- _LCD_DISPLAYON = const (0x04 )
72
- _LCD_CURSORON = const (0x02 )
73
- _LCD_CURSOROFF = const (0x00 )
74
- _LCD_BLINKON = const (0x01 )
75
- _LCD_BLINKOFF = const (0x00 )
71
+ _LCD_DISPLAYON = const (0x04 )
72
+ _LCD_CURSORON = const (0x02 )
73
+ _LCD_CURSOROFF = const (0x00 )
74
+ _LCD_BLINKON = const (0x01 )
75
+ _LCD_BLINKOFF = const (0x00 )
76
76
77
77
# Move flags
78
- _LCD_DISPLAYMOVE = const (0x08 )
79
- _LCD_MOVERIGHT = const (0x04 )
80
- _LCD_MOVELEFT = const (0x00 )
78
+ _LCD_DISPLAYMOVE = const (0x08 )
79
+ _LCD_MOVERIGHT = const (0x04 )
80
+ _LCD_MOVELEFT = const (0x00 )
81
81
82
82
# Function set flags
83
- _LCD_4BITMODE = const (0x00 )
84
- _LCD_2LINE = const (0x08 )
85
- _LCD_1LINE = const (0x00 )
86
- _LCD_5X8DOTS = const (0x00 )
83
+ _LCD_4BITMODE = const (0x00 )
84
+ _LCD_2LINE = const (0x08 )
85
+ _LCD_1LINE = const (0x00 )
86
+ _LCD_5X8DOTS = const (0x00 )
87
87
88
88
# Offset for up to 4 rows.
89
- _LCD_ROW_OFFSETS = (0x00 , 0x40 , 0x14 , 0x54 )
89
+ _LCD_ROW_OFFSETS = (0x00 , 0x40 , 0x14 , 0x54 )
90
90
91
91
# pylint: enable-msg=bad-whitespace
92
92
@@ -128,12 +128,12 @@ class Character_LCD:
128
128
:param lines: The lines on the charLCD
129
129
130
130
"""
131
+
131
132
LEFT_TO_RIGHT = const (0 )
132
133
RIGHT_TO_LEFT = const (1 )
133
134
134
135
# pylint: disable-msg=too-many-arguments
135
- def __init__ (self , rs , en , d4 , d5 , d6 , d7 , columns , lines
136
- ):
136
+ def __init__ (self , rs , en , d4 , d5 , d6 , d7 , columns , lines ):
137
137
138
138
self .columns = columns
139
139
self .lines = lines
@@ -146,7 +146,7 @@ def __init__(self, rs, en, d4, d5, d6, d7, columns, lines
146
146
self .dl7 = d7
147
147
148
148
# set all pins as outputs
149
- for pin in (rs , en , d4 , d5 , d6 , d7 ):
149
+ for pin in (rs , en , d4 , d5 , d6 , d7 ):
150
150
pin .direction = digitalio .Direction .OUTPUT
151
151
152
152
# Initialise the display
@@ -174,6 +174,7 @@ def __init__(self, rs, en, d4, d5, d6, d7, columns, lines
174
174
self .row = 0
175
175
self .column = 0
176
176
self ._column_align = False
177
+
177
178
# pylint: enable-msg=too-many-arguments
178
179
179
180
def home (self ):
@@ -215,7 +216,7 @@ def column_align(self, enable):
215
216
if isinstance (enable , bool ):
216
217
self ._column_align = enable
217
218
else :
218
- raise ValueError (' The column_align value must be either True or False' )
219
+ raise ValueError (" The column_align value must be either True or False" )
219
220
220
221
@property
221
222
def cursor (self ):
@@ -379,7 +380,7 @@ def message(self, message):
379
380
self .cursor_position (col , line )
380
381
initial_character += 1
381
382
# If character is \n, go to next line
382
- if character == ' \n ' :
383
+ if character == " \n " :
383
384
line += 1
384
385
# Start the second line at (0, 1) unless direction is set right to left in
385
386
# which case start on the opposite side of the display if cursor_position
@@ -540,6 +541,8 @@ def _pulse_enable(self):
540
541
time .sleep (0.0000001 )
541
542
self .enable .value = False
542
543
time .sleep (0.0000001 )
544
+
545
+
543
546
# pylint: enable-msg=too-many-instance-attributes
544
547
545
548
@@ -561,9 +564,21 @@ class Character_LCD_Mono(Character_LCD):
561
564
to common cathode.
562
565
563
566
"""
567
+
564
568
# pylint: disable-msg=too-many-arguments
565
- def __init__ (self , rs , en , db4 , db5 , db6 , db7 , columns , lines ,
566
- backlight_pin = None , backlight_inverted = False ):
569
+ def __init__ (
570
+ self ,
571
+ rs ,
572
+ en ,
573
+ db4 ,
574
+ db5 ,
575
+ db6 ,
576
+ db7 ,
577
+ columns ,
578
+ lines ,
579
+ backlight_pin = None ,
580
+ backlight_inverted = False ,
581
+ ):
567
582
568
583
# Backlight pin and inversion
569
584
self .backlight_pin = backlight_pin
@@ -574,6 +589,7 @@ def __init__(self, rs, en, db4, db5, db6, db7, columns, lines,
574
589
self .backlight_pin .direction = digitalio .Direction .OUTPUT
575
590
self .backlight = True
576
591
super ().__init__ (rs , en , db4 , db5 , db6 , db7 , columns , lines )
592
+
577
593
# pylint: enable-msg=too-many-arguments
578
594
579
595
@property
@@ -631,9 +647,23 @@ class Character_LCD_RGB(Character_LCD):
631
647
write from the display. Not necessary if only writing to the display. Used on shield.
632
648
633
649
"""
650
+
634
651
# pylint: disable-msg=too-many-arguments
635
- def __init__ (self , rs , en , db4 , db5 , db6 , db7 , columns , lines ,
636
- red , green , blue , read_write = None ):
652
+ def __init__ (
653
+ self ,
654
+ rs ,
655
+ en ,
656
+ db4 ,
657
+ db5 ,
658
+ db6 ,
659
+ db7 ,
660
+ columns ,
661
+ lines ,
662
+ red ,
663
+ green ,
664
+ blue ,
665
+ read_write = None ,
666
+ ):
637
667
638
668
# Define read_write (rw) pin
639
669
self .read_write = read_write
@@ -646,13 +676,13 @@ def __init__(self, rs, en, db4, db5, db6, db7, columns, lines,
646
676
self .rgb_led = [red , green , blue ]
647
677
648
678
for pin in self .rgb_led :
649
- if hasattr (pin , ' direction' ):
679
+ if hasattr (pin , " direction" ):
650
680
# Assume a digitalio.DigitalInOut or compatible interface:
651
681
pin .direction = digitalio .Direction .OUTPUT
652
- elif not hasattr (pin , ' duty_cycle' ):
682
+ elif not hasattr (pin , " duty_cycle" ):
653
683
raise TypeError (
654
- ' RGB LED objects must be instances of digitalio.DigitalInOut'
655
- ' or pulseio.PWMOut, or provide a compatible interface.'
684
+ " RGB LED objects must be instances of digitalio.DigitalInOut"
685
+ " or pulseio.PWMOut, or provide a compatible interface."
656
686
)
657
687
658
688
self ._color = [0 , 0 , 0 ]
@@ -691,10 +721,10 @@ def color(self):
691
721
def color (self , color ):
692
722
self ._color = color
693
723
for number , pin in enumerate (self .rgb_led ):
694
- if hasattr (pin , ' duty_cycle' ):
724
+ if hasattr (pin , " duty_cycle" ):
695
725
# Assume a pulseio.PWMOut or compatible interface and set duty cycle:
696
726
pin .duty_cycle = int (_map (color [number ], 0 , 100 , 65535 , 0 ))
697
- elif hasattr (pin , ' value' ):
727
+ elif hasattr (pin , " value" ):
698
728
# If we don't have a PWM interface, all we can do is turn each color
699
729
# on / off. Assume a DigitalInOut (or compatible interface) and write
700
730
# 0 (on) to pin for any value greater than 0, or 1 (off) for 0:
0 commit comments