diff --git a/pi_mqtt_gpio/modules/mcp3008.py b/pi_mqtt_gpio/modules/mcp3008.py index 18c583a5464cf0437d45d56018208d85e7b72b85..75e1b0c62846468a1ecf987f7778848915102d22 100644 --- a/pi_mqtt_gpio/modules/mcp3008.py +++ b/pi_mqtt_gpio/modules/mcp3008.py @@ -9,35 +9,53 @@ SENSOR_SCHEMA = { required=False, empty=False, default="CH0", - allowed=["CH0", "CH1", "CH2", "CH3", "CH4", "CH5", "CH6", "CH7", - "DF0", "DF1", "DF2", "DF3", "DF4", "DF5", "DF6", "DF7"], + allowed=[ + "CH0", + "CH1", + "CH2", + "CH3", + "CH4", + "CH5", + "CH6", + "CH7", + "DF0", + "DF1", + "DF2", + "DF3", + "DF4", + "DF5", + "DF6", + "DF7", + ], ) } _LOG = logging.getLogger("mqtt_gpio") + class Sensor(GenericSensor): """ Implementation of MCP3008 ADC sensor. """ + def __init__(self, config): import Adafruit_MCP3008 import Adafruit_GPIO.SPI as SPI """init the mcp on SPI CE0""" - SPI_PORT = 0 + SPI_PORT = 0 SPI_DEVICE = 0 self.mcp = Adafruit_MCP3008.MCP3008(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE)) self.channels = { - "CH0": 0, - "CH1": 1, - "CH2": 2, - "CH3": 3, - "CH4": 4, - "CH5": 5, - "CH6": 6, - "CH7": 7 + "CH0": 0, + "CH1": 1, + "CH2": 2, + "CH3": 3, + "CH4": 4, + "CH5": 5, + "CH6": 6, + "CH7": 7, } def setup_sensor(self, config): @@ -55,4 +73,4 @@ class Sensor(GenericSensor): def cleanup(self): """close the adc, to proper shut down the spi bus""" - #self.adc.close() + # self.adc.close()