Skip to content

Commit 1b0eb8d

Browse files
Add colormode option and move special effect to advanced tab
1 parent 6b8b72a commit 1b0eb8d

File tree

1 file changed

+17
-11
lines changed
  • internal_filesystem/apps/com.micropythonos.camera/assets

1 file changed

+17
-11
lines changed

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

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CameraApp(Activity):
2525

2626
button_width = 60
2727
button_height = 45
28-
graymode = True
28+
colormode = False
2929

3030
status_label_text = "No camera found."
3131
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."
@@ -56,6 +56,7 @@ def load_resolution_preference(self):
5656
"""Load resolution preference from SharedPreferences and update width/height."""
5757
prefs = SharedPreferences("com.micropythonos.camera")
5858
resolution_str = prefs.get_string("resolution", f"{self.DEFAULT_WIDTH}x{self.DEFAULT_HEIGHT}")
59+
self.colormode = prefs.get_bool("colormode", False)
5960
try:
6061
width_str, height_str = resolution_str.split('x')
6162
self.width = int(width_str)
@@ -397,8 +398,8 @@ def try_capture(self, event):
397398
self.image_dsc.data = self.current_cam_buffer
398399
#image.invalidate() # does not work so do this:
399400
self.image.set_src(self.image_dsc)
400-
#if not self.use_webcam:
401-
# self.cam.free_buffer() # Free the old buffer
401+
if not self.use_webcam:
402+
self.cam.free_buffer() # Free the old buffer
402403
try:
403404
if self.keepliveqrdecoding:
404405
self.qrdecode_one()
@@ -882,6 +883,11 @@ def create_basic_tab(self, tab, prefs):
882883
#tab.set_scrollbar_mode(lv.SCROLLBAR_MODE.AUTO)
883884
tab.set_style_pad_all(1, 0)
884885

886+
# Color Mode
887+
colormode = prefs.get_bool("colormode", False)
888+
checkbox, cont = self.create_checkbox(tab, "Color Mode (slower)", colormode, "colormode")
889+
self.ui_controls["colormode"] = checkbox
890+
885891
# Resolution dropdown
886892
current_resolution = prefs.get_string("resolution", "320x240")
887893
resolution_idx = 0
@@ -918,6 +924,14 @@ def create_basic_tab(self, tab, prefs):
918924
checkbox, cont = self.create_checkbox(tab, "Vertical Flip", vflip, "vflip")
919925
self.ui_controls["vflip"] = checkbox
920926

927+
self.add_buttons(tab)
928+
929+
def create_advanced_tab(self, tab, prefs):
930+
"""Create Advanced settings tab."""
931+
#tab.set_scrollbar_mode(lv.SCROLLBAR_MODE.AUTO)
932+
tab.set_flex_flow(lv.FLEX_FLOW.COLUMN)
933+
tab.set_style_pad_all(1, 0)
934+
921935
# Special Effect
922936
special_effect_options = [
923937
("None", 0), ("Negative", 1), ("Grayscale", 2),
@@ -928,14 +942,6 @@ def create_basic_tab(self, tab, prefs):
928942
special_effect, "special_effect")
929943
self.ui_controls["special_effect"] = dropdown
930944

931-
self.add_buttons(tab)
932-
933-
def create_advanced_tab(self, tab, prefs):
934-
"""Create Advanced settings tab."""
935-
#tab.set_scrollbar_mode(lv.SCROLLBAR_MODE.AUTO)
936-
tab.set_flex_flow(lv.FLEX_FLOW.COLUMN)
937-
tab.set_style_pad_all(1, 0)
938-
939945
# Auto Exposure Control (master switch)
940946
exposure_ctrl = prefs.get_bool("exposure_ctrl", True)
941947
aec_checkbox, cont = self.create_checkbox(tab, "Auto Exposure", exposure_ctrl, "exposure_ctrl")

0 commit comments

Comments
 (0)