@@ -86,7 +86,10 @@ def __init__(self, i2c=None):
86
86
if i2c is None :
87
87
i2c = board .I2C ()
88
88
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 )
90
93
91
94
# Buttons
92
95
self ._buttons = GamePadShift (digitalio .DigitalInOut (board .BUTTON_CLOCK ),
@@ -210,7 +213,7 @@ def brightness(self):
210
213
def brightness (self , value ):
211
214
self .display .brightness = value
212
215
213
- def business_card (self , image_name = None , dwell = 20 ):
216
+ def show_business_card (self , image_name = None , dwell = 20 ):
214
217
"""Display a bitmap image and a text string, such as a personal image and email address.
215
218
CURRENTLY ONLY DISPLAYS BITMAP IMAGE. Text string to be added.
216
219
@@ -229,21 +232,27 @@ def business_card(self, image_name=None, dwell=20):
229
232
time .sleep (dwell )
230
233
231
234
# 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" ):
236
241
"""Create a "Hello My Name is"-style badge.
237
242
238
243
:param background_color: The color of the background. Defaults to 0xFF0000.
239
244
:param foreground_color: The color of the foreground rectangle. Defaults to 0xFFFFFF.
240
245
:param background_text_color: The color of the "HELLO MY NAME IS" text. Defaults to
241
246
0xFFFFFF.
242
247
: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``.
243
249
:param hello_scale: The size scale of the "HELLO" string. Defaults to 1.
244
250
: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``.
245
253
:param my_name_is_scale: The size scale of the "MY NAME IS" string. Defaults to 1.
246
254
: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``.
247
256
:param name_scale: The size scale of the name string. Defaults to 1.
248
257
:param name_string: The third string of the badge - change to be your name. Defaults to
249
258
"Blinka".
@@ -270,7 +279,7 @@ def badge(self, *, background_color=0xFF0000, foreground_color=0xFFFFFF,
270
279
hello_scale = hello_scale
271
280
hello_group = displayio .Group (scale = hello_scale )
272
281
# 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 )
274
283
(_ , _ , width , height ) = hello_label .bounding_box
275
284
hello_label .x = ((self .display .width // (2 * hello_scale )) - width // 2 )
276
285
hello_label .y = int (height // (1.2 * hello_scale ))
@@ -280,7 +289,7 @@ def badge(self, *, background_color=0xFF0000, foreground_color=0xFFFFFF,
280
289
my_name_is_scale = my_name_is_scale
281
290
my_name_is_group = displayio .Group (scale = my_name_is_scale )
282
291
# 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 )
284
293
(_ , _ , width , height ) = my_name_is_label .bounding_box
285
294
my_name_is_label .x = ((self .display .width // (2 * my_name_is_scale )) - width // 2 )
286
295
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,
290
299
name_scale = name_scale
291
300
name_group = displayio .Group (scale = name_scale )
292
301
# 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 )
294
303
(_ , _ , width , height ) = name_label .bounding_box
295
304
name_label .x = ((self .display .width // (2 * name_scale )) - width // 2 )
296
305
name_label .y = int (height // (0.17 * name_scale ))
@@ -318,7 +327,7 @@ def bitmap_qr(matrix):
318
327
bitmap [x + border_pixels , y + border_pixels ] = 0
319
328
return bitmap
320
329
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 ):
322
331
"""Generate a QR code and display it for ``dwell`` seconds.
323
332
324
333
:param bytearray data: A bytearray of data for the QR code
0 commit comments