Work around BCM8 edge detect/SPI issue for #1

This commit is contained in:
Phil Howard
2020-07-27 10:46:10 +01:00
parent f1ad8add15
commit de3816f917
3 changed files with 16 additions and 1 deletions

View File

@@ -34,7 +34,19 @@ class Moisture(object):
self._wet_point = wet_point if wet_point is not None else 0.7
self._dry_point = dry_point if dry_point is not None else 27.6
self._time_last_reading = time.time()
GPIO.add_event_detect(self._gpio_pin, GPIO.RISING, callback=self._event_handler, bouncetime=1)
try:
GPIO.add_event_detect(self._gpio_pin, GPIO.RISING, callback=self._event_handler, bouncetime=1)
except RuntimeError as e:
if self._gpio_pin == 8:
raise RuntimeError("""Unable to set up edge detection on BCM8.
Please ensure you add the following to /boot/config.txt and reboot:
dtoverlay=spi0-cs,cs0_pin=14 # Re-assign CS0 from BCM 8 so that Grow can use it
""")
else:
raise e
self._time_start = time.time()
self._total_count = 0

View File

@@ -64,4 +64,7 @@ commands =
printf "Setting up i2c and SPI..\n"
raspi-config nonint do_spi 0
raspi-config nonint do_i2c 0
configtxt =
dtoverlay=spi0-cs,cs0_pin=14 # Re-assign CS0 from BCM 8 so that Grow can use it