|
20 | 20 | # Circuit Playground Bluefruit buttons and LED setup
|
21 | 21 | butA = digitalio.DigitalInOut(board.D4) # CPB "A" button
|
22 | 22 | butB = digitalio.DigitalInOut(board.D5) # CPB "B" button
|
23 |
| -butA.switch_to_input(digitalio.Pull.DOWN) # buttons are active HIGH |
| 23 | +butA.switch_to_input(digitalio.Pull.DOWN) # buttons are active HIGH |
24 | 24 | butB.switch_to_input(digitalio.Pull.DOWN)
|
25 | 25 |
|
26 | 26 | leds = neopixel.NeoPixel(board.D8, 10, brightness=0.1)
|
27 | 27 |
|
28 |
| -(coff, cred, cgrn, cblu, cgra) = (0x000000, 0xff0000, 0x00ff00, 0x0000ff, 0x111111 ) |
29 |
| -leds_off = ( coff,coff,coff,coff,coff, coff,coff,coff,coff,coff ) |
30 |
| -leds_idle = ( cgra,cgra,cgra,cgra,cgra, cgra,cgra,cgra,cgra,cgra ) |
31 |
| -leds_incoming_call = ( coff,cgrn,cgrn,cgrn,coff, coff,cred,cred,cred,coff ) |
32 |
| -leds_active_call = ( cgrn,coff,coff,coff,cgrn, cgrn,cred,cred,cred,cgrn ) |
| 28 | +(coff, cred, cgrn, cblu, cgra) = (0x000000, 0xFF0000, 0x00FF00, 0x0000FF, 0x111111) |
| 29 | +leds_off = (coff, coff, coff, coff, coff, coff, coff, coff, coff, coff) |
| 30 | +leds_idle = (cgra, cgra, cgra, cgra, cgra, cgra, cgra, cgra, cgra, cgra) |
| 31 | +leds_incoming_call = (coff, cgrn, cgrn, cgrn, coff, coff, cred, cred, cred, coff) |
| 32 | +leds_active_call = (cgrn, coff, coff, coff, cgrn, cgrn, cred, cred, cred, cgrn) |
33 | 33 |
|
34 | 34 | print("starting...")
|
35 | 35 | radio = adafruit_ble.BLERadio() # pylint: disable=no-member
|
36 | 36 | a = SolicitServicesAdvertisement()
|
37 |
| -#a.complete_name = "CIRPYCALLHANDLER" # this crashes things? |
| 37 | +# a.complete_name = "CIRPYCALLHANDLER" # this crashes things? |
38 | 38 | a.solicited_services.append(ancs.AppleNotificationCenterService)
|
39 | 39 | radio.start_advertising(a)
|
40 | 40 |
|
|
64 | 64 | if butA.value:
|
65 | 65 | print("Action: accepting call")
|
66 | 66 | notification.send_positive_action()
|
67 |
| - time.sleep(1) # simple debounce |
| 67 | + time.sleep(1) # simple debounce |
68 | 68 | if butB.value:
|
69 | 69 | print("Action: declining call")
|
70 | 70 | notification.send_negative_action()
|
71 |
| - time.sleep(1) # simple debounce |
| 71 | + time.sleep(1) # simple debounce |
72 | 72 | # active call category, only has negative action
|
73 | 73 | if notification.category_id == 12:
|
74 | 74 | leds[:] = leds_active_call
|
75 | 75 | if butB.value:
|
76 | 76 | print("Action: hanging up call")
|
77 | 77 | notification.send_negative_action()
|
78 |
| - time.sleep(1) # simple debounce |
| 78 | + time.sleep(1) # simple debounce |
79 | 79 |
|
80 | 80 | if time.monotonic() - last_display_time > 3.0:
|
81 | 81 | last_display_time = time.monotonic()
|
82 |
| - print("Current Notifications:", len(ans.active_notifications), time.monotonic()) |
| 82 | + print( |
| 83 | + "Current Notifications:", |
| 84 | + len(ans.active_notifications), |
| 85 | + time.monotonic(), |
| 86 | + ) |
83 | 87 | for nid, n in ans.active_notifications.items():
|
84 |
| - print("- uid:",n.id, "catid:", n.category_id, "title:", n.title, "msg:", n.message) |
| 88 | + print( |
| 89 | + "- uid:", |
| 90 | + n.id, |
| 91 | + "catid:", |
| 92 | + n.category_id, |
| 93 | + "title:", |
| 94 | + n.title, |
| 95 | + "msg:", |
| 96 | + n.message, |
| 97 | + ) |
0 commit comments