|
| 1 | +import time |
| 2 | + |
1 | 3 | appscreen = lv.screen_active() |
2 | 4 |
|
3 | 5 | keepgoing = True |
@@ -105,31 +107,34 @@ def qr_button_click(e): |
105 | 107 | close_label.center() |
106 | 108 | def close_button_click(e): |
107 | 109 | global keepgoing |
108 | | - print("Closing camera!") |
| 110 | + print("Close button clicked") |
109 | 111 | keepgoing = False |
110 | 112 |
|
111 | 113 | close_button.add_event_cb(close_button_click,lv.EVENT.CLICKED,None) |
112 | 114 |
|
113 | 115 |
|
114 | 116 | from camera import Camera, GrabMode, PixelFormat, FrameSize, GainCeiling |
115 | 117 |
|
116 | | -cam = Camera( |
117 | | - data_pins=[12,13,15,11,14,10,7,2], |
118 | | - vsync_pin=6, |
119 | | - href_pin=4, |
120 | | - sda_pin=21, |
121 | | - scl_pin=16, |
122 | | - pclk_pin=9, |
123 | | - xclk_pin=8, |
124 | | - xclk_freq=20000000, |
125 | | - powerdown_pin=-1, |
126 | | - reset_pin=-1, |
127 | | - #pixel_format=PixelFormat.RGB565, |
128 | | - pixel_format=PixelFormat.GRAYSCALE, |
129 | | - frame_size=FrameSize.R240X240, |
130 | | - grab_mode=GrabMode.LATEST |
131 | | -) |
132 | | -#cam.init() automatically done when creating the Camera() |
| 118 | +try: |
| 119 | + cam = Camera( |
| 120 | + data_pins=[12,13,15,11,14,10,7,2], |
| 121 | + vsync_pin=6, |
| 122 | + href_pin=4, |
| 123 | + sda_pin=21, |
| 124 | + scl_pin=16, |
| 125 | + pclk_pin=9, |
| 126 | + xclk_pin=8, |
| 127 | + xclk_freq=20000000, |
| 128 | + powerdown_pin=-1, |
| 129 | + reset_pin=-1, |
| 130 | + #pixel_format=PixelFormat.RGB565, |
| 131 | + pixel_format=PixelFormat.GRAYSCALE, |
| 132 | + frame_size=FrameSize.R240X240, |
| 133 | + grab_mode=GrabMode.LATEST |
| 134 | + ) |
| 135 | + #cam.init() automatically done when creating the Camera() |
| 136 | +except Exception as e: |
| 137 | + print(f"Exception while initializing camera: {e}") |
133 | 138 |
|
134 | 139 | #cam.reconfigure(frame_size=FrameSize.HVGA) |
135 | 140 | #frame_size=FrameSize.HVGA, # 480x320 |
@@ -186,8 +191,7 @@ def try_capture(): |
186 | 191 | try_capture() |
187 | 192 |
|
188 | 193 |
|
189 | | -import time |
190 | | -while appscreen == lv.screen_active() and keepgoing: |
| 194 | +while appscreen == lv.screen_active() and keepgoing is True: |
191 | 195 | try_capture() |
192 | 196 | time.sleep_ms(100) # Allow for the MicroPython REPL to still work. Reducing it doesn't seem to affect the on-display FPS. |
193 | 197 |
|
|
0 commit comments