Skip to content

Commit 20f9448

Browse files
committed
Fixed None string issue.
1 parent 58aec64 commit 20f9448

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

adafruit_pybadger.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,12 @@ def brightness(self):
213213
def brightness(self, value):
214214
self.display.brightness = value
215215

216-
# pylint: disable=too-many-arguments,too-many-locals
217-
def show_business_card(self, image_name=None, email_string=None,
216+
def show_business_card(self, *, image_name=None, email_string=None,
218217
email_scale=1, email_font=terminalio.FONT, dwell=20):
219218
"""Display a bitmap image and a text string, such as a personal image and email address.
220219
221-
:param str image_name: The name of the bitmap image including .bmp, e.g. ``"Blinka.bmp"``.
220+
:param str image_name: REQUIRED. The name of the bitmap image including .bmp, e.g.
221+
``"Blinka.bmp"``.
222222
:param str email_string: A string to display along the bottom of the display, e.g.
223223
``"blinka@adafruit.com"``.
224224
:param int email_scale: The scale of ``email_string``. Defaults to 1.
@@ -233,14 +233,15 @@ def show_business_card(self, image_name=None, email_string=None,
233233
face_image = displayio.TileGrid(on_disk_bitmap, pixel_shader=displayio.ColorConverter())
234234
business_card_splash.append(face_image)
235235
self.display.wait_for_frame()
236-
email_group = displayio.Group(scale=email_scale)
237-
email_label = Label(email_font, text=email_string)
238-
(_, _, width, height) = email_label.bounding_box
239-
email_label.x = ((self.display.width // (2 * email_scale)) - width // 2)
240-
email_label.y = int(height // (0.13 * email_scale))
241-
email_label.color = 0xFFFFFF
242-
email_group.append(email_label)
243-
business_card_splash.append(email_group)
236+
if email_string is not None and len(email_string) > 0:
237+
email_group = displayio.Group(scale=email_scale)
238+
email_label = Label(email_font, text=email_string)
239+
(_, _, width, height) = email_label.bounding_box
240+
email_label.x = ((self.display.width // (2 * email_scale)) - width // 2)
241+
email_label.y = int(height // (0.13 * email_scale))
242+
email_label.color = 0xFFFFFF
243+
email_group.append(email_label)
244+
business_card_splash.append(email_group)
244245
time.sleep(dwell)
245246

246247
# pylint: disable=too-many-locals
@@ -339,7 +340,7 @@ def bitmap_qr(matrix):
339340
bitmap[x + border_pixels, y + border_pixels] = 0
340341
return bitmap
341342

342-
def show_qr_code(self, data="https://circuitpython.org", dwell=20):
343+
def show_qr_code(self, *, data="https://circuitpython.org", dwell=20):
343344
"""Generate a QR code and display it for ``dwell`` seconds.
344345
345346
:param string data: A string of data for the QR code

0 commit comments

Comments
 (0)