Skip to content
Snippets Groups Projects
Commit ae08d2f9 authored by schneider's avatar schneider
Browse files

feat(exno): Save config

parent aadcb133
No related branches found
No related tags found
1 merge request!392Show COVID-19 exposure notification statistics
Pipeline #4666 passed
......@@ -6,6 +6,7 @@ import display
import color
import buttons
import leds
import config
DM_ADV_TYPE_FLAGS = 0x01
DM_ADV_TYPE_16_UUID = 0x03
......@@ -19,8 +20,8 @@ MODE_ON_RX = 2
MODE_BOTH = 3
seen = {}
vib_mode = MODE_OFF
led_mode = MODE_OFF
vib_mode = MODE_BOTH
led_mode = MODE_BOTH
def parse_advertisement_data(data):
......@@ -100,12 +101,13 @@ def process_scan_report(scan_report):
def ble_callback(_):
event = sys_ble.get_event()
prune()
while True:
scan_report = sys_ble.get_scan_report()
if scan_report == None:
return
process_scan_report(scan_report)
if event == sys_ble.EVENT_SCAN_REPORT:
while True:
scan_report = sys_ble.get_scan_report()
if scan_report == None:
break
process_scan_report(scan_report)
prune()
def show_stats():
......@@ -139,7 +141,6 @@ def show_stats():
disp.update()
t0 = time.time()
last_rx_time = 0
disp = display.open()
v_old = 0
......@@ -148,6 +149,15 @@ pause = 1
interrupt.set_callback(interrupt.BLE, ble_callback)
interrupt.enable_callback(interrupt.BLE)
try:
vib_mode = int(config.get_string("exno_vib_mode"))
except:
pass
try:
led_mode = int(config.get_string("exno_led_mode"))
except:
pass
disp.clear()
disp.print(" Exp Notif", posy=0, fg=color.WHITE)
......@@ -158,6 +168,7 @@ disp.update()
time.sleep(3)
t0 = time.time()
sys_ble.scan_start()
while True:
......@@ -182,8 +193,9 @@ while True:
elif vib_mode == MODE_BOTH:
vib_mode = MODE_OFF
disp.print("Vib off", posy=40, fg=color.WHITE)
disp.update()
config.set_string("exno_vib_mode", str(vib_mode))
pause = 20
if v & buttons.BOTTOM_LEFT:
......@@ -203,8 +215,9 @@ while True:
elif led_mode == MODE_BOTH:
led_mode = MODE_OFF
disp.print("LED off", posy=40, fg=color.WHITE)
disp.update()
config.set_string("exno_led_mode", str(led_mode))
pause = 20
pause -= 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment