@@ -43,19 +43,19 @@ def __init__(self):
4343 ]
4444 self .settings = [
4545 # Basic settings, alphabetically:
46- {"title" : "Light/Dark Theme" , "key" : "theme_light_dark" , "value_label" : None , "cont" : None , " ui" : "radiobuttons" , "ui_options" : [("Light" , "light" ), ("Dark" , "dark" )], "changed_callback" : self .theme_changed },
47- {"title" : "Theme Color" , "key" : "theme_primary_color" , "value_label" : None , "cont" : None , " placeholder" : "HTML hex color, like: EC048C" , "ui" : "dropdown" , "ui_options" : theme_colors , "changed_callback" : self .theme_changed },
48- {"title" : "Timezone" , "key" : "timezone" , "value_label" : None , "cont" : None , " ui" : "dropdown" , "ui_options" : self . get_timezone_tuples () , "changed_callback" : lambda * args : mpos .time .refresh_timezone_preference ()},
46+ {"title" : "Light/Dark Theme" , "key" : "theme_light_dark" , "ui" : "radiobuttons" , "ui_options" : [("Light" , "light" ), ("Dark" , "dark" )], "changed_callback" : self .theme_changed },
47+ {"title" : "Theme Color" , "key" : "theme_primary_color" , "placeholder" : "HTML hex color, like: EC048C" , "ui" : "dropdown" , "ui_options" : theme_colors , "changed_callback" : self .theme_changed },
48+ {"title" : "Timezone" , "key" : "timezone" , "ui" : "dropdown" , "ui_options" : [( tz , tz ) for tz in mpos . time . get_timezones ()] , "changed_callback" : lambda * args : mpos .time .refresh_timezone_preference ()},
4949 # Advanced settings, alphabetically:
50- #{"title": "Audio Output Device", "key": "audio_device", "value_label": None, "cont": None, " ui": "radiobuttons", "ui_options": [("Auto-detect", "auto"), ("I2S (Digital Audio)", "i2s"), ("Buzzer (PWM Tones)", "buzzer"), ("Both I2S and Buzzer", "both"), ("Disabled", "null")], "changed_callback": self.audio_device_changed},
51- {"title" : "Auto Start App" , "key" : "auto_start_app" , "value_label" : None , "cont" : None , " ui" : "radiobuttons" , "ui_options" : [(app .name , app .fullname ) for app in PackageManager .get_app_list ()]},
52- {"title" : "Check IMU Calibration" , "key" : "check_imu_calibration" , "value_label" : None , "cont" : None , " ui" : "activity" , "activity_class" : CheckIMUCalibrationActivity },
53- {"title" : "Calibrate IMU" , "key" : "calibrate_imu" , "value_label" : None , "cont" : None , " ui" : "activity" , "activity_class" : CalibrateIMUActivity },
50+ #{"title": "Audio Output Device", "key": "audio_device", "ui": "radiobuttons", "ui_options": [("Auto-detect", "auto"), ("I2S (Digital Audio)", "i2s"), ("Buzzer (PWM Tones)", "buzzer"), ("Both I2S and Buzzer", "both"), ("Disabled", "null")], "changed_callback": self.audio_device_changed},
51+ {"title" : "Auto Start App" , "key" : "auto_start_app" , "ui" : "radiobuttons" , "ui_options" : [(app .name , app .fullname ) for app in PackageManager .get_app_list ()]},
52+ {"title" : "Check IMU Calibration" , "key" : "check_imu_calibration" , "ui" : "activity" , "activity_class" : CheckIMUCalibrationActivity },
53+ {"title" : "Calibrate IMU" , "key" : "calibrate_imu" , "ui" : "activity" , "activity_class" : CalibrateIMUActivity },
5454 # Expert settings, alphabetically
55- {"title" : "Restart to Bootloader" , "key" : "boot_mode" , "dont_persist" : True , "value_label" : None , "cont" : None , " ui" : "radiobuttons" , "ui_options" : [("Normal" , "normal" ), ("Bootloader" , "bootloader" )], "changed_callback" : self .reset_into_bootloader },
56- {"title" : "Format internal data partition" , "key" : "format_internal_data_partition" , "dont_persist" : True , "value_label" : None , "cont" : None , " ui" : "radiobuttons" , "ui_options" : [("No, do not format" , "no" ), ("Yes, erase all settings, files and non-builtin apps" , "yes" )], "changed_callback" : self .format_internal_data_partition },
55+ {"title" : "Restart to Bootloader" , "key" : "boot_mode" , "dont_persist" : True , "ui" : "radiobuttons" , "ui_options" : [("Normal" , "normal" ), ("Bootloader" , "bootloader" )], "changed_callback" : self .reset_into_bootloader },
56+ {"title" : "Format internal data partition" , "key" : "format_internal_data_partition" , "dont_persist" : True , "ui" : "radiobuttons" , "ui_options" : [("No, do not format" , "no" ), ("Yes, erase all settings, files and non-builtin apps" , "yes" )], "changed_callback" : self .format_internal_data_partition },
5757 # This is currently only in the drawer but would make sense to have it here for completeness:
58- #{"title": "Display Brightness", "key": "display_brightness", "value_label": None, "cont": None, " placeholder": "A value from 0 to 100."},
58+ #{"title": "Display Brightness", "key": "display_brightness", "placeholder": "A value from 0 to 100."},
5959 # Maybe also add font size (but ideally then all fonts should scale up/down)
6060 ]
6161
@@ -70,7 +70,6 @@ def onCreate(self):
7070 def onResume (self , screen ):
7171 # reload settings because the SettingsActivity might have changed them - could be optimized to only load if it did:
7272 self .prefs = mpos .config .SharedPreferences ("com.micropythonos.settings" )
73- #wallet_type = self.prefs.get_string("wallet_type") # unused
7473
7574 # Create settings entries
7675 screen .clean ()
@@ -124,38 +123,6 @@ def startSettingActivity(self, setting):
124123 intent .putExtra ("prefs" , self .prefs )
125124 self .startActivity (intent )
126125
127- @staticmethod
128- def get_timezone_tuples ():
129- return [(tz , tz ) for tz in mpos .time .get_timezones ()]
130-
131- def audio_device_changed (self ):
132- """
133- Called when audio device setting changes.
134- Note: Changing device type at runtime requires a restart for full effect.
135- AudioFlinger initialization happens at boot.
136- """
137- import mpos .audio .audioflinger as AudioFlinger
138-
139- new_value = self .prefs .get_string ("audio_device" , "auto" )
140- print (f"Audio device setting changed to: { new_value } " )
141- print ("Note: Restart required for audio device change to take effect" )
142-
143- # Map setting values to device types
144- device_map = {
145- "auto" : AudioFlinger .get_device_type (), # Keep current
146- "i2s" : AudioFlinger .DEVICE_I2S ,
147- "buzzer" : AudioFlinger .DEVICE_BUZZER ,
148- "both" : AudioFlinger .DEVICE_BOTH ,
149- "null" : AudioFlinger .DEVICE_NULL ,
150- }
151-
152- desired_device = device_map .get (new_value , AudioFlinger .get_device_type ())
153- current_device = AudioFlinger .get_device_type ()
154-
155- if desired_device != current_device :
156- print (f"Desired device type ({ desired_device } ) differs from current ({ current_device } )" )
157- print ("Full device type change requires restart - current session continues with existing device" )
158-
159126 def focus_container (self , container ):
160127 print (f"container { container } focused, setting border..." )
161128 container .set_style_border_color (lv .theme_get_color_primary (None ),lv .PART .MAIN )
@@ -166,6 +133,8 @@ def defocus_container(self, container):
166133 print (f"container { container } defocused, unsetting border..." )
167134 container .set_style_border_width (0 , lv .PART .MAIN )
168135
136+
137+ # Change handlers:
169138 def reset_into_bootloader (self , new_value ):
170139 if new_value is not "bootloader" :
171140 return
0 commit comments