Skip to content

Commit 3cd02e1

Browse files
committed
Throw the blank screen into its own function.
1 parent 3944eaf commit 3cd02e1

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

Pi_Hole_Ad_Blocker/stats.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
# Create the I2C interface.
4949
i2c = busio.I2C(SCL, SDA)
5050

51+
# Blanks the Pi OLED display.
52+
def blank_screen(display):
53+
display.fill(0)
54+
display.show()
55+
5156
# Create the SSD1306 OLED class.
5257
# The first two parameters are the pixel width and pixel height. Change these
5358
# to the right size for your display!
@@ -59,8 +64,7 @@
5964
DISPLAY_OFF = 50 # off time in seconds
6065

6166
# Clear display.
62-
disp.fill(0)
63-
disp.show()
67+
blank_screen(disp)
6468

6569
# Create blank image for drawing.
6670
# Make sure to create image with mode '1' for 1-bit color.
@@ -132,6 +136,6 @@
132136
disp.image(image)
133137
disp.show()
134138
time.sleep(DISPLAY_ON)
135-
disp.fill(0)
136-
disp.show()
139+
# Clear display.
140+
blank_screen(disp)
137141
time.sleep(DISPLAY_OFF)

0 commit comments

Comments
 (0)