Skip to content

Commit 78bf6a6

Browse files
authored
Merge pull request #20 from fourstix/b_update_build
Updated examples reformatted with Black
2 parents 100d482 + 82455ed commit 78bf6a6

17 files changed

+119
-159
lines changed

examples/example10_turn_off_display.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
"""
2525
from time import sleep
2626
import board
27-
from sparkfun_serlcd import Sparkfun_SerLCD_I2C
27+
from sparkfun_serlcd import Sparkfun_SerLCD_I2C
2828

2929
i2c = board.I2C()
3030
serlcd = Sparkfun_SerLCD_I2C(i2c)
3131

32-
print('Example 10: Turn Off Display')
33-
print('Press Ctrl-C to end program.')
32+
print("Example 10: Turn Off Display")
33+
print("Press Ctrl-C to end program.")
3434

3535
serlcd.clear()
3636

examples/example11_text_direction.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@
2323
"""
2424
from time import sleep
2525
import board
26-
from sparkfun_serlcd import Sparkfun_SerLCD_I2C
26+
from sparkfun_serlcd import Sparkfun_SerLCD_I2C
2727

2828
i2c = board.I2C()
2929
serlcd = Sparkfun_SerLCD_I2C(i2c)
3030

31-
print('Example 11: Text Direction')
32-
print('Press Ctrl-C to end program.')
31+
print("Example 11: Text Direction")
32+
print("Press Ctrl-C to end program.")
3333

3434
serlcd.write("Hello, world!")
3535

36-
letter_a = ord('a')
37-
letter_j = ord('j')
38-
letter_q = ord('q')
39-
letter_z = ord('z')
36+
letter_a = ord("a")
37+
letter_j = ord("j")
38+
letter_q = ord("q")
39+
letter_z = ord("z")
4040

4141
# Start with letter 'a'
4242
letter = letter_a
@@ -64,7 +64,7 @@
6464
sleep(0.5)
6565

6666
serlcd.write(chr(letter))
67-
sleep(1) # wait a second
67+
sleep(1) # wait a second
6868
letter += 1
6969

7070
except KeyboardInterrupt:

examples/example12_display_input_text.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
"""
2424
from time import sleep
2525
import board
26-
from sparkfun_serlcd import Sparkfun_SerLCD_I2C
26+
from sparkfun_serlcd import Sparkfun_SerLCD_I2C
2727

2828
i2c = board.I2C()
2929
serlcd = Sparkfun_SerLCD_I2C(i2c)
3030

31-
print('Example 12: Display Input Text')
32-
print('Press Ctrl-C to end program.')
31+
print("Example 12: Display Input Text")
32+
print("Press Ctrl-C to end program.")
3333

3434

3535
try:

examples/example13_fast_backlight.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,62 +23,62 @@
2323
"""
2424
from time import sleep
2525
import board
26-
from sparkfun_serlcd import Sparkfun_SerLCD_I2C
26+
from sparkfun_serlcd import Sparkfun_SerLCD_I2C
2727

2828
i2c = board.I2C()
2929
serlcd = Sparkfun_SerLCD_I2C(i2c)
3030

31-
print('Example 13: Fast Backlight')
32-
print('Press Ctrl-C to end program.')
31+
print("Example 13: Fast Backlight")
32+
print("Press Ctrl-C to end program.")
3333

3434
try:
3535
while True:
36-
serlcd.set_fast_backlight_rgb(0, 0, 0) # black is off
36+
serlcd.set_fast_backlight_rgb(0, 0, 0) # black is off
3737
serlcd.clear()
3838
serlcd.write("Black (off)")
3939
sleep(3)
4040

41-
serlcd.set_fast_backlight_rgb(255, 0, 0) #bright red
41+
serlcd.set_fast_backlight_rgb(255, 0, 0) # bright red
4242
serlcd.clear()
4343
serlcd.write("Red")
4444
sleep(3)
4545

46-
serlcd.set_fast_backlight(0xFF8C00) #orange
46+
serlcd.set_fast_backlight(0xFF8C00) # orange
4747
serlcd.clear()
4848
serlcd.write("Orange")
4949
sleep(3)
5050

51-
serlcd.set_fast_backlight_rgb(255, 255, 0) #bright yellow
51+
serlcd.set_fast_backlight_rgb(255, 255, 0) # bright yellow
5252
serlcd.clear()
5353
serlcd.write("Yellow")
5454
sleep(3)
5555

56-
serlcd.set_fast_backlight_rgb(0, 255, 0) #bright green
56+
serlcd.set_fast_backlight_rgb(0, 255, 0) # bright green
5757
serlcd.clear()
5858
serlcd.write("Green")
5959
sleep(3)
6060

61-
serlcd.set_fast_backlight_rgb(0, 0, 255) #bright blue
61+
serlcd.set_fast_backlight_rgb(0, 0, 255) # bright blue
6262
serlcd.clear()
6363
serlcd.write("Blue")
6464
sleep(3)
6565

