45
45
#==================================================================================
46
46
#
47
47
# This is mostly a port of existing Arduino functionaly, so pylint is sad.
48
- # The goal is to keep the public interface pthonic , but internal is internal
48
+ # The goal is to keep the public interface pythonic , but internal is internal.
49
49
#
50
50
# pylint: disable=line-too-long, too-many-public-methods, invalid-name
51
51
#
60
60
[SparkFun 20x4 SerLCD - RGB Backlight (Qwiic)](https://www.sparkfun.com/products/16398)
61
61
62
62
This python package enables the user to control the SerLCDs via I2C.
63
- It is intended to be used by simply plugging in a qwiic cable for power and I2C communicaiton .
63
+ It is intended to be used by simply plugging in a qwiic cable for power and I2C communication .
64
64
65
65
This package can be used in conjunction with the overall [SparkFun qwiic Python Package](https://github.com/sparkfun/Qwiic_Py)
66
66
82
82
# The name of this device
83
83
_DEFAULT_NAME = "SparkFun Qwiic SerLCD"
84
84
85
- # Some devices have multiple availabel addresses - this is a list of these addresses.
85
+ # Some devices have multiple available addresses - this is a list of these addresses.
86
86
# NOTE: The first address in this list is considered the default I2C address for the
87
87
# device.
88
88
_AVAILABLE_I2C_ADDRESS = [0x72 ] # default address, note it can be changed via software commands
@@ -143,10 +143,10 @@ def map(x, in_min, in_max, out_min, out_max):
143
143
:param in_max: maximum of input range
144
144
:param out_min: minimum of output range
145
145
:param out_max: maximum of output range
146
-
146
+
147
147
:return: The value scaled to the new range
148
148
:rtype: int
149
- """
149
+ """
150
150
return int ((x - in_min ) * (out_max - out_min ) / (in_max - in_min ) + out_min )
151
151
152
152
# define the class that encapsulates the device being created. All information associated with this
@@ -234,8 +234,8 @@ def print(self, string):
234
234
Print a string of characters to the LCD
235
235
236
236
:param string: The string you would like to print. Aka ASCII characters. example: "Hello"
237
-
238
- :return: Returns true if the I2C writes were successful, otherwise False.
237
+
238
+ :return: Returns True if the I2C writes were successful, otherwise False.
239
239
:rtype: bool
240
240
241
241
"""
@@ -253,7 +253,7 @@ def clearScreen(self):
253
253
"""
254
254
Sends the command to clear the screen
255
255
256
- :return: Returns true if the I2C write was successful, otherwise False.
256
+ :return: Returns True if the I2C write was successful, otherwise False.
257
257
:rtype: bool
258
258
259
259
"""
@@ -270,10 +270,10 @@ def clearScreen(self):
270
270
def home (self ):
271
271
"""
272
272
Send the home command to the display. This returns the cursor
273
- to return to the beginning of the display, without clearing
273
+ to the beginning of the display, without clearing
274
274
the display.
275
275
276
- :return: Returns true if the I2C write was successful, otherwise False.
276
+ :return: Returns True if the I2C write was successful, otherwise False.
277
277
:rtype: bool
278
278
279
279
"""
@@ -291,13 +291,13 @@ def setCursor(self, col, row):
291
291
292
292
:param col: The column postion (0-19)
293
293
:param row: The row postion (0-3)
294
-
295
- :return: Returns true if the I2C write was successful, otherwise False.
294
+
295
+ :return: Returns True if the I2C write was successful, otherwise False.
296
296
:rtype: bool
297
297
298
- """
298
+ """
299
299
row_offsets = [0x00 , 0x40 , 0x14 , 0x54 ]
300
-
300
+
301
301
# kepp variables in bounds
302
302
row = max (0 , row ) # row cannot be less than 0
303
303
row = min (row , (MAX_ROWS - 1 )) # row cannot be greater than max rows
@@ -318,8 +318,8 @@ def setContrast(self, contrast):
318
318
Set the contrast of the LCD screen (0-255)
319
319
320
320
:param contrast: The new contrast value (0-255)
321
-
322
- :return: Returns true if the I2C write was successful, otherwise False.
321
+
322
+ :return: Returns True if the I2C write was successful, otherwise False.
323
323
:rtype: bool
324
324
325
325
"""
@@ -332,8 +332,8 @@ def setContrast(self, contrast):
332
332
# so we need our "block of bytes" to include
333
333
# CONTRAST_COMMAND and contrast value
334
334
335
- block = [CONTRAST_COMMAND , contrast ]
336
-
335
+ block = [CONTRAST_COMMAND , contrast ]
336
+
337
337
# send the complete bytes (address, settings command , contrast command, contrast value)
338
338
result = self ._i2c .writeBlock (self .address , SETTING_COMMAND , block )
339
339
time .sleep (0.01 )
@@ -351,8 +351,8 @@ def setBacklight(self, r, g, b):
351
351
:param red: The new red brightness value (0-255)
352
352
:param green: The new green brightness value (0-255)
353
353
:param blue: The new blue brightness value (0-255)
354
-
355
- :return: Returns true if the I2C write was successful, otherwise False.
354
+
355
+ :return: Returns True if the I2C write was successful, otherwise False.
356
356
:rtype: bool
357
357
358
358
"""
@@ -384,12 +384,12 @@ def setBacklight(self, r, g, b):
384
384
self ._displayControl |= LCD_DISPLAYON
385
385
block [8 ] = SPECIAL_COMMAND
386
386
block [9 ] = (LCD_DISPLAYCONTROL | self ._displayControl )
387
-
387
+
388
388
# send the complete bytes (address, settings command , contrast command, contrast value)
389
389
result = self ._i2c .writeBlock (self .address , SETTING_COMMAND , block )
390
390
time .sleep (0.05 )
391
391
return result
392
-
392
+
393
393
# ----------------------------------
394
394
# specialCommand()
395
395
#
@@ -402,8 +402,8 @@ def specialCommand(self, command, count = 1):
402
402
403
403
:param command: Command to send (a single byte)
404
404
:param count: Number of times to send the command (if ommited, then default is once)
405
-
406
- :return: Returns true if the I2C write was successful, otherwise False.
405
+
406
+ :return: Returns True if the I2C write was successful, otherwise False.
407
407
:rtype: bool
408
408
409
409
"""
@@ -412,7 +412,7 @@ def specialCommand(self, command, count = 1):
412
412
result = self ._i2c .writeByte (self .address , SPECIAL_COMMAND , command )
413
413
time .sleep (0.05 )
414
414
return result
415
-
415
+
416
416
# ----------------------------------
417
417
# command()
418
418
#
@@ -425,7 +425,7 @@ def command(self, command):
425
425
426
426
:param command: Command to send (a single byte)
427
427
428
- :return: Returns true if the I2C write was successful, otherwise False.
428
+ :return: Returns True if the I2C write was successful, otherwise False.
429
429
:rtype: bool
430
430
431
431
"""
@@ -443,7 +443,7 @@ def moveCursorLeft(self, count = 1):
443
443
444
444
:param count: Number of character spaces you'd like to move
445
445
446
- :return: Returns true if the I2C write was successful, otherwise False.
446
+ :return: Returns True if the I2C write was successful, otherwise False.
447
447
:rtype: bool
448
448
449
449
"""
@@ -459,7 +459,7 @@ def moveCursorRight(self, count = 1):
459
459
460
460
:param count: Number of character spaces you'd like to move
461
461
462
- :return: Returns true if the I2C write was successful, otherwise False.
462
+ :return: Returns True if the I2C write was successful, otherwise False.
463
463
:rtype: bool
464
464
465
465
"""
@@ -473,7 +473,7 @@ def cursor(self):
473
473
"""
474
474
Turn the underline cursor on.
475
475
476
- :return: Returns true if the I2C write was successful, otherwise False.
476
+ :return: Returns True if the I2C write was successful, otherwise False.
477
477
:rtype: bool
478
478
479
479
"""
@@ -488,7 +488,7 @@ def noCursor(self):
488
488
"""
489
489
Turn the underline cursor off.
490
490
491
- :return: Returns true if the I2C write was successful, otherwise False.
491
+ :return: Returns True if the I2C write was successful, otherwise False.
492
492
:rtype: bool
493
493
494
494
"""
@@ -503,7 +503,7 @@ def blink(self):
503
503
"""
504
504
Turn the blink cursor on.
505
505
506
- :return: Returns true if the I2C write was successful, otherwise False.
506
+ :return: Returns True if the I2C write was successful, otherwise False.
507
507
:rtype: bool
508
508
509
509
"""
@@ -518,7 +518,7 @@ def noBlink(self):
518
518
"""
519
519
Turn the blink cursor off.
520
520
521
- :return: Returns true if the I2C write was successful, otherwise False.
521
+ :return: Returns True if the I2C write was successful, otherwise False.
522
522
:rtype: bool
523
523
524
524
"""
@@ -535,7 +535,7 @@ def scrollDisplayLeft(self, count = 1):
535
535
536
536
:param count: Number of character spaces you'd like to scroll
537
537
538
- :return: Returns true if the I2C write was successful, otherwise False.
538
+ :return: Returns True if the I2C write was successful, otherwise False.
539
539
:rtype: bool
540
540
541
541
"""
@@ -551,7 +551,7 @@ def scrollDisplayRight(self, count = 1):
551
551
552
552
:param count: Number of character spaces you'd like to scroll
553
553
554
- :return: Returns true if the I2C write was successful, otherwise False.
554
+ :return: Returns True if the I2C write was successful, otherwise False.
555
555
:rtype: bool
556
556
557
557
"""
@@ -565,7 +565,7 @@ def autoscroll(self):
565
565
"""
566
566
Turn autoscrolling on. This will right-justify text from the cursor.
567
567
568
- :return: Returns true if the I2C write was successful, otherwise False.
568
+ :return: Returns True if the I2C write was successful, otherwise False.
569
569
:rtype: bool
570
570
571
571
"""
@@ -580,7 +580,7 @@ def noAutoscroll(self):
580
580
"""
581
581
Turn autoscrolling off.
582
582
583
- :return: Returns true if the I2C write was successful, otherwise False.
583
+ :return: Returns True if the I2C write was successful, otherwise False.
584
584
:rtype: bool
585
585
586
586
"""
@@ -596,7 +596,7 @@ def leftToRight(self):
596
596
"""
597
597
Set the text to flow from left to right.
598
598
599
- :return: Returns true if the I2C write was successful, otherwise False.
599
+ :return: Returns True if the I2C write was successful, otherwise False.
600
600
:rtype: bool
601
601
602
602
"""
@@ -611,7 +611,7 @@ def rightToLeft(self):
611
611
"""
612
612
Set the text to flow from right to left
613
613
614
- :return: Returns true if the I2C write was successful, otherwise False.
614
+ :return: Returns True if the I2C write was successful, otherwise False.
615
615
:rtype: bool
616
616
617
617
"""
@@ -630,7 +630,7 @@ def createChar(self, location, charmap):
630
630
:param location: character number 0 to 7
631
631
:param charmap: byte array for character
632
632
633
- :return: Returns true if the I2C write was successful, otherwise False.
633
+ :return: Returns True if the I2C write was successful, otherwise False.
634
634
:rtype: bool
635
635
636
636
"""
@@ -661,7 +661,7 @@ def writeChar(self, location):
661
661
Write a customer character to the display
662
662
:param location: character number 0 to 7
663
663
664
- :return: Returns true if the I2C write was successful, otherwise False.
664
+ :return: Returns True if the I2C write was successful, otherwise False.
665
665
:rtype: bool
666
666
667
667
"""
@@ -680,7 +680,7 @@ def display(self):
680
680
"""
681
681
Turn the display on quickly.
682
682
683
- :return: Returns true if the I2C write was successful, otherwise False.
683
+ :return: Returns True if the I2C write was successful, otherwise False.
684
684
:rtype: bool
685
685
686
686
"""
@@ -695,7 +695,7 @@ def noDisplay(self):
695
695
"""
696
696
Turn the display off quickly.
697
697
698
- :return: Returns true if the I2C write was successful, otherwise False.
698
+ :return: Returns True if the I2C write was successful, otherwise False.
699
699
:rtype: bool
700
700
701
701
"""
@@ -716,7 +716,7 @@ def setFastBacklight(self, r, g, b):
716
716
:param g: green backlight value 0-255
717
717
:param b: blue backlight value 0-255
718
718
719
- :return: Returns true if the I2C write was successful, otherwise False.
719
+ :return: Returns True if the I2C write was successful, otherwise False.
720
720
:rtype: bool
721
721
722
722
"""
@@ -744,7 +744,7 @@ def enableSystemMessages(self):
744
744
"""
745
745
Enable system messages
746
746
747
- :return: Returns true if the I2C write was successful, otherwise False.
747
+ :return: Returns True if the I2C write was successful, otherwise False.
748
748
:rtype: bool
749
749
750
750
"""
@@ -763,7 +763,7 @@ def disableSystemMessages(self):
763
763
"""
764
764
Disable system messages
765
765
766
- :return: Returns true if the I2C write was successful, otherwise False.
766
+ :return: Returns True if the I2C write was successful, otherwise False.
767
767
:rtype: bool
768
768
769
769
"""
@@ -781,7 +781,7 @@ def enableSplash(self):
781
781
"""
782
782
Enable splash screen at power on
783
783
784
- :return: Returns true if the I2C write was successful, otherwise False.
784
+ :return: Returns True if the I2C write was successful, otherwise False.
785
785
:rtype: bool
786
786
787
787
"""
@@ -799,7 +799,7 @@ def disableSplash(self):
799
799
"""
800
800
Disable splash screen at power on
801
801
802
- :return: Returns true if the I2C write was successful, otherwise False.
802
+ :return: Returns True if the I2C write was successful, otherwise False.
803
803
:rtype: bool
804
804
805
805
"""
@@ -821,7 +821,7 @@ def saveSplash(self):
821
821
Saves whatever is currently being displayed into EEPROM
822
822
This will be displayed at next power on as the splash screen
823
823
824
- :return: Returns true if the I2C write was successful, otherwise False.
824
+ :return: Returns True if the I2C write was successful, otherwise False.
825
825
:rtype: bool
826
826
827
827
"""
@@ -848,7 +848,7 @@ def setAddress(self, new_addr):
848
848
to unbrick the display.
849
849
:param new_addr: new i2c address
850
850
851
- :return: Returns true if the I2C write was successful, otherwise False.
851
+ :return: Returns True if the I2C write was successful, otherwise False.
852
852
:rtype: bool
853
853
854
854
"""
0 commit comments