mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 09:40:36 +00:00
Add max_voltage property, ensure it is positive and cast to a float
This commit is contained in:
@@ -76,8 +76,10 @@ class AnalogInputDevice(SPIDevice):
|
||||
if bits is None:
|
||||
raise InputDeviceError('you must specify the bit resolution of the device')
|
||||
self._bits = bits
|
||||
if max_voltage <= 0:
|
||||
raise InputDeviceError('max_voltage must be positive')
|
||||
self._max_voltage = float(max_voltage)
|
||||
super(AnalogInputDevice, self).__init__(shared=True, **spi_args)
|
||||
self._max_voltage = max_voltage
|
||||
|
||||
@property
|
||||
def bits(self):
|
||||
@@ -104,6 +106,13 @@ class AnalogInputDevice(SPIDevice):
|
||||
"""
|
||||
return self._read()
|
||||
|
||||
@property
|
||||
def max_voltage(self):
|
||||
"""
|
||||
The voltage required to set the device's value to 1
|
||||
"""
|
||||
return self._max_voltage
|
||||
|
||||
@property
|
||||
def voltage(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user