@@ -86,7 +86,10 @@ def __init__(self, i2c=None):
8686 if i2c is None :
8787 i2c = board .I2C ()
8888 int1 = digitalio .DigitalInOut (board .ACCELEROMETER_INTERRUPT )
89- self ._accelerometer = adafruit_lis3dh .LIS3DH_I2C (i2c , address = 0x19 , int1 = int1 )
89+ try :
90+ self ._accelerometer = adafruit_lis3dh .LIS3DH_I2C (i2c , address = 0x19 , int1 = int1 )
91+ except ValueError :
92+ self ._accelerometer = adafruit_lis3dh .LIS3DH_I2C (i2c , int1 = int1 )
9093
9194 # Buttons
9295 self ._buttons = GamePadShift (digitalio .DigitalInOut (board .BUTTON_CLOCK ),
@@ -210,7 +213,7 @@ def brightness(self):
210213 def brightness (self , value ):
211214 self .display .brightness = value
212215
213- def business_card (self , image_name = None , dwell = 20 ):
216+ def show_business_card (self , image_name = None , dwell = 20 ):
214217 """Display a bitmap image and a text string, such as a personal image and email address.
215218 CURRENTLY ONLY DISPLAYS BITMAP IMAGE. Text string to be added.
216219
@@ -229,21 +232,27 @@ def business_card(self, image_name=None, dwell=20):
229232 time .sleep (dwell )
230233
231234 # pylint: disable=too-many-locals
232- def badge (self , * , background_color = 0xFF0000 , foreground_color = 0xFFFFFF ,
233- background_text_color = 0xFFFFFF , foreground_text_color = 0x000000 , hello_scale = 1 ,
234- hello_string = "HELLO" , my_name_is_scale = 1 , my_name_is_string = "MY NAME IS" ,
235- name_scale = 1 , name_string = "Blinka" ):
235+ def show_badge (self , * , background_color = 0xFF0000 , foreground_color = 0xFFFFFF ,
236+ background_text_color = 0xFFFFFF , foreground_text_color = 0x000000 ,
237+ hello_font = terminalio .FONT , hello_scale = 1 , hello_string = "HELLO" ,
238+ my_name_is_font = terminalio .FONT , my_name_is_scale = 1 ,
239+ my_name_is_string = "MY NAME IS" , name_font = terminalio .FONT , name_scale = 1 ,
240+ name_string = "Blinka" ):
236241 """Create a "Hello My Name is"-style badge.
237242
238243 :param background_color: The color of the background. Defaults to 0xFF0000.
239244 :param foreground_color: The color of the foreground rectangle. Defaults to 0xFFFFFF.
240245 :param background_text_color: The color of the "HELLO MY NAME IS" text. Defaults to
241246 0xFFFFFF.
242247 :param foreground_text_color: The color of the name text. Defaults to 0x000000.
248+ :param hello_font: The font for the "HELLO" string. Defaults to ``terminalio.FONT``.
243249 :param hello_scale: The size scale of the "HELLO" string. Defaults to 1.
244250 :param hello_string: The first string of the badge. Defaults to "HELLO".
251+ :param my_name_is_font: The font for the "MY NAME IS" string. Defaults to
252+ ``terminalio.FONT``.
245253 :param my_name_is_scale: The size scale of the "MY NAME IS" string. Defaults to 1.
246254 :param my_name_is_string: The second string of the badge. Defaults to "MY NAME IS".
255+ :param name_font: The font for the name string. Defaults to ``terminalio.FONT``.
247256 :param name_scale: The size scale of the name string. Defaults to 1.
248257 :param name_string: The third string of the badge - change to be your name. Defaults to
249258 "Blinka".
@@ -270,7 +279,7 @@ def badge(self, *, background_color=0xFF0000, foreground_color=0xFFFFFF,
270279 hello_scale = hello_scale
271280 hello_group = displayio .Group (scale = hello_scale )
272281 # Setup and Center the Hello Label
273- hello_label = Label (terminalio . FONT , text = hello_string )
282+ hello_label = Label (font = hello_font , text = hello_string )
274283 (_ , _ , width , height ) = hello_label .bounding_box
275284 hello_label .x = ((self .display .width // (2 * hello_scale )) - width // 2 )
276285 hello_label .y = int (height // (1.2 * hello_scale ))
@@ -280,7 +289,7 @@ def badge(self, *, background_color=0xFF0000, foreground_color=0xFFFFFF,
280289 my_name_is_scale = my_name_is_scale
281290 my_name_is_group = displayio .Group (scale = my_name_is_scale )
282291 # Setup and Center the "My Name Is" Label
283- my_name_is_label = Label (terminalio . FONT , text = my_name_is_string )
292+ my_name_is_label = Label (font = my_name_is_font , text = my_name_is_string )
284293 (_ , _ , width , height ) = my_name_is_label .bounding_box
285294 my_name_is_label .x = ((self .display .width // (2 * my_name_is_scale )) - width // 2 )
286295 my_name_is_label .y = int (height // (0.42 * my_name_is_scale ))
@@ -290,7 +299,7 @@ def badge(self, *, background_color=0xFF0000, foreground_color=0xFFFFFF,
290299 name_scale = name_scale
291300 name_group = displayio .Group (scale = name_scale )
292301 # Setup and Center the Name Label
293- name_label = Label (terminalio . FONT , text = name_string )
302+ name_label = Label (font = name_font , text = name_string )
294303 (_ , _ , width , height ) = name_label .bounding_box
295304 name_label .x = ((self .display .width // (2 * name_scale )) - width // 2 )
296305 name_label .y = int (height // (0.17 * name_scale ))
@@ -318,7 +327,7 @@ def bitmap_qr(matrix):
318327 bitmap [x + border_pixels , y + border_pixels ] = 0
319328 return bitmap
320329
321- def qr_code (self , data = b'https://circuitpython.org' , dwell = 20 ):
330+ def show_qr_code (self , data = b'https://circuitpython.org' , dwell = 20 ):
322331 """Generate a QR code and display it for ``dwell`` seconds.
323332
324333 :param bytearray data: A bytearray of data for the QR code
0 commit comments