Skip to content

Commit

Permalink
Remove hexpansion format prompt and be more tolerant of multiple inse…
Browse files Browse the repository at this point in the history
…rtion. Reduce time to 4 seconds
  • Loading branch information
MatthewWilkes committed Jun 2, 2024
1 parent 3994c6b commit 871ddae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions modules/frontboards/twentyfour.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ async def background_task(self):
while True:
booped = not machine.Pin(0, mode=machine.Pin.IN).value()
tildagonos.read_egpios()
print(booped)
if booped:
now = time.ticks_ms()
for i, gpio in enumerate(
Expand All @@ -48,12 +47,13 @@ async def background_task(self):
button_down = not tildagonos.check_egpio_state(
gpio, readgpios=False
)
# print(i, now, state)
if button_down and state is None:
print(f"Down {i}")
hexpansion_states[i + 1] = now
await eventbus.emit_async(HexpansionInsertionEvent(port=i + 1))
elif state and time.ticks_diff(now, state) > 5000:
elif state and time.ticks_diff(now, state) > 4000:
hexpansion_states[i + 1] = None
# print(f"Removing {i}")
await eventbus.emit_async(HexpansionRemovalEvent(port=i + 1))
else:
for button, pin in self.BUTTON_PINS.items():
Expand Down
9 changes: 5 additions & 4 deletions modules/system/hexpansion/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,19 @@ def _format_eeprom(self, eep):
def _mount_eeprom(self, eep, port):
mountpoint = f"/hexpansion_{port}"

print(mountpoint, os.listdir())
if mountpoint in os.listdir():
try:
# This is mounted already, unmount first
vfs.umount(mountpoint)
except OSError:
pass

try:
print(f"Attempting to mount i2c eeprom from hexpansion port {port}")
vfs.mount(eep, mountpoint)
except Exception as e:
print(f"Failed to mount: {e}")
self.format_requests.append((eep, port))
eventbus.emit(RequestForegroundPushEvent(self))
# self.format_requests.append((eep, port))
# eventbus.emit(RequestForegroundPushEvent(self))
return

self.mountpoints[port] = mountpoint
Expand Down

0 comments on commit 871ddae

Please sign in to comment.