From 7f84e1a8167ec398a9a2e036f6fe3be456edad6c Mon Sep 17 00:00:00 2001 From: bdamokos <163609735+bdamokos@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:23:18 +0100 Subject: [PATCH] do not show qr code if one is not set --- weather/display.py | 28 +++++++--------------------- weather/icons/Brand raspberrypi.png | Bin 1626 -> 0 bytes 2 files changed, 7 insertions(+), 21 deletions(-) delete mode 100644 weather/icons/Brand raspberrypi.png diff --git a/weather/display.py b/weather/display.py index ef88cf7..5f98401 100644 --- a/weather/display.py +++ b/weather/display.py @@ -286,7 +286,11 @@ def get_weather_data(self): # Constants MARGIN = 5 -QR_SIZE = 52 # QR code size in pixels +qr_code_address = os.getenv("weather_mode_qr_code_address") +if qr_code_address: + QR_SIZE = 52 # QR code size in pixels +else: + QR_SIZE = 0 ICON_PADDING = 2 # Padding around icons def draw_weather_display(epd, weather_data, last_weather_data=None, set_base_image=False): @@ -581,7 +585,7 @@ def draw_weather_display(epd, weather_data, last_weather_data=None, set_base_ima forecast_text, font=font_medium, fill=BLACK) # Generate and draw QR code (larger size) or Raspberry Pi logo - qr_code_address = os.getenv("weather_mode_qr_code_address") + if qr_code_address: qr = qrcode.QRCode(version=1, box_size=2, border=1) qr.add_data(qr_code_address) @@ -594,25 +598,7 @@ def draw_weather_display(epd, weather_data, last_weather_data=None, set_base_ima qr_x = Himage.width - QR_SIZE - MARGIN qr_y = MARGIN Himage.paste(qr_img, (qr_x, qr_y)) - else: - # Load and display Raspberry Pi logo instead - try: - logo_path = Path(__file__).parent / "icons" / "Brand raspberrypi.png" - logo_img = Image.open(logo_path) - - # Calculate position to center the 46x46 logo in the QR code space - logo_x = Himage.width - QR_SIZE - MARGIN + (QR_SIZE - 46) // 2 - logo_y = MARGIN + (QR_SIZE - 46) // 2 - - # Convert logo to match display mode if needed - if epd.is_bw_display: - logo_img = logo_img.convert('1') - else: - logo_img = logo_img.convert('RGB') - - Himage.paste(logo_img, (logo_x, logo_y)) - except Exception as e: - logger.error(f"Error loading Raspberry Pi logo: {e}") + # Draw time under QR code current_time = datetime.now().strftime("%H:%M") diff --git a/weather/icons/Brand raspberrypi.png b/weather/icons/Brand raspberrypi.png deleted file mode 100644 index 85facdb076192f9d936febfb4696cb029e47dc61..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1626 zcmV-g2BrClP)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91E}#Pd1ONa40RR91E&u=k08)}91ONa9#7RU!RA>e5m}`htRTzf74Qi%# z!!8r1Q(CEA)fxzGtfUmmF6a+SXl9uHBsB%mjVu)_6~)3NFz7-NX^=%!bk)qJGRR8H zE>7c^m|~@wW0_jdlY7DPaQ2zQxX;v&dEuG0*0?ih!F&kg|F#`ih-5i(a_JWholz{J+VYIq%%!ne=@%}@>T zgjm!0FT380g%0yl8;%q!rq_-m(_Zdu1Xrw$2iqY*1GL|t5s$0R{gPng2M2h#}*!M$7I4&nW$gIH(5?uUpQ&u5JLIF-GR{wcZR1ASCw&^>T>iz3kOzB4Uz9L9DJcW`O<6!5hfB zF*23+^>zr!Sgr)OOFmtLF^nCZZ$M&O9F6mU8pBwbXb4_(_!>+C6FLCrL7MzQZlRsf zC2bJ)Ht$XTTlFpbE;ZV9di(f1dse zDkCqA)R#om{;8I@y0Bc-gt z9(+$t857JV7*^5sWPkQGD`A;@y(yQ#GV9Y7qtMQ%fwRm05n9wx21MpHX zP=^5r@PrBS;hObQ8+TMj;5NkM%ZQu{{8e9eL^L^mV_lBS$R2o5F9>}ml(-NDp z+bmzfAHiLThi51a6mT^jfw^F!?oB@d;sjmxTftk#E6;0GpWzGyUsqxCzTcSiANK2i z431pxg(Fov;ORX7l> z4P258Fv(cHnEXIe{SFod|N5r%T-*d6*jOHD6=EH1W$<@BJ|0i;^EP%9@o*KAd%8Yl zz-`!#k+~kkV^fOPI_xg zHawlW-|6l4ufMy$TmYSrnm$dPqE!@joPj&3pWW=s6GQl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