Skip to content

Commit 4cf2dbf

Browse files
Camera app: don't repeat yourself
1 parent 031d502 commit 4cf2dbf

File tree

1 file changed

+3
-2
lines changed
  • internal_filesystem/apps/com.micropythonos.camera/assets

1 file changed

+3
-2
lines changed

internal_filesystem/apps/com.micropythonos.camera/assets/camera_app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,13 @@ def snap_button_click(self, e):
260260
print("Taking picture...")
261261
# Would be nice to check that there's enough free space here, and show an error if not...
262262
import os
263+
path = "data/images"
263264
try:
264265
os.mkdir("data")
265266
except OSError:
266267
pass
267268
try:
268-
os.mkdir("data/images")
269+
os.mkdir(path)
269270
except OSError:
270271
pass
271272
if self.current_cam_buffer is None:
@@ -281,7 +282,7 @@ def snap_button_click(self, e):
281282
self.status_label_cont.remove_flag(lv.obj.FLAG.HIDDEN)
282283
return
283284
colorname = "RGB565" if self.colormode else "GRAY"
284-
filename=f"data/images/camera_capture_{mpos.time.epoch_seconds()}_{self.width}x{self.height}_{colorname}.raw"
285+
filename=f"{path}/picture_{mpos.time.epoch_seconds()}_{self.width}x{self.height}_{colorname}.raw"
285286
try:
286287
with open(filename, 'wb') as f:
287288
f.write(self.current_cam_buffer) # This takes around 17 seconds to store 921600 bytes, so ~50KB/s, so would be nice to show some progress bar

0 commit comments

Comments
 (0)