-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
31 lines (26 loc) · 823 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def on_bluetooth_connected():
global isConnected
basic.show_string("C")
isConnected = True
bluetooth.on_bluetooth_connected(on_bluetooth_connected)
def on_bluetooth_disconnected():
global isConnected
basic.show_string("D")
isConnected = False
bluetooth.on_bluetooth_disconnected(on_bluetooth_disconnected)
def on_button_pressed_a():
basic.show_string(cmd)
input.on_button_pressed(Button.A, on_button_pressed_a)
def on_uart_data_received():
global cmd
cmd = bluetooth.uart_read_until(serial.delimiters(Delimiters.NEW_LINE))
cmd = cmd.substr(0, len(cmd) - 1)
bluetooth.on_uart_data_received(serial.delimiters(Delimiters.NEW_LINE),
on_uart_data_received)
isConnected = False
cmd = ""
bluetooth.start_uart_service()
cmd = ""
def on_forever():
pass
basic.forever(on_forever)