Skip to content

Commit

Permalink
Drawing rectangle everytime to fix a bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarimbinwaseem committed Feb 13, 2024
1 parent ed2d73b commit 65f6b52
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
25 changes: 14 additions & 11 deletions Utils/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,25 @@ def __init__(self):
self.RST = None

# Note the following are only used with SPI:
self.DC = 23
self.SPI_PORT = 0
self.SPI_DEVICE = 0
self.DC: int = 23
self.SPI_PORT: int = 0
self.SPI_DEVICE: int = 0
self.disp = Adafruit_SSD1306.SSD1306_128_64(rst=None)
self.X = 0
self.X: int = 0

self.PADDING = None
self.TOP = None
self.BOTTOM = None
self.PADDING: int = None
self.TOP: int = None
self.BOTTOM: int = None
self.IMAGE = None
self.DRAW = None

self.WIDTH: int = None
self.HEIGHT: int = None

try:
self.font = ImageFont.truetype("Fonts/TheImpostor.ttf", 20)
self.FONT = ImageFont.truetype("Fonts/TheImpostor.ttf", 20)
except FileNotFoundError:
self.font = ImageFont.load_default()
self.FONT = ImageFont.load_default()

def get_disp_dimensions(self) -> tuple:
"""Returns connected display's dimension"""
Expand Down Expand Up @@ -94,9 +97,9 @@ def create_image(self, current_time, next_salah_time) -> None:
"""Creating image of timings to show."""


self.DRAW.text((self.X, self.TOP), current_time, font=self.font, fill=255)
self.DRAW.text((self.X, self.TOP), current_time, font=self.FONT, fill=255)

self.DRAW.text((self.X, self.TOP + 28), next_salah_time, font=self.font, fill=255)
self.DRAW.text((self.X, self.TOP + 28), next_salah_time, font=self.FONT, fill=255)

def display_image(self) -> None:
"""Display the created image."""
Expand Down
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def display_loop(*args):

for _ in range(13):
current_time, next_salah_time = stime.get_all_times()
display.draw_rectangle()
display.create_image(current_time, next_salah_time)

# Display image.
Expand Down

0 comments on commit 65f6b52

Please sign in to comment.