mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
Camera app: extract variable
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
- OSUpdate app: pause download when wifi is lost, resume when reconnected
|
- OSUpdate app: pause download when wifi is lost, resume when reconnected
|
||||||
- Settings app: fix un-checking of radio button
|
- Settings app: fix un-checking of radio button
|
||||||
- API: SharedPreferences: add erase_all() functionality
|
- API: SharedPreferences: add erase_all() functionality
|
||||||
|
- API: improve and cleanup animations
|
||||||
|
|
||||||
0.5.0
|
0.5.0
|
||||||
=====
|
=====
|
||||||
|
|||||||
@@ -15,14 +15,17 @@ class CameraApp(Activity):
|
|||||||
|
|
||||||
DEFAULT_WIDTH = 320 # 240 would be better but webcam doesn't support this (yet)
|
DEFAULT_WIDTH = 320 # 240 would be better but webcam doesn't support this (yet)
|
||||||
DEFAULT_HEIGHT = 240
|
DEFAULT_HEIGHT = 240
|
||||||
|
APPNAME = "com.micropythonos.camera"
|
||||||
|
#DEFAULT_CONFIG = "config.json"
|
||||||
|
#QRCODE_CONFIG = "config_qrmode.json"
|
||||||
|
|
||||||
button_width = 60
|
button_width = 60
|
||||||
button_height = 45
|
button_height = 45
|
||||||
colormode = False
|
colormode = False
|
||||||
|
|
||||||
status_label_text = "No camera found."
|
status_label_text = "No camera found."
|
||||||
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."
|
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."
|
||||||
status_label_text_found = "Decoding QR..."
|
status_label_text_found = "Found QR, trying to decode... hold still..."
|
||||||
|
|
||||||
cam = None
|
cam = None
|
||||||
current_cam_buffer = None # Holds the current memoryview to prevent garbage collection
|
current_cam_buffer = None # Holds the current memoryview to prevent garbage collection
|
||||||
@@ -167,7 +170,7 @@ class CameraApp(Activity):
|
|||||||
|
|
||||||
def load_resolution_preference(self):
|
def load_resolution_preference(self):
|
||||||
"""Load resolution preference from SharedPreferences and update width/height."""
|
"""Load resolution preference from SharedPreferences and update width/height."""
|
||||||
prefs = SharedPreferences("com.micropythonos.camera")
|
prefs = SharedPreferences(CameraApp.APPNAME)
|
||||||
resolution_str = prefs.get_string("resolution", f"{self.DEFAULT_WIDTH}x{self.DEFAULT_HEIGHT}")
|
resolution_str = prefs.get_string("resolution", f"{self.DEFAULT_WIDTH}x{self.DEFAULT_HEIGHT}")
|
||||||
self.colormode = prefs.get_bool("colormode", False)
|
self.colormode = prefs.get_bool("colormode", False)
|
||||||
try:
|
try:
|
||||||
@@ -283,7 +286,7 @@ class CameraApp(Activity):
|
|||||||
print("zoom_button_click is not supported for webcam")
|
print("zoom_button_click is not supported for webcam")
|
||||||
return
|
return
|
||||||
if self.cam:
|
if self.cam:
|
||||||
prefs = SharedPreferences("com.micropythonos.camera")
|
prefs = SharedPreferences(CameraApp.APPNAME)
|
||||||
startX = prefs.get_int("startX", CameraSettingsActivity.startX_default)
|
startX = prefs.get_int("startX", CameraSettingsActivity.startX_default)
|
||||||
startY = prefs.get_int("startX", CameraSettingsActivity.startY_default)
|
startY = prefs.get_int("startX", CameraSettingsActivity.startY_default)
|
||||||
endX = prefs.get_int("startX", CameraSettingsActivity.endX_default)
|
endX = prefs.get_int("startX", CameraSettingsActivity.endX_default)
|
||||||
@@ -447,7 +450,7 @@ def apply_camera_settings(cam, use_webcam):
|
|||||||
print("apply_camera_settings: Skipping (no camera or webcam mode)")
|
print("apply_camera_settings: Skipping (no camera or webcam mode)")
|
||||||
return
|
return
|
||||||
|
|
||||||
prefs = SharedPreferences("com.micropythonos.camera")
|
prefs = SharedPreferences(CameraApp.APPNAME)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Basic image adjustments
|
# Basic image adjustments
|
||||||
@@ -628,7 +631,7 @@ class CameraSettingsActivity(Activity):
|
|||||||
|
|
||||||
def onCreate(self):
|
def onCreate(self):
|
||||||
# Load preferences
|
# Load preferences
|
||||||
prefs = SharedPreferences("com.micropythonos.camera")
|
prefs = SharedPreferences(CameraApp.APPNAME)
|
||||||
|
|
||||||
# Detect platform (webcam vs ESP32)
|
# Detect platform (webcam vs ESP32)
|
||||||
try:
|
try:
|
||||||
@@ -1066,13 +1069,13 @@ class CameraSettingsActivity(Activity):
|
|||||||
self.add_buttons(tab)
|
self.add_buttons(tab)
|
||||||
|
|
||||||
def erase_and_close(self):
|
def erase_and_close(self):
|
||||||
SharedPreferences("com.micropythonos.camera").edit().remove_all().commit()
|
SharedPreferences(CameraApp.APPNAME).edit().remove_all().commit()
|
||||||
self.setResult(True, {"settings_changed": True})
|
self.setResult(True, {"settings_changed": True})
|
||||||
self.finish()
|
self.finish()
|
||||||
|
|
||||||
def save_and_close(self):
|
def save_and_close(self):
|
||||||
"""Save all settings to SharedPreferences and return result."""
|
"""Save all settings to SharedPreferences and return result."""
|
||||||
prefs = SharedPreferences("com.micropythonos.camera")
|
prefs = SharedPreferences(CameraApp.APPNAME)
|
||||||
editor = prefs.edit()
|
editor = prefs.edit()
|
||||||
|
|
||||||
# Save all UI control values
|
# Save all UI control values
|
||||||
|
|||||||
Reference in New Issue
Block a user