@@ -213,12 +213,31 @@ def brightness(self):
213213 def brightness (self , value ):
214214 self .display .brightness = value
215215
216- def show_business_card (self , image_name = None , dwell = 20 ):
216+ # pylint: disable=too-many-locals
217+ def show_business_card (self , * , image_name = None , name_string = None , name_scale = 1 ,
218+ name_font = terminalio .FONT , email_string_one = None ,
219+ email_scale_one = 1 , email_font_one = terminalio .FONT ,
220+ email_string_two = None , email_scale_two = 1 ,
221+ email_font_two = terminalio .FONT ):
217222 """Display a bitmap image and a text string, such as a personal image and email address.
218- CURRENTLY ONLY DISPLAYS BITMAP IMAGE. Text string to be added.
219223
220- :param str image_name: The name of the bitmap image including .bmp, e.g. ``"Blinka.bmp"``.
221- :param int dwell: The amount of time in seconds to display the business card.
224+ :param str image_name: REQUIRED. The name of the bitmap image including .bmp, e.g.
225+ ``"Blinka.bmp"``.
226+ :param str name_string: A name string to display along the bottom of the display, e.g.
227+ ``"Blinka"``.
228+ :param int name_scale: The scale of ``name_string``. Defaults to 1.
229+ :param name_font: The font for the name string. Defaults to ``terminalio.FONT``.
230+ :param str email_string_one: A string to display along the bottom of the display, e.g.
231+ 232+ :param int email_scale_one: The scale of ``email_string_one``. Defaults to 1.
233+ :param email_font_one: The font for the first email string. Defaults to ``terminalio.FONT``.
234+ :param str email_string_two: A second string to display along the bottom of the display.
235+ Use if your email address is longer than one line or to add
236+ more space between the name and email address,
237+ e.g. (blinka@) ``"adafruit.com"``.
238+ :param int email_scale_two: The scale of ``email_string_two``. Defaults to 1.
239+ :param email_font_two: The font for the second email string. Defaults to
240+ ``terminalio.FONT``.
222241
223242 """
224243 business_card_splash = displayio .Group (max_size = 30 )
@@ -227,9 +246,36 @@ def show_business_card(self, image_name=None, dwell=20):
227246 on_disk_bitmap = displayio .OnDiskBitmap (file_name )
228247 face_image = displayio .TileGrid (on_disk_bitmap , pixel_shader = displayio .ColorConverter ())
229248 business_card_splash .append (face_image )
230- # Wait for the image to load.
231249 self .display .wait_for_frame ()
232- time .sleep (dwell )
250+ if name_string :
251+ name_group = displayio .Group (scale = name_scale )
252+ name_label = Label (name_font , text = name_string )
253+ (_ , _ , width , height ) = name_label .bounding_box
254+ name_label .x = ((self .display .width // (2 * name_scale )) - width // 2 )
255+ name_label .y = int (height // (0.15 * name_scale ))
256+ name_label .color = 0xFFFFFF
257+ name_group .append (name_label )
258+ business_card_splash .append (name_group )
259+ if email_string_one :
260+ email_group_one = displayio .Group (scale = email_scale_one )
261+ email_label_one = Label (email_font_one , text = email_string_one )
262+ (_ , _ , width , height ) = email_label_one .bounding_box
263+ email_label_one .width = self .display .width
264+ email_label_one .x = ((self .display .width // (2 * email_scale_one )) - width // 2 )
265+ email_label_one .y = int (height // (0.13 * email_scale_one ))
266+ email_label_one .color = 0xFFFFFF
267+ email_group_one .append (email_label_one )
268+ business_card_splash .append (email_group_one )
269+ if email_string_two :
270+ email_group_two = displayio .Group (scale = email_scale_two )
271+ email_label_two = Label (email_font_two , text = email_string_two )
272+ (_ , _ , width , height ) = email_label_two .bounding_box
273+ email_label_two .width = self .display .width
274+ email_label_two .x = ((self .display .width // (2 * email_scale_two )) - width // 2 )
275+ email_label_two .y = int (height // (0.12 * email_scale_two ))
276+ email_label_two .color = 0xFFFFFF
277+ email_group_two .append (email_label_two )
278+ business_card_splash .append (email_group_two )
233279
234280 # pylint: disable=too-many-locals
235281 def show_badge (self , * , background_color = 0xFF0000 , foreground_color = 0xFFFFFF ,
@@ -258,7 +304,6 @@ def show_badge(self, *, background_color=0xFF0000, foreground_color=0xFFFFFF,
258304 "Blinka".
259305
260306 """
261- # Make the Display Background
262307 splash = displayio .Group (max_size = 20 )
263308
264309 color_bitmap = displayio .Bitmap (self .display .width , self .display .height , 1 )
@@ -270,15 +315,12 @@ def show_badge(self, *, background_color=0xFF0000, foreground_color=0xFFFFFF,
270315 x = 0 , y = 0 )
271316 splash .append (bg_sprite )
272317
273- # Draw a Foreground Rectangle where the name goes
274- # x, y, width, height
275318 rect = Rect (0 , (int (self .display .height * 0.4 )), self .display .width ,
276319 (int (self .display .height * 0.5 )), fill = foreground_color )
277320 splash .append (rect )
278321
279322 hello_scale = hello_scale
280323 hello_group = displayio .Group (scale = hello_scale )
281- # Setup and Center the Hello Label
282324 hello_label = Label (font = hello_font , text = hello_string )
283325 (_ , _ , width , height ) = hello_label .bounding_box
284326 hello_label .x = ((self .display .width // (2 * hello_scale )) - width // 2 )
@@ -288,7 +330,6 @@ def show_badge(self, *, background_color=0xFF0000, foreground_color=0xFFFFFF,
288330
289331 my_name_is_scale = my_name_is_scale
290332 my_name_is_group = displayio .Group (scale = my_name_is_scale )
291- # Setup and Center the "My Name Is" Label
292333 my_name_is_label = Label (font = my_name_is_font , text = my_name_is_string )
293334 (_ , _ , width , height ) = my_name_is_label .bounding_box
294335 my_name_is_label .x = ((self .display .width // (2 * my_name_is_scale )) - width // 2 )
@@ -298,7 +339,6 @@ def show_badge(self, *, background_color=0xFF0000, foreground_color=0xFFFFFF,
298339
299340 name_scale = name_scale
300341 name_group = displayio .Group (scale = name_scale )
301- # Setup and Center the Name Label
302342 name_label = Label (font = name_font , text = name_string )
303343 (_ , _ , width , height ) = name_label .bounding_box
304344 name_label .x = ((self .display .width // (2 * name_scale )) - width // 2 )
@@ -327,15 +367,15 @@ def bitmap_qr(matrix):
327367 bitmap [x + border_pixels , y + border_pixels ] = 0
328368 return bitmap
329369
330- def show_qr_code (self , data = b' https://circuitpython.org' , dwell = 20 ):
370+ def show_qr_code (self , * , data = " https://circuitpython.org" ):
331371 """Generate a QR code and display it for ``dwell`` seconds.
332372
333- :param bytearray data: A bytearray of data for the QR code
373+ :param string data: A string of data for the QR code
334374 :param int dwell: The amount of time in seconds to display the QR code
335375
336376 """
337377 qr_code = adafruit_miniqr .QRCode (qr_type = 3 , error_correct = adafruit_miniqr .L )
338- qr_code .add_data (data )
378+ qr_code .add_data (bytearray ( data ) )
339379 qr_code .make ()
340380 qr_bitmap = self .bitmap_qr (qr_code .matrix )
341381 palette = displayio .Palette (2 )
@@ -350,7 +390,6 @@ def show_qr_code(self, data=b'https://circuitpython.org', dwell=20):
350390 qr_code = displayio .Group (scale = qr_code_scale )
351391 qr_code .append (qr_img )
352392 self .display .show (qr_code )
353- time .sleep (dwell )
354393
355394 @staticmethod
356395 def _sine_sample (length ):
0 commit comments