Skip to content
Open
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
4 changes: 4 additions & 0 deletions firmware/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
BIP = (("A7", 50),)
BOP = (("C7", 50),)
SAD = (("G6", 100), ("C6", 200))
SAD_MAGNETIC = (("G6", 100), ("C6", 100), ("G6", 100), ("C6", 200))


# noinspection PyAttributeOutsideInit
Expand Down Expand Up @@ -86,6 +87,9 @@ def beep_bop(self):
def beep_sad(self):
self.buzzer.play(SAD)

def beep_sad_magnetic(self):
self.buzzer.play(SAD_MAGNETIC)

async def beep_wait(self):
await self.buzzer.wait()

Expand Down
9 changes: 8 additions & 1 deletion firmware/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,21 @@ async def take_reading(devices: hardware.HardwareBase,
# noinspection PyTypeChecker
cfg.calib.raise_if_anomaly(mag, grav, cfg.anomaly_strictness)
except tuple(ERROR_MESSAGES.keys()) as exc:
isMagneticError = False
for key in ERROR_MESSAGES.keys():
if isinstance(exc, key):
if (key == MagneticAnomalyError) or (key == DipAnomalyError):
isMagneticError = True
disp.show_big_info(ERROR_MESSAGES[key])
logger.info(f"Measurement error: {repr(exc)}")
if not isinstance(exc, asyncio.TimeoutError):
# don't wibble the laser if it's timed out, it'll just get more confused
devices.flash_laser(5,0.1)
devices.beep_sad()
if isMagneticError:
# spic17: send acoustic signal for magnetic error (this is relevant for the surveyor).
devices.beep_sad_magnetic()
else:
devices.beep_sad()
await asyncio.sleep(0)
return False
else:
Expand Down