Improve scan UI, slightly
parent
aee5d6b2b6
commit
9f78ea99c8
|
@ -14,30 +14,44 @@ from tilda import Buttons
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
btrestore = False
|
btrestore = False
|
||||||
|
duration = 10
|
||||||
status_height = 20
|
status_height = 20
|
||||||
|
|
||||||
ugfx.init()
|
ugfx.init()
|
||||||
ugfx.clear()
|
ugfx.clear()
|
||||||
ugfx.set_default_font(ugfx.FONT_FIXED)
|
ugfx.set_default_font(ugfx.FONT_FIXED)
|
||||||
|
|
||||||
ugfx.Label(5, 180, 240, 15, "Press A to scan, MENU to exit")
|
def instructions(duration):
|
||||||
ugfx.Label(5, 200, 240, 15, "Scan requires ~10 seconds")
|
ugfx.Label(5, 180, 240, 30, "Press A to start, B to change scan length or MENU to exit")
|
||||||
|
ugfx.Label(5, 210, 240, 15, "Scan requires ~{0} seconds".format(duration))
|
||||||
|
|
||||||
if not sim800.btison():
|
if not sim800.btison():
|
||||||
sim800.btpoweron()
|
sim800.btpoweron()
|
||||||
btrestore = True
|
btrestore = True
|
||||||
|
|
||||||
|
instructions(duration)
|
||||||
# while (not Buttons.is_pressed(Buttons.BTN_A)) and (not Buttons.is_pressed(Buttons.BTN_B)) and (not Buttons.is_pressed(Buttons.BTN_Menu)):
|
# while (not Buttons.is_pressed(Buttons.BTN_A)) and (not Buttons.is_pressed(Buttons.BTN_B)) and (not Buttons.is_pressed(Buttons.BTN_Menu)):
|
||||||
while not Buttons.is_pressed(Buttons.BTN_Menu):
|
while not Buttons.is_pressed(Buttons.BTN_Menu):
|
||||||
if not Buttons.is_pressed(Buttons.BTN_A):
|
a = Buttons.is_pressed(Buttons.BTN_A)
|
||||||
|
b = Buttons.is_pressed(Buttons.BTN_B)
|
||||||
|
if not a and not b:
|
||||||
ugfx.poll()
|
ugfx.poll()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if b:
|
||||||
|
duration = duration + 5
|
||||||
|
if duration > 60:
|
||||||
|
duration = 5
|
||||||
|
ugfx.clear()
|
||||||
|
instructions(duration)
|
||||||
|
continue
|
||||||
|
|
||||||
ugfx.clear()
|
ugfx.clear()
|
||||||
|
|
||||||
np.display([0,0])
|
np.display([0,0])
|
||||||
np.display([0x000099, 0x000099])
|
np.display([0x000099, 0x000099])
|
||||||
devs = sim800.btscan(15000)
|
devs = sim800.btscan(duration*1000)
|
||||||
|
np.display([0x00, 0x00])
|
||||||
|
|
||||||
if len(devs) == 0:
|
if len(devs) == 0:
|
||||||
ugfx.Label(0, 0, 240, 25, "No devices found")
|
ugfx.Label(0, 0, 240, 25, "No devices found")
|
||||||
|
@ -47,17 +61,14 @@ while not Buttons.is_pressed(Buttons.BTN_Menu):
|
||||||
else:
|
else:
|
||||||
if type(devs[0]) == int:
|
if type(devs[0]) == int:
|
||||||
devs = [devs]
|
devs = [devs]
|
||||||
print(devs)
|
|
||||||
|
|
||||||
y = 0
|
y = 0
|
||||||
for dev in devs[:20]:
|
for dev in devs[:20]:
|
||||||
print(dev)
|
|
||||||
ugfx.Label(0, y, 240, 25, "{3}dB {1}".format(*dev))
|
ugfx.Label(0, y, 240, 25, "{3}dB {1}".format(*dev))
|
||||||
y += status_height
|
y += status_height
|
||||||
|
instructions(duration)
|
||||||
|
|
||||||
np.display([0x00, 0x00])
|
## App quitting...
|
||||||
|
|
||||||
if btrestore:
|
if btrestore:
|
||||||
sim800.btpoweroff()
|
sim800.btpoweroff()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue