From ce87a29a949f29e46195deba8fbe67be9e842b7f Mon Sep 17 00:00:00 2001 From: Chris I-B Date: Sun, 5 Jul 2026 14:32:38 -0400 Subject: [PATCH] Fix some copy & paste errors with the autoselect feature, free up memory before saving the JSON file --- software/firmware/experimental/settings_menu.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/software/firmware/experimental/settings_menu.py b/software/firmware/experimental/settings_menu.py index fe5c4ae88..19baa630c 100644 --- a/software/firmware/experimental/settings_menu.py +++ b/software/firmware/experimental/settings_menu.py @@ -37,6 +37,8 @@ from experimental.knobs import KnobBank, LockableKnob from framebuf import FrameBuffer, MONO_HLSB from machine import Timer + +import gc import os import time @@ -389,7 +391,7 @@ def modify_choices(self, choices=None, new_default=None): # add the autoselect items, if needed if self.autoselect_knob: choices.append(AUTOSELECT_KNOB) - if self.autoselect_knob: + if self.autoselect_cv: choices.append(AUTOSELECT_AIN) self.config_point.choices = choices @@ -448,7 +450,7 @@ def get_option_list(self): # Add the autoselect inputs, if needed if self.autoselect_knob: items.append(AUTOSELECT_KNOB) - if self.autoselect_knob: + if self.autoselect_cv: items.append(AUTOSELECT_AIN) return items @@ -769,6 +771,11 @@ def save(self, settings_file): :param settings_file: The path to the JSON file to generate """ + # free up any fragmented memory before the dict-building + JSON + # serialization below, which can be a meaningful allocation on + # memory-constrained boards (e.g. the original RP2040 Pico) + gc.collect() + data = {} for item in self.menu_items_by_name.values(): data[item.config_point.name] = item.value_choice