Yet Another WebIOPi+
Main Page
Related Pages
Packages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Macros
Pages
python
webiopi
devices
analog
mcp4725.py
Go to the documentation of this file.
1
# Copyright 2012-2013 Eric Ptak - trouch.com
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
# http://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14
15
from
webiopi.utils.types
import
toint
16
from
webiopi.devices.i2c
import
I2C
17
from
webiopi.devices.analog
import
DAC
18
19
20
class
MCP4725
(
DAC
,
I2C
):
21
def
__init__
(self, slave=0x60, vref=3.3):
22
I2C.__init__(self,
toint
(slave))
23
DAC.__init__(self, 1, 12, float(vref))
24
25
def
__str__
(self):
26
return
"MCP4725(slave=0x%02X)"
% self.
slave
27
28
def
__analogRead__
(self, channel, diff=False):
29
d = self.
readBytes
(3)
30
value = (d[1] << 8 | d[2]) >> 4
31
return
value
32
33
34
def
__analogWrite__
(self, channel, value):
35
d = bytearray(2)
36
d[0] = (value >> 8) & 0x0F
37
d[1] = value & 0xFF
38
self.
writeBytes
(d)
webiopi.utils.types
Definition:
types.py:1
webiopi.devices.analog.mcp4725.MCP4725.__str__
def __str__
Definition:
mcp4725.py:25
webiopi.devices.analog
Definition:
__init__.py:1
webiopi.devices.analog.DAC
Definition:
__init__.py:101
webiopi.devices.analog.mcp4725.MCP4725
Definition:
mcp4725.py:20
webiopi.devices.bus.Bus.writeBytes
def writeBytes
Definition:
bus.py:112
webiopi.devices.i2c.I2C.slave
slave
Definition:
i2c.py:53
webiopi.devices.analog.mcp4725.MCP4725.__analogWrite__
def __analogWrite__
Definition:
mcp4725.py:34
webiopi.devices.i2c.I2C
Definition:
i2c.py:46
webiopi.devices.i2c
Definition:
i2c.py:1
webiopi.devices.analog.mcp4725.MCP4725.__analogRead__
def __analogRead__
Definition:
mcp4725.py:28
webiopi.devices.analog.mcp4725.MCP4725.__init__
def __init__
Definition:
mcp4725.py:21
webiopi.utils.types.toint
def toint
Definition:
types.py:16
webiopi.devices.bus.Bus.readBytes
def readBytes
Definition:
bus.py:101
Generated on Sat Sep 10 2016 09:36:55 for Yet Another WebIOPi+ by
1.8.8