66-
serlcd.set_fast_backlight(0x4B0082) #indigo, a kind of dark purplish blue
66+
serlcd.set_fast_backlight(0x4B0082) # indigo, a kind of dark purplish blue
6767
serlcd.clear()
6868
serlcd.write("Indigo")
6969
sleep(3)
7070

71-
serlcd.set_fast_backlight(0xA020F0) #violet
71+
serlcd.set_fast_backlight(0xA020F0) # violet
7272
serlcd.clear()
7373
serlcd.write("Violet")
7474
sleep(3)
7575

76-
serlcd.set_fast_backlight(0x808080) #grey
76+
serlcd.set_fast_backlight(0x808080) # grey
7777
serlcd.clear()
7878
serlcd.write("Grey")
7979
sleep(3)
8080

81-
serlcd.set_fast_backlight_rgb(255, 255, 255) #bright white
81+
serlcd.set_fast_backlight_rgb(255, 255, 255) # bright white
8282
serlcd.clear()
8383
serlcd.write("White")
8484
sleep(3)

examples/example14_show_firmware_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
i2c = board.I2C()
2828
serlcd = Sparkfun_SerLCD_I2C(i2c)
2929

30-
print('Example 12: Show Firmware Version')
31-
print('Press Ctrl-C to end program.')
30+
print("Example 12: Show Firmware Version")
31+
print("Press Ctrl-C to end program.")
3232

3333
serlcd.clear()
3434

examples/example15_system_messages.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
i2c = board.I2C()
3434
serlcd = Sparkfun_SerLCD_I2C(i2c)
3535

36-
print('Press Ctrl-C to end program.')
36+
print("Press Ctrl-C to end program.")
3737

3838

3939
try:
@@ -46,7 +46,7 @@
4646
serlcd.command(187)
4747
serlcd.command(217)
4848
serlcd.write("Messages on")
49-
serlcd.set_cursor(0,1)
49+
serlcd.set_cursor(0, 1)
5050
serlcd.write("White")
5151
sleep(3)
5252

@@ -57,7 +57,7 @@
5757
serlcd.command(162)
5858
serlcd.command(202)
5959
serlcd.write("Messages off")
60-
serlcd.set_cursor(0,1)
60+
serlcd.set_cursor(0, 1)
6161
serlcd.write("Purple")
6262
sleep(2)
6363

examples/example16_splash_screen.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
i2c = board.I2C()
3131
serlcd = Sparkfun_SerLCD_I2C(i2c)
3232

33-
print('Example 16: Splash Screen')
33+
print("Example 16: Splash Screen")
3434

3535
# Set backlight to bright white
3636
serlcd.set_backlight_rgb(255, 255, 255)
@@ -47,12 +47,12 @@
4747
serlcd.save_splash_screen()
4848

4949
# Uncomment this line to set splash screen back to default
50-
#serlcd.default_splash_screen()
50+
# serlcd.default_splash_screen()
5151

5252
# This will cause the splash to be displayed at power on
5353
serlcd.splash_screen(True)
5454

5555
# Uncomment the next line to supress any splash display at power on
56-
#serlcd.splash_screen(False)
56+
# serlcd.splash_screen(False)
5757

58-
print('Power off dislpay. Then Power back on to see Splash Screen changes.')
58+
print("Power off dislpay. Then Power back on to see Splash Screen changes.")

examples/example1_hello_world.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,42 +31,42 @@
3131
serlcd = Sparkfun_SerLCD_I2C(i2c)
3232

3333
# Enable SPI communication
34-
#import digitalio
35-
#from sparkfun_serlcd import Sparkfun_SerLCD_SPI
36-
#spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
34+
# import digitalio
35+
# from sparkfun_serlcd import Sparkfun_SerLCD_SPI
36+
# spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
3737
#
3838
# Set up chip select, CE0 or D8 is labeled CS on Sparkfun Pi Hat
39-
#cs = digitalio.DigitalInOut(board.CE0)
40-
#cs.direction = digitalio.Direction.OUTPUT
39+
# cs = digitalio.DigitalInOut(board.CE0)
40+
# cs.direction = digitalio.Direction.OUTPUT
4141
#
42-
#serlcd = Sparkfun_SerLCD_SPI(spi, cs)
42+
# serlcd = Sparkfun_SerLCD_SPI(spi, cs)
4343

4444
# Enable UART Serial communication
4545
# SerLCD is connected to the RPi via a USB to TTL 3.3v Serial Cable:
4646
# https://www.sparkfun.com/products/12977
4747
# https://www.adafruit.com/product/954
4848

49-
#import serial
50-
#from sparkfun_serlcd import Sparkfun_SerLCD_UART
51-
#usb0 = serial.Serial(
49+
# import serial
50+
# from sparkfun_serlcd import Sparkfun_SerLCD_UART
51+
# usb0 = serial.Serial(
5252
# port='/dev/ttyUSB0',
5353
# baudrate = 9600,
5454
# parity=serial.PARITY_NONE,
5555
# stopbits=serial.STOPBITS_ONE,
5656
# bytesize=serial.EIGHTBITS,
5757
# timeout=1)
5858
#
59-
#serlcd = Sparkfun_SerLCD_UART(usb0)
59+
# serlcd = Sparkfun_SerLCD_UART(usb0)
6060

