Commit 9dd93ad1 authored by Klint Youngmeyer's avatar Klint Youngmeyer
Browse files

Add LED toggle on 'notification' packet, write to LCD on anything else

parent 5cfeb543
......@@ -16,6 +16,12 @@ def blechat(name):
print('Local Device MAC Address = {}'.format(rs.get_local_addr()))
print('Local Device Name = {}'.format(rs.get_local_name()))
rs.advertise(True)
lcd = pyb.LCD()
lcd.light(True)
lcd.fill(0)
lcd.show()
led = pyb.LED(1)
led.off()
print("Waiting for connection...")
......@@ -38,11 +44,19 @@ def blechat(name):
done = True
elif event == rs.WRITE_EVENT:
event_rsp = rs.get_event_data(event)
print('Write event')
print('Write event')
print('Write Data = {}'.format(event_rsp))
if event_rsp[0] in ('\x00\x00', '\x01\x00'):
if event_rsp[0] is '\x00\x00':
led.off()
else:
led.on()
else:
lcd.write(event_rsp[0] + '\n')
# event_attr_index = rs.event_attr_hiandle()
# if event_attr_index == write_attr_ index:
# print('Write event')
# print('Write event')
# print('Write Data = {}'.format (rs.event_attr_value()))
# rs.set_attr_value(read_attr_index, rs.event_attr_value())
else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment