mirror of
https://github.com/naruxde/revpimodio2.git
synced 2026-09-30 23:04:29 +02:00
feat: Add counter reset function to the MIO module
Due to the new firmware 1.10 on the MIO module, the GPIOs that were configured as counters can now also be reset to 0. With this change, the .reset() function in RevPiModIO is added to the respective counter IOs.
This commit is contained in:
1 parent
8e42527cd0
commit
79dd172f31
2 files changed
+24
-2
No files matched your search
@@ -354,8 +354,10 @@ class Device(object):
|
||||
elif bool(dict_io[key][7]):
|
||||
# Use IOBase for bit values
|
||||
io_new = IOBase(self, dict_io[key], iotype, "little", False)
|
||||
elif isinstance(self, DioModule) and dict_io[key][3] in self._lst_counter:
|
||||
# Counter IO on a DI or DIO
|
||||
elif (isinstance(self, DioModule) or isinstance(self, MioModule)) and dict_io[key][
|
||||
3
|
||||
] in self._lst_counter:
|
||||
# Counter IO on a DI, DIO or MIO module
|
||||
io_new = IntIOCounter(
|
||||
self._lst_counter.index(dict_io[key][3]),
|
||||
self,
|
||||
@@ -2030,6 +2032,23 @@ class DioModule(Device):
|
||||
super().__init__(parentmodio, dict_device, simulator=simulator)
|
||||
|
||||
|
||||
class MioModule(Device):
|
||||
"""Represents a MIO module."""
|
||||
|
||||
__slots__ = "_lst_counter"
|
||||
|
||||
def __init__(self, parentmodio, dict_device, simulator=False):
|
||||
"""
|
||||
Extended device class to recognize IntIOCounter.
|
||||
|
||||
:rev: :func:`Device.__init__()`
|
||||
"""
|
||||
# String list of byte addresses that are a counter.
|
||||
self._lst_counter = list(map(str, range(9, 17, 2)))
|
||||
|
||||
super().__init__(parentmodio, dict_device, simulator=simulator)
|
||||
|
||||
|
||||
class RoModule(Device):
|
||||
"""Relais output (RO) module with"""
|
||||
|
||||
|
||||
@@ -403,6 +403,9 @@ class RevPiModIO(object):
|
||||
elif pt == ProductType.RO:
|
||||
# RO
|
||||
dev_new = devicemodule.RoModule(self, device, simulator=self._simulator)
|
||||
elif pt == ProductType.MIO:
|
||||
# MIO
|
||||
dev_new = devicemodule.MioModule(self, device, simulator=self._simulator)
|
||||
else:
|
||||
# All other IO devices
|
||||
dev_new = devicemodule.Device(self, device, simulator=self._simulator)
|
||||
|
||||
Reference in new issue
Block a user