Skip to content

Commit a657a3b

Browse files
Camera app: simplify by using same resolutions list
1 parent 5d100dc commit a657a3b

File tree

1 file changed

+5
-41
lines changed

1 file changed

+5
-41
lines changed

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

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -83,37 +83,9 @@ class CameraSettingsActivity(Activity):
8383
"raw_gma": False, # Disable gamma for better contrast
8484
}
8585

86-
# Resolution options for desktop/webcam
87-
# Now supports all ESP32 resolutions via automatic cropping/padding
88-
WEBCAM_RESOLUTIONS = [
89-
("96x96", "96x96"),
90-
("160x120", "160x120"),
91-
("128x128", "128x128"),
92-
("176x144", "176x144"),
93-
("240x176", "240x176"),
94-
("240x240", "240x240"),
95-
("320x240", "320x240"),
96-
("320x320", "320x320"),
97-
("400x296", "400x296"),
98-
("480x320", "480x320"),
99-
("480x480", "480x480"),
100-
("640x480", "640x480"),
101-
("640x640", "640x640"),
102-
("720x720", "720x720"),
103-
("800x600", "800x600"),
104-
("800x800", "800x800"),
105-
("960x960", "960x960"),
106-
("1024x768", "1024x768"),
107-
("1024x1024","1024x1024"),
108-
("1280x720", "1280x720"),
109-
("1280x1024", "1280x1024"),
110-
("1280x1280", "1280x1280"),
111-
("1600x1200", "1600x1200"),
112-
("1920x1080", "1920x1080"),
113-
]
114-
115-
# Resolution options for internal camera (ESP32)
116-
ESP32_RESOLUTIONS = [
86+
# Resolution options for both ESP32 and webcam
87+
# Webcam supports all ESP32 resolutions via automatic cropping/padding
88+
RESOLUTIONS = [
11789
("96x96", "96x96"),
11890
("160x120", "160x120"),
11991
("128x128", "128x128"),
@@ -153,19 +125,11 @@ def __init__(self):
153125
self.ui_controls = {}
154126
self.control_metadata = {} # Store pref_key and option_values for each control
155127
self.dependent_controls = {}
156-
self.is_webcam = False
157-
self.resolutions = []
158128

159129
def onCreate(self):
160130
self.use_webcam = self.getIntent().extras.get("use_webcam")
161131
self.prefs = self.getIntent().extras.get("prefs")
162132
self.scanqr_mode = self.getIntent().extras.get("scanqr_mode")
163-
if self.use_webcam:
164-
self.resolutions = self.WEBCAM_RESOLUTIONS
165-
print("Using webcam resolutions")
166-
else:
167-
self.resolutions = self.ESP32_RESOLUTIONS
168-
print("Using ESP32 camera resolutions")
169133

170134
# Create main screen
171135
screen = lv.obj()
@@ -350,14 +314,14 @@ def create_basic_tab(self, tab, prefs):
350314
dropdown_value = f"{current_resolution_width}x{current_resolution_height}"
351315
print(f"looking for {dropdown_value}")
352316
resolution_idx = 0
353-
for idx, (_, value) in enumerate(self.resolutions):
317+
for idx, (_, value) in enumerate(self.RESOLUTIONS):
354318
print(f"got {value}")
355319
if value == dropdown_value:
356320
resolution_idx = idx
357321
print(f"found it! {idx}")
358322
break
359323

360-
dropdown, cont = self.create_dropdown(tab, "Resolution:", self.resolutions, resolution_idx, "resolution")
324+
dropdown, cont = self.create_dropdown(tab, "Resolution:", self.RESOLUTIONS, resolution_idx, "resolution")
361325
self.ui_controls["resolution"] = dropdown
362326

363327
# Brightness

0 commit comments

Comments
 (0)