61-
print('Example 1: Hello World')
62-
print('Press Ctrl-C to end program.')
61+
print("Example 1: Hello World")
62+
print("Press Ctrl-C to end program.")
6363

6464
serlcd.write("Hello, world!")
6565

6666
i = 0
6767
try:
6868
while True:
69-
serlcd.set_cursor(0,1)
69+
serlcd.set_cursor(0, 1)
7070
serlcd.write(i)
7171
i += 1
7272
sleep(1)

examples/example2_backlight.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"""
2626
from time import sleep
2727
import board
28-
from sparkfun_serlcd import Sparkfun_SerLCD_I2C
28+
from sparkfun_serlcd import Sparkfun_SerLCD_I2C
2929

3030
i2c = board.I2C()
3131
serlcd = Sparkfun_SerLCD_I2C(i2c)
@@ -35,52 +35,52 @@
3535

3636
try:
3737
while True:
38-
serlcd.set_backlight_rgb(0, 0, 0) # black is off
38+
serlcd.set_backlight_rgb(0, 0, 0) # black is off
3939
serlcd.clear()
4040
serlcd.write("Black (off)")
4141
sleep(3)
4242

43-
serlcd.set_backlight_rgb(255, 0, 0) #bright red
43+
serlcd.set_backlight_rgb(255, 0, 0) # bright red
4444
serlcd.clear()
4545
serlcd.write("Red")
4646
sleep(3)
4747

48-
serlcd.set_backlight(0xFF8C00) #orange
48+
serlcd.set_backlight(0xFF8C00) # orange
4949
serlcd.clear()
5050
serlcd.write("Orange")
5151
sleep(3)
5252

53-
serlcd.set_backlight_rgb(255, 255, 0) #bright yellow
53+
serlcd.set_backlight_rgb(255, 255, 0) # bright yellow
5454
serlcd.clear()
5555
serlcd.write("Yellow")
5656
sleep(3)
5757

58-
serlcd.set_backlight_rgb(0, 255, 0) #bright green
58+
serlcd.set_backlight_rgb(0, 255, 0) # bright green
5959
serlcd.clear()
6060
serlcd.write("Green")
6161
sleep(3)
6262

63-
serlcd.set_backlight_rgb(0, 0, 255) #bright blue
63+
serlcd.set_backlight_rgb(0, 0, 255) # bright blue
6464
serlcd.clear()
6565
serlcd.write("Blue")
6666
sleep(3)
6767

68-
serlcd.set_backlight(0x4B0082) #indigo, a kind of dark purplish blue
68+
serlcd.set_backlight(0x4B0082) # indigo, a kind of dark purplish blue
6969
serlcd.clear()
7070
serlcd.write("Indigo")
7171
sleep(3)
7272

73-
serlcd.set_backlight(0xA020F0) #violet
73+
serlcd.set_backlight(0xA020F0) # violet
7474
serlcd.clear()
7575
serlcd.write("Violet")
7676
sleep(3)
7777

78-
serlcd.set_backlight(0x808080) #grey
78+
serlcd.set_backlight(0x808080) # grey
7979
serlcd.clear()
8080
serlcd.write("Grey")
8181
sleep(3)
8282

83-
serlcd.set_backlight_rgb(255, 255, 255) #bright white
83+
serlcd.set_backlight_rgb(255, 255, 255) # bright white
8484
serlcd.clear()
8585
serlcd.write("White")
8686
sleep(3)

examples/example3_cursor_position.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import time
2525
import random
2626
import board
27-
from sparkfun_serlcd import Sparkfun_SerLCD_I2C
27+
from sparkfun_serlcd import Sparkfun_SerLCD_I2C
2828

2929
i2c = board.I2C()
3030
serlcd = Sparkfun_SerLCD_I2C(i2c)
@@ -37,29 +37,29 @@
3737
# num_rows = 4
3838

3939
# Starting character value
40-
letter = ord('a')
40+
letter = ord("a")
4141

42-
print('Example 3: Cursor Position')
43-
print('Press Ctrl-C to end program.')
42+
print("Example 3: Cursor Position")
43+
print("Press Ctrl-C to end program.")
4444

4545
# Clear the display before writing random letters
4646
serlcd.clear()
4747

4848
try:
4949
while True:
5050
# pick a random column 0 to 15 (or 19)
51-
col = random.randint(0, num_cols-1)
51+
col = random.randint(0, num_cols - 1)
5252
# pick a random row 0 to 1 (or 3)
53-
row = random.randint(0, num_rows-1)
53+
row = random.randint(0, num_rows - 1)
5454

5555
# Move to random location and write the next letter
56-
serlcd.set_cursor(col,row)
56+
serlcd.set_cursor(col, row)
5757
serlcd.write(chr(letter))
5858

5959
# Get the next letter wrapping around after z
6060
letter += 1
61-
if letter > ord('z'):
62-
letter = ord('a')
61+
if letter > ord("z"):
62+
letter = ord("a")
6363

6464
time.sleep(0.5)
6565

0 commit comments

Comments
 (0)