Skip to content

Removing sys.exit calls and sys dependency from Alvik #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions arduino_alvik/arduino_alvik.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
import struct
from machine import I2C
import _thread
Expand Down Expand Up @@ -231,12 +230,15 @@ def _idle(self, delay_=1, check_on_thread=False, blocking=False) -> None:
self.i2c.set_single_thread(False)
if self.is_on():
print("\n********** Alvik is on **********")
except KeyboardInterrupt:
except KeyboardInterrupt as e:
self.stop()
sys.exit()
except Exception as e:
pass
raise e
except OSError as e:
print(f'\nUnable to read SOC: {e}')
raise e
except Exception as e:
print(f'\nUnhandled exception: {e} {type(e)}')
raise e
finally:
LEDR.value(1)
LEDG.value(1)
Expand Down Expand Up @@ -285,8 +287,8 @@ def begin(self) -> int:
self._snake_robot(1000)
self._wait_for_ack()
if not self._wait_for_fw_check():
print('\n********** PLEASE UPDATE ALVIK FIRMWARE (required: '+'.'.join(map(str,self._required_fw_version))+')! Check documentation **********\n')
sys.exit(-2)
self.stop()
raise Exception('\n********** PLEASE UPDATE ALVIK FIRMWARE (required: '+'.'.join(map(str,self._required_fw_version))+')! Check documentation **********\n')
self._snake_robot(2000)
self.set_illuminator(True)
self.set_behaviour(1)
Expand Down
3 changes: 1 addition & 2 deletions examples/communication/modulino.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
pixels = ModulinoPixels(alvik.i2c)

if not pixels.connected:
print("🤷 No pixel modulino found")
sys.exit(-2)
raise Exception("🤷 No pixel modulino found")

while True:
try:
Expand Down