Check if UARTService is in waiting before reading Stream

This commit is contained in:
Nina Zakharenko 2020-06-13 22:59:12 -07:00
parent 646cdd8afd
commit cceaf0de1e

View file

@ -22,7 +22,8 @@ while True:
ble.stop_advertising() ble.stop_advertising()
while ble.connected: while ble.connected:
packet = Packet.from_stream(uart_service) if uart_service.in_waiting:
if isinstance(packet, ColorPacket): packet = Packet.from_stream(uart_service)
print(packet.color) if isinstance(packet, ColorPacket):
pixels.fill(packet.color) print(packet.color)
pixels.fill(packet.color)