Skip to content

Commit

Permalink
corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Nov 18, 2023
1 parent ab679ba commit 18ba772
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions pioreactor/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
}


def is_i2c_device_present(channel):
def is_i2c_device_present(channel: int) -> bool:
if is_testing_env():
from pioreactor.utils.mock import MockI2C as I2C
else:
Expand All @@ -73,29 +73,32 @@ def is_i2c_device_present(channel):
return False


def is_DAC_present():
def is_DAC_present() -> bool:
return is_i2c_device_present(DAC)


def is_ADC_present():
def is_ADC_present() -> bool:
return is_i2c_device_present(ADC)


def is_heating_pcb_present():
def is_heating_pcb_present() -> bool:
return is_i2c_device_present(TEMP)


def is_HAT_present():
def is_HAT_present() -> bool:
if is_testing_env():
return True

with open("/proc/device-tree/hat/vendor", "r") as f:
vendor = f.readline().strip()
try:
with open("/proc/device-tree/hat/vendor", "r") as f:
vendor = f.readline().strip("\x00")

with open("/proc/device-tree/hat/product_id", "r") as f:
product_id = f.readline().strip()
with open("/proc/device-tree/hat/product_id", "r") as f:
product_id = f.readline().strip("\x00")

return vendor == "Pioreactor Inc." and product_id == "0x0001"
return vendor == "Pioreactor Inc." and product_id == "0x0001"
except FileNotFoundError:
return False


def round_to_precision(x: float, p: float) -> float:
Expand Down

0 comments on commit 18ba772

Please sign in to comment.