Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3f9ea91

Browse files
committed
Add additional ADC chips, close gpiozero#162
1 parent 7e2b002 commit 3f9ea91

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

gpiozero/input_devices.py

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,30 @@ def _send(self):
776776
return [16 + [8, 0][self.differential] + self.channel, 0, 0]
777777

778778

779+
class MCP3001(MCP3xxx):
780+
"""
781+
The `MCP3001`_ is a 10-bit analog to digital converter with 2 channels
782+
(0-3).
783+
784+
.. _MCP3001: http://www.farnell.com/datasheets/630400.pdf
785+
"""
786+
def __init__(self, device=0, differential=False):
787+
super(MCP3001, self).__init__(0, device, 10, differential)
788+
789+
790+
class MCP3002(MCP3xxx):
791+
"""
792+
The `MCP3002`_ is a 10-bit analog to digital converter with 2 channels
793+
(0-3).
794+
795+
.. _MCP3002: http://www.farnell.com/datasheets/1599363.pdf
796+
"""
797+
def __init__(self, channel=0, device=0, differential=False):
798+
if not 0 <= channel < 2:
799+
raise InputDeviceError('channel must be 0 or 1')
800+
super(MCP3002, self).__init__(channel, device, 10, differential)
801+
802+
779803
class MCP3004(MCP3xxx):
780804
"""
781805
The `MCP3004`_ is a 10-bit analog to digital converter with 4 channels
@@ -802,6 +826,30 @@ def __init__(self, channel=0, device=0, differential=False):
802826
super(MCP3008, self).__init__(channel, device, 10, differential)
803827

804828

829+
class MCP3201(MCP3xxx):
830+
"""
831+
The `MCP3201`_ is a 12-bit analog to digital converter with 2 channels
832+
(0-1).
833+
834+
.. _MCP3201: http://www.farnell.com/datasheets/1669366.pdf
835+
"""
836+
def __init__(self, device=0, differential=False):
837+
super(MCP3201, self).__init__(0, device, 12, differential)
838+
839+
840+
class MCP3202(MCP3xxx):
841+
"""
842+
The `MCP3202`_ is a 12-bit analog to digital converter with 2 channels
843+
(0-1).
844+
845+
.. _MCP3202: http://www.farnell.com/datasheets/1669376.pdf
846+
"""
847+
def __init__(self, channel=0, device=0, differential=False):
848+
if not 0 <= channel < 2:
849+
raise InputDeviceError('channel must be 0 or 1')
850+
super(MCP3202, self).__init__(channel, device, 12, differential)
851+
852+
805853
class MCP3204(MCP3xxx):
806854
"""
807855
The `MCP3204`_ is a 12-bit analog to digital converter with 4 channels
@@ -873,4 +921,3 @@ def __init__(self, channel=0, device=0, differential=False):
873921
if not 0 <= channel < 8:
874922
raise InputDeviceError('channel must be between 0 and 7')
875923
super(MCP3304, self).__init__(channel, device, differential)
876-

0 commit comments

Comments
 (0)