Skip to content

Commit 630268e

Browse files
committed
remove RPi.GPIO and gpiozero compatibility for now
1 parent d28ab7c commit 630268e

File tree

3 files changed

+2
-146
lines changed

3 files changed

+2
-146
lines changed

gpio_expander.py

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -66,88 +66,6 @@
6666
_CONFIG_REGISTER = const(3)
6767

6868

69-
class RWDependentBit(RWBit):
70-
"""A default descriptor """
71-
dependent_bit: RWBit
72-
73-
def __init__(
74-
self,
75-
register_address: int,
76-
bit: int,
77-
78-
flag: bool,
79-
register_width: int = 1,
80-
lsb_first: bool = True
81-
) -> None:
82-
super(RWDependentBit, self).__init__(register_address, bit, register_width, lsb_first)
83-
# self.__dependent_bit = dependent_bit
84-
self.__flag = flag
85-
86-
def __set__(self, obj: I2CDeviceDriver, value: bool):
87-
# Pin can be set only when configuration dependent bit is equal to 0.
88-
if self.__flag != self.dependent_bit: # self.__dependent_bit:
89-
raise AttributeError("Pin not configured as output.")
90-
else:
91-
super(RWDependentBit, self).__set__(obj, value)
92-
93-
94-
class _I2cGpio:
95-
96-
def __init__(self, input_reg: ROBit, output_reg: RWDependentBit, polarity_reg: RWBit, cfg_reg: RWBit):
97-
self.__input_reg = input_reg
98-
self.__output_reg = output_reg
99-
self.__polarity_reg = polarity_reg
100-
self.__cfg_reg = cfg_reg
101-
102-
def _get_value(self) -> bool:
103-
# If a bit in configuration register is set to 1, the corresponding port pin is enabled as an input.
104-
# If a bit in this register is cleared to 0, the corresponding port pin is enabled as an output.
105-
if self.__cfg_reg:
106-
self.value = self.__input_reg
107-
else:
108-
self.value = self.__output_reg
109-
return self.value
110-
111-
# gpiozero InputDevice and OutputDevice compatible interfaces
112-
@property
113-
def value(self) -> bool:
114-
# The Input Port registers reflect the incoming logic levels of the pins, regardless of whether the pin is
115-
# defined as an input or an output by the Configuration register.
116-
return self.__input_reg
117-
118-
@value.setter
119-
def value(self, new_val: bool) -> None:
120-
self.__output_reg = new_val
121-
122-
def is_active(self):
123-
return self.value
124-
125-
@property
126-
def active_high(self):
127-
pass
128-
129-
@active_high.setter
130-
def active_high(self, value):
131-
pass
132-
133-
def on(self):
134-
pass
135-
136-
def off(self):
137-
pass
138-
139-
def toggle(self):
140-
pass
141-
142-
@property
143-
def configure(self) -> bool:
144-
return self.__cfg_reg
145-
146-
@configure.setter
147-
def configure(self, new_value: bool) -> None:
148-
self.__cfg_reg = new_value
149-
150-
15169
def _get_registry_params(value, x):
15270
_name = ""
15371
_reg_address_multiplier = 1
@@ -188,14 +106,8 @@ def __new__(mcs, clsname, bases, dct, *args, **kwargs):
188106
_cfg_reg = RWBit(_CONFIG_REGISTER * _reg_address_multiplier + _adder, _idx)
189107
_input_reg = ROBit(_INPUT_PORT * _reg_address_multiplier + _adder, _idx)
190108
_output_reg = RWBit(_OUTPUT_PORT * _reg_address_multiplier + _adder, _idx)
191-
# RWDependentBit(_OUTPUT_PORT * _reg_address_multiplier + _adder, _idx,
192-
# _cfg_reg, False)
193109
_polarity_reg = RWBit(_POLARITY_REGISTER * _reg_address_multiplier + _adder, _idx)
194110

195-
# GPIO object
196-
# prop_name = f"GPIO{x}"
197-
# result_dct[prop_name] = _I2cGpio(_input_reg, _output_reg, _polarity_reg, _cfg_reg)
198-
199111
# REGISTRY 0 and 1 INPUT PORT
200112
prop_name = f"I{_name}{_idx}"
201113
result_dct[prop_name] = _input_reg
@@ -223,23 +135,6 @@ def __init__(self, i2c_bus: I2C, address: int, **kwargs) -> None:
223135
def max_gpios(self):
224136
return getattr(self, '_NUM_GPIO')
225137

226-
# RPi.GPIO compatible interface
227-
def setmode(self, gpio: int) -> None:
228-
# Does nothing, pin already configured.
229-
pass
230-
231-
def setup(self, gpio: int, mode: bool) -> None:
232-
_name, _, _, _idx = _get_registry_params(self.max_gpios(), gpio)
233-
setattr(self, f"C{_name}{_idx}", mode)
234-
235-
def input(self, gpio: int) -> bool:
236-
_name, _, _, _idx = _get_registry_params(self.max_gpios(), gpio)
237-
return getattr(self, f"I{_name}{_idx}")
238-
239-
def output(self, gpio: int, _value: bool) -> None:
240-
_name, _, _, _idx = _get_registry_params(self.max_gpios(), gpio)
241-
setattr(self, f"O{_name}{_idx}", _value)
242-
243138

244139
# PCA series
245140
class PCA9534(BaseGPIOExpander):

poetry.lock

Lines changed: 2 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
Adafruit-Blinka = "^8.5.0"
2525
adafruit-circuitpython-busdevice = "^5.2.3"
2626
adafruit-circuitpython-register = "^1.9.14"
27-
gpiozero = "^1.6.2"
2827

2928

3029
[tool.poetry.group.devel]

0 commit comments

Comments
 (0)