20
20
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
# THE SOFTWARE.
22
22
"""
23
- `Adafruit_MCP4725`
24
- ====================================================
23
+ `adafruit_mcp4725` - MCP4725 digital to analog converter
24
+ ========================================================
25
25
26
26
CircuitPython module for the MCP4725 digital to analog converter. See
27
27
examples/simpletest.py for a demo of the usage.
35
35
36
36
37
37
# Internal constants:
38
- _MCP4725_DEFAULT_ADDRESS = const ( 0b01100010 )
38
+ _MCP4725_DEFAULT_ADDRESS = 0b01100010
39
39
_MCP4725_WRITE_FAST_MODE = const (0b00000000 )
40
40
41
41
42
42
class MCP4725 :
43
43
"""MCP4725 12-bit digital to analog converter. This class has a similar
44
- interface as the CircuitPython AnalogOut class and can be used in place
45
- of that module. To construct pass the following parameters to the
46
- initializer:
47
- - i2c: The I2C bus.
44
+ interface as the CircuitPython AnalogOut class and can be used in place
45
+ of that module.
48
46
49
- Optionally pass:
50
- - address: The address of the device if set differently from the default.
47
+ :param ~busio.I2C i2c: The I2C bus.
48
+ :param int address: The address of the device if set differently from the default.
51
49
"""
52
50
53
51
@@ -99,11 +97,12 @@ def _read(self):
99
97
100
98
@property
101
99
def value (self ):
102
- """Get and set the DAC value as a 16-bit unsigned value compatible
103
- with the AnalogOut class. Note that the MCP4725 is still just a 12-bit
104
- device so quantization will occur. If you'd like to instead deal with
105
- the raw 12-bit value use the raw_value property, or the normalized_value
106
- property to deal with a 0...1 float value.
100
+ """The DAC value as a 16-bit unsigned value compatible with the
101
+ :py:class:`~analogio.AnalogOut` class.
102
+
103
+ Note that the MCP4725 is still just a 12-bit device so quantization will occur. If you'd
104
+ like to instead deal with the raw 12-bit value use the raw_value property, or the
105
+ normalized_value property to deal with a 0...1 float value.
107
106
"""
108
107
raw_value = self ._read ()
109
108
# Scale up to 16-bit range.
@@ -118,9 +117,8 @@ def value(self, val):
118
117
119
118
@property
120
119
def raw_value (self ):
121
- """Get and set the DAC value as a 12-bit unsigned value. This is the
122
- the true resolution of the DAC and will never peform scaling or run
123
- into quantization error.
120
+ """The DAC value as a 12-bit unsigned value. This is the the true resolution of the DAC
121
+ and will never peform scaling or run into quantization error.
124
122
"""
125
123
return self ._read ()
126
124
@@ -130,8 +128,7 @@ def raw_value(self, val):
130
128
131
129
@property
132
130
def normalized_value (self ):
133
- """Get and set the DAC value as a floating point number in the range
134
- 0 to 1.0.
131
+ """The DAC value as a floating point number in the range 0.0 to 1.0.
135
132
"""
136
133
return self ._read ()/ 4095.0
137
134
0 commit comments