Skip to content

Commit 9ece189

Browse files
Piggy: make capture QR generic
1 parent 6f7a3e7 commit 9ece189

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

internal_filesystem/apps/com.lightningpiggy.displaywallet/assets/captureqr.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616

1717
import mpos.apps
18-
import mpos.clipboard
1918
import mpos.ui
2019

2120
# screens:
@@ -79,9 +78,9 @@ def qrdecode_one():
7978
print(f"QR decoding found: {result}")
8079
status_label.set_text(result)
8180
stop_qr_decoding()
82-
mpos.clipboard.add(f"Result: {result}")
8381
mpos.ui.back_screen()
84-
scanqr_callback(True,result)
82+
if scanqr_callback:
83+
scanqr_callback(True,result)
8584
except ValueError as e:
8685
print("QR ValueError: ", e)
8786
status_label.set_text(status_label_text_searching)
@@ -269,7 +268,7 @@ def check_running(timer):
269268
print("camtest.py cleanup done.")
270269

271270

272-
def scanqr(scanqr_cb):
271+
def init(scanqr_cb=None):
273272
global scanqr_callback, cam, use_webcam, check_running_timer, status_label_cont, capture_timer, main_screen
274273
scanqr_callback = scanqr_cb
275274
build_ui()
@@ -286,14 +285,21 @@ def scanqr(scanqr_cb):
286285
if cam:
287286
print("Camera initialized, continuing...")
288287
check_running_timer = lv.timer_create(check_running, 500, None)
289-
#qr_button.remove_flag(lv.obj.FLAG.HIDDEN)
290-
#snap_button.remove_flag(lv.obj.FLAG.HIDDEN)
291-
status_label_cont.add_flag(lv.obj.FLAG.HIDDEN)
292288
capture_timer = lv.timer_create(try_capture, 100, None)
293-
start_qr_decoding()
289+
status_label_cont.add_flag(lv.obj.FLAG.HIDDEN)
290+
if scanqr_callback:
291+
start_qr_decoding()
292+
else:
293+
qr_button.remove_flag(lv.obj.FLAG.HIDDEN)
294+
snap_button.remove_flag(lv.obj.FLAG.HIDDEN)
294295
return main_screen
295296
else:
296297
print("No camera found, stopping camtest.py")
297-
scanqr_callback(False,"")
298+
if scanqr_callback:
299+
scanqr_callback(False,"")
298300
return None
299301

302+
303+
if __name__ == '__main__':
304+
print("camera started as __main__")
305+
mpos.ui.load_screen(init())

internal_filesystem/apps/com.lightningpiggy.displaywallet/assets/displaywallet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def cambutton_cb(self, event):
152152
global qr_scanner_screen
153153
print("cambutton clicked!")
154154
import captureqr
155-
qr_scanner_screen = captureqr.scanqr(self.gotqr_callback)
155+
qr_scanner_screen = captureqr.init(self.gotqr_callback)
156156
if qr_scanner_screen:
157157
mpos.ui.load_screen(qr_scanner_screen)
158158

0 commit comments

Comments
 (0)