Skip to content

Commit

Permalink
add bw handling here as well
Browse files Browse the repository at this point in the history
  • Loading branch information
bdamokos committed Dec 7, 2024
1 parent 6175543 commit c2b8c21
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
15 changes: 12 additions & 3 deletions basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,19 @@ def update_display(epd, weather_data, bus_data, error_message=None, stop_name=No

def draw_weather_display(epd, weather_data, last_weather_data=None):
"""Draw a weather-focused display when no bus times are available"""
# Handle different color definitions
BLACK = epd.BLACK
WHITE = epd.WHITE
RED = getattr(epd, 'RED', BLACK) # Fall back to BLACK if RED not available
YELLOW = getattr(epd, 'YELLOW', BLACK) # Fall back to BLACK if YELLOW not available

# Create a new image with white background
Himage = Image.new('RGB', (epd.height, epd.width), epd.WHITE) # 250x120 width x height
if epd.is_bw_display:
Himage = Image.new('1', (epd.height, epd.width), 1) # 1 is white in 1-bit mode
else:
Himage = Image.new('RGB', (epd.height, epd.width), WHITE)

# 250x120 width x height
draw = ImageDraw.Draw(Himage)

try:
Expand Down Expand Up @@ -631,8 +642,6 @@ def draw_weather_display(epd, weather_data, last_weather_data=None):
Himage = Himage.rotate(90, expand=True)

# Display the image
epd.init()
epd.Clear()
buffer = epd.getbuffer(Himage)
epd.display(buffer)

Expand Down
14 changes: 12 additions & 2 deletions wifi_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,18 @@ def main():

def show_no_wifi_display(epd):
"""Display a Wi-Fi QR code and no Wi-Fi symbol on the screen."""
Himage = Image.new('RGB', (epd.height, epd.width), epd.WHITE)
BLACK = epd.BLACK
WHITE = epd.WHITE
RED = getattr(epd, 'RED', BLACK) # Fall back to BLACK if RED not available
YELLOW = getattr(epd, 'YELLOW', BLACK) # Fall back to BLACK if YELLOW not available

# Create a new image with white background
if epd.is_bw_display:
Himage = Image.new('1', (epd.height, epd.width), 1) # 1 is white in 1-bit mode
else:
Himage = Image.new('RGB', (epd.height, epd.width), WHITE)


draw = ImageDraw.Draw(Himage)

try:
Expand Down Expand Up @@ -303,7 +314,6 @@ def show_no_wifi_display(epd):
Himage = Himage.rotate(90, expand=True)

# Display the image
epd.init()
buffer = epd.getbuffer(Himage)
epd.display(buffer)

Expand Down

0 comments on commit c2b8c21

Please sign in to comment.