Skip to content

Commit cee0b92

Browse files
Camera app: extract variable
1 parent 06d98ce commit cee0b92

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- OSUpdate app: pause download when wifi is lost, resume when reconnected
77
- Settings app: fix un-checking of radio button
88
- API: SharedPreferences: add erase_all() functionality
9+
- API: improve and cleanup animations
910

1011
0.5.0
1112
=====

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ class CameraApp(Activity):
1515

1616
DEFAULT_WIDTH = 320 # 240 would be better but webcam doesn't support this (yet)
1717
DEFAULT_HEIGHT = 240
18+
APPNAME = "com.micropythonos.camera"
19+
#DEFAULT_CONFIG = "config.json"
20+
#QRCODE_CONFIG = "config_qrmode.json"
1821

1922
button_width = 60
2023
button_height = 45
2124
colormode = False
2225

2326
status_label_text = "No camera found."
24-
status_label_text_searching = "Searching QR codes...\n\nHold still and try varying scan distance (10-25cm) and QR size (4-12cm). Ensure proper lighting."
25-
status_label_text_found = "Decoding QR..."
27+
status_label_text_searching = "Searching QR codes...\n\nHold still and try varying scan distance (10-25cm) and make the QR code big (4-12cm). Ensure proper lighting."
28+
status_label_text_found = "Found QR, trying to decode... hold still..."
2629

2730
cam = None
2831
current_cam_buffer = None # Holds the current memoryview to prevent garbage collection
@@ -167,7 +170,7 @@ def onPause(self, screen):
167170

168171
def load_resolution_preference(self):
169172
"""Load resolution preference from SharedPreferences and update width/height."""
170-
prefs = SharedPreferences("com.micropythonos.camera")
173+
prefs = SharedPreferences(CameraApp.APPNAME)
171174
resolution_str = prefs.get_string("resolution", f"{self.DEFAULT_WIDTH}x{self.DEFAULT_HEIGHT}")
172175
self.colormode = prefs.get_bool("colormode", False)
173176
try:
@@ -283,7 +286,7 @@ def zoom_button_click(self, e):
283286
print("zoom_button_click is not supported for webcam")
284287
return
285288
if self.cam:
286-
prefs = SharedPreferences("com.micropythonos.camera")
289+
prefs = SharedPreferences(CameraApp.APPNAME)
287290
startX = prefs.get_int("startX", CameraSettingsActivity.startX_default)
288291
startY = prefs.get_int("startX", CameraSettingsActivity.startY_default)
289292
endX = prefs.get_int("startX", CameraSettingsActivity.endX_default)
@@ -447,7 +450,7 @@ def apply_camera_settings(cam, use_webcam):
447450
print("apply_camera_settings: Skipping (no camera or webcam mode)")
448451
return
449452

450-
prefs = SharedPreferences("com.micropythonos.camera")
453+
prefs = SharedPreferences(CameraApp.APPNAME)
451454

452455
try:
453456
# Basic image adjustments
@@ -628,7 +631,7 @@ def __init__(self):
628631

629632
def onCreate(self):
630633
# Load preferences
631-
prefs = SharedPreferences("com.micropythonos.camera")
634+
prefs = SharedPreferences(CameraApp.APPNAME)
632635

633636
# Detect platform (webcam vs ESP32)
634637
try:
@@ -1066,13 +1069,13 @@ def create_raw_tab(self, tab, prefs):
10661069
self.add_buttons(tab)
10671070

10681071
def erase_and_close(self):
1069-
SharedPreferences("com.micropythonos.camera").edit().remove_all().commit()
1072+
SharedPreferences(CameraApp.APPNAME).edit().remove_all().commit()
10701073
self.setResult(True, {"settings_changed": True})
10711074
self.finish()
10721075

10731076
def save_and_close(self):
10741077
"""Save all settings to SharedPreferences and return result."""
1075-
prefs = SharedPreferences("com.micropythonos.camera")
1078+
prefs = SharedPreferences(CameraApp.APPNAME)
10761079
editor = prefs.edit()
10771080

10781081
# Save all UI control values

0 commit comments

Comments
 (0)