-
Notifications
You must be signed in to change notification settings - Fork 3
/
learn.py
39 lines (26 loc) · 855 Bytes
/
learn.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
32
33
34
35
36
37
38
39
from bl_common import get_device, get_packet
def main():
# initialise variables
p = ""
# get broadlink device
device = get_device()
while p is not None:
# get packet
print("\nPress a button\n")
p = get_packet(device,5)
# if no packet received, prompt to try again
while p is None:
prompt = None
while prompt not in ['Y','y','N','n']:
prompt = str(input('Nothing received. Try again?\n(Y/N) '))
if prompt.strip().upper() == 'N':
break
print("\nPress a button\n")
p = get_packet(device,5)
# break loop if user chooses not to try again
if p is None:
break
# print packet
print(f'{p}\n')
if __name__ == '__main__':
main()