Skip to content

Commit

Permalink
Change the I2C timeout to a choice (#402)
Browse files Browse the repository at this point in the history
* Change the I2C timeout to a choice to reduce the number of options in the config editor

* Ensure /config exists before trying to save to it
  • Loading branch information
chrisib authored Jan 22, 2025
1 parent 74f4365 commit 2c2456a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
24 changes: 19 additions & 5 deletions software/firmware/europi_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def config_points(cls):
choices=[0, 1],
default=0,
danger=True,
),
),
configuration.choice(
name="DISPLAY_FREQUENCY",
choices=[
Expand Down Expand Up @@ -182,11 +182,25 @@ def config_points(cls):
],
default=100000,
),
configuration.integer(
configuration.choice(
name="EXTERNAL_I2C_TIMEOUT",
minimum=0,
maximum=5000,
default=1000
choices=[
# somewhat arbitrary subset of 0-5000
# this should cover a good range of use-cases
0,
1,
5,
10,
25,
50,
100,
250,
500,
1000,
2500,
5000,
],
default=1000,
),

# I/O voltage settings
Expand Down
7 changes: 7 additions & 0 deletions software/firmware/experimental/settings_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from experimental.knobs import KnobBank
from framebuf import FrameBuffer, MONO_HLSB
from machine import Timer
import os
import time


Expand Down Expand Up @@ -740,6 +741,12 @@ def save(self, settings_file):
data = {}
for item in self.menu_items_by_name.values():
data[item.config_point.name] = item.value_choice
try:
# ensure the /config directory exists
# save_to_file won't create it for us!
os.mkdir("config")
except OSError:
pass
ConfigFile.save_to_file(settings_file, data)
self.settings_dirty = False

Expand Down

0 comments on commit 2c2456a

Please sign in to comment.