Re-index channels from 1

This commit is contained in:
Phil Howard
2020-05-21 11:43:40 +01:00
parent c054a0a5b4
commit 605d6fdc47
3 changed files with 47 additions and 12 deletions

View File

@@ -7,12 +7,22 @@ PUMP_1_PIN = 17
PUMP_2_PIN = 27
PUMP_3_PIN = 22
PUMP_PWM_FREQ = 10000
PUMP_MAX_DUTY = 60
PUMP_MAX_DUTY = 90
class Pump(object):
def __init__(self, channel):
self._gpio_pin = [PUMP_1_PIN, PUMP_2_PIN, PUMP_3_PIN][channel]
"""Grow pump driver."""
def __init__(self, channel=1):
"""Create a new pump.
Uses soft PWM to drive a Grow pump.
:param channel: One of 1, 2 or 3.
"""
self._gpio_pin = [PUMP_1_PIN, PUMP_2_PIN, PUMP_3_PIN][channel - 1]
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
@@ -37,7 +47,7 @@ class Pump(object):
"""Stop the pump."""
self.set_speed(0)
def pulse(self, speed, timeout=0.1, blocking=True, force=False):
def dose(self, speed, timeout=0.1, blocking=True, force=False):
"""Pulse the pump for timeout seconds.
:param timeout: Timeout, in seconds, of the pump pulse