@@ -109,8 +109,6 @@ class PyBadgerBase:
109
109
BLINKA_PURPLE = (102 , 45 , 145 )
110
110
BLINKA_PINK = (231 , 33 , 138 )
111
111
112
- RAINBOW = (RED , ORANGE , YELLOW , GREEN , BLUE , PURPLE )
113
-
114
112
# Button Constants
115
113
BUTTON_LEFT = const (128 )
116
114
BUTTON_UP = const (64 )
@@ -121,7 +119,7 @@ class PyBadgerBase:
121
119
BUTTON_A = const (2 )
122
120
BUTTON_B = const (1 )
123
121
124
- def __init__ (self , * , pixels_brightness = 1.0 ):
122
+ def __init__ (self ):
125
123
self ._light_sensor = None
126
124
self ._accelerometer = None
127
125
self ._label = label
@@ -137,7 +135,7 @@ def __init__(self, *, pixels_brightness=1.0):
137
135
138
136
# NeoPixels
139
137
self ._neopixels = neopixel .NeoPixel (board .NEOPIXEL , self ._neopixel_count ,
140
- brightness = pixels_brightness , pixel_order = neopixel .GRB )
138
+ brightness = 1 , pixel_order = neopixel .GRB )
141
139
142
140
# Auto dim display based on movement
143
141
self ._last_accelerometer = None
@@ -199,6 +197,9 @@ def badge_background(self, background_color=(255, 0, 0), rectangle_color=(255, 2
199
197
pybadger.badge_background(background_color=pybadger.WHITE,
200
198
rectangle_color=pybadger.PURPLE,
201
199
rectangle_drop=0.2, rectangle_height=0.6)
200
+
201
+ while True:
202
+ pybadger.show()
202
203
"""
203
204
self ._background_group = self ._badge_background (background_color , rectangle_color ,
204
205
rectangle_drop , rectangle_height )
@@ -233,6 +234,9 @@ def image_background(self, image_name=None):
233
234
from adafruit_pybadger import pybadger
234
235
235
236
pybadger.image_background("Blinka.bmp")
237
+
238
+ while True:
239
+ pybadger.show()
236
240
"""
237
241
self ._background_image_filename = image_name
238
242
@@ -262,19 +266,17 @@ def badge_line(self, text=" ", color=(0, 0, 0), scale=1, font=terminalio.FONT,
262
266
rectangle_color=pybadger.PURPLE,
263
267
rectangle_drop=0.2, rectangle_height=0.6)
264
268
265
- pybadger.badge_line(text="@blinka", color=pybadger.BLINKA_PURPLE, scale=4,
266
- padding_above=1)
267
- pybadger.badge_line(text="Blinka", color=pybadger.WHITE, scale=5,
269
+ pybadger.badge_line(text="@circuitpython", color=pybadger.BLINKA_PURPLE, scale=2,
268
270
padding_above=2)
271
+ pybadger.badge_line(text="Blinka", color=pybadger.WHITE, scale=5,
272
+ padding_above=3)
269
273
pybadger.badge_line(text="CircuitPython", color=pybadger.WHITE, scale=3,
270
274
padding_above=1)
271
275
pybadger.badge_line(text="she/her", color=pybadger.BLINKA_PINK, scale=4,
272
276
padding_above=4)
273
277
274
- pybadger.show()
275
-
276
278
while True:
277
- pass
279
+ pybadger.show()
278
280
"""
279
281
if isinstance (font , str ):
280
282
font = load_font (font , text )
@@ -314,8 +316,7 @@ def badge_line(self, text=" ", color=(0, 0, 0), scale=1, font=terminalio.FONT,
314
316
self ._y_position += height * scale + 4
315
317
316
318
def show (self ):
317
- """Call ``show()`` to display the badge lines of text."""
318
-
319
+ """Call ``pybadger.show()`` to display the custom badge elements."""
319
320
if not self ._created_background :
320
321
self ._create_badge_background ()
321
322
@@ -357,6 +358,12 @@ def auto_dim_display(self, delay=5.0, movement_threshold=10):
357
358
:param int movement_threshold: Threshold required for movement to be considered stopped.
358
359
Change to increase or decrease sensitivity.
359
360
361
+ .. code-block:: python
362
+
363
+ from adafruit_pybadger import pybadger
364
+
365
+ while True:
366
+ pybadger.auto_dim_display(delay=10)
360
367
"""
361
368
if not self ._check_for_movement (movement_threshold = movement_threshold ):
362
369
current_time = time .monotonic ()
@@ -383,7 +390,7 @@ def acceleration(self):
383
390
384
391
@property
385
392
def brightness (self ):
386
- """Display brightness."""
393
+ """Display brightness. Must be a value between ``0`` and ``1``. """
387
394
return self .display .brightness
388
395
389
396
@brightness .setter
@@ -417,6 +424,14 @@ def show_business_card(self, *, image_name=None, name_string=None, name_scale=1,
417
424
:param email_font_two: The font for the second email string. Defaults to
418
425
``terminalio.FONT``.
419
426
427
+ .. code-block:: python
428
+ from adafruit_pybadger import pybadger
429
+
430
+ while True:
431
+ pybadger.show_business_card(image_name="Blinka.bmp", name_string="Blinka",
432
+ name_scale=2, email_string_one="blinka@",
433
+ email_string_two="adafruit.com")
434
+
420
435
"""
421
436
business_card_label_groups = []
422
437
if name_string :
@@ -480,6 +495,14 @@ def show_badge(self, *, background_color=(255, 0, 0), foreground_color=(255, 255
480
495
:param name_string: The third string of the badge - change to be your name. Defaults to
481
496
"Blinka".
482
497
498
+ .. code-block:: python
499
+
500
+ from adafruit_pybadger import pybadger
501
+
502
+ while True:
503
+ pybadger.show_badge(name_string="Blinka", hello_scale=2, my_name_is_scale=2,
504
+ name_scale=3)
505
+
483
506
"""
484
507
hello_group = self ._create_label_group (text = hello_string ,
485
508
font = hello_font ,
@@ -528,11 +551,18 @@ def bitmap_qr(matrix):
528
551
bitmap [x + border_pixels , y + border_pixels ] = 0
529
552
return bitmap
530
553
531
- def show_qr_code (self , * , data = "https://circuitpython.org" ):
532
- """Generate a QR code and display it for ``dwell`` seconds .
554
+ def show_qr_code (self , data = "https://circuitpython.org" ):
555
+ """Generate a QR code.
533
556
534
557
:param string data: A string of data for the QR code
535
558
559
+ .. code-block:: python
560
+
561
+ from adafruit_pybadger import pybadger
562
+
563
+ while True:
564
+ pybadger.show_qr_code("https://adafruit.com")
565
+
536
566
"""
537
567
qr_code = adafruit_miniqr .QRCode (qr_type = 3 , error_correct = adafruit_miniqr .L )
538
568
qr_code .add_data (bytearray (data ))
@@ -585,7 +615,7 @@ def play_tone(self, frequency, duration):
585
615
586
616
def start_tone (self , frequency ):
587
617
""" Produce a tone using the speaker. Try changing frequency to change
588
- the pitch of the tone.
618
+ the pitch of the tone. Use ``stop_tone`` to stop the tone.
589
619
590
620
:param int frequency: The frequency of the tone in Hz
591
621
@@ -601,7 +631,7 @@ def start_tone(self, frequency):
601
631
self ._sample .play (self ._sine_wave_sample , loop = True )
602
632
603
633
def stop_tone (self ):
604
- """ Use with start_tone to stop the tone produced.
634
+ """ Use with `` start_tone`` to stop the tone produced.
605
635
"""
606
636
# Stop playing any tones.
607
637
if self ._sample is not None and self ._sample .playing :
0 commit comments