Slide 21
Slide 21 text
ble = BLERadio()
uart_service = UARTService()
advertisement = ProvideServicesAdvertisement(uart_service)
while True:
ble.start_advertising(advertisement)
while ble.connected:
animation_sequence.animate()
if uart_service.in_waiting: # Get a Bluetooth Packet if one is sent
packet = Packet.from_stream(uart_service)
if isinstance(packet, ColorPacket):
selected_color = packet.color
if isinstance(packet, ButtonPacket):
if packet.pressed:
if packet.button == ButtonPacket.RIGHT:
animation_sequence.next()
print(
"Selecting next animation: ",
animation_sequence.current_animation.__class__.__name__,
)
code: git.io/ledjacket