File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -72,11 +72,12 @@ class AnalogInputDevice(SPIDevice):
7272 .. _analog to digital converters: https://en.wikipedia.org/wiki/Analog-to-digital_converter
7373 """
7474
75- def __init__ (self , bits = None , ** spi_args ):
75+ def __init__ (self , bits = None , max_voltage = 3.3 , ** spi_args ):
7676 if bits is None :
7777 raise InputDeviceError ('you must specify the bit resolution of the device' )
7878 self ._bits = bits
7979 super (AnalogInputDevice , self ).__init__ (shared = True , ** spi_args )
80+ self ._max_voltage = max_voltage
8081
8182 @property
8283 def bits (self ):
@@ -103,6 +104,13 @@ def raw_value(self):
103104 """
104105 return self ._read ()
105106
107+ @property
108+ def voltage (self ):
109+ """
110+ The current voltage read from the device
111+ """
112+ return self .value * self ._max_voltage
113+
106114
107115class MCP3xxx (AnalogInputDevice ):
108116 """
You can’t perform that action at this time.
0 commit comments