File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
micropython/examples/badger2040 Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 49
49
"current_qr" : 0
50
50
}
51
51
52
+ def set_state_current_index_in_range ():
53
+ badger_os .state_load ("qrcodes" , state )
54
+
55
+ if state ["current_qr" ] >= len (CODES ):
56
+ state ["current_qr" ] = len (CODES ) - 1 # set to last index (zero-based). Note: will set to -1 if currently 0
57
+
58
+ # check that the index is not negative, thus still out of range
59
+ if state ["current_qr" ] < 0 :
60
+ state ["current_qr" ] = 0
61
+
62
+ badger_os .state_save ("qrcodes" , state )
63
+
52
64
53
65
def measure_qr_code (size , code ):
54
66
w , h = code .get_size ()
@@ -110,7 +122,7 @@ def draw_qr_file(n):
110
122
display .update ()
111
123
112
124
113
- badger_os . state_load ( "qrcodes" , state )
125
+ set_state_current_index_in_range ( )
114
126
changed = not badger2040 .woken_by_button ()
115
127
116
128
while True :
You can’t perform that action at this time.
0 commit comments