-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow running without physical hardware
- Loading branch information
Showing
4 changed files
with
96 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"""GPIO interface""" | ||
|
||
from abc import ABC, abstractmethod | ||
|
||
|
||
class GPioIf(ABC): | ||
"""Base abstract class for GPIO operations""" | ||
|
||
@property | ||
@abstractmethod | ||
def HIGH(self) -> int: # pylint: disable=invalid-name | ||
"""HIGH level""" | ||
|
||
@property | ||
@abstractmethod | ||
def LOW(self) -> int: # pylint: disable=invalid-name | ||
"""LOW level""" | ||
|
||
@abstractmethod | ||
def input(self, pin: int) -> bool: | ||
"""Read pin and return logical HIGH/LOW level""" | ||
|
||
@abstractmethod | ||
def output(self, pin: int, signal: int): | ||
"""Set pin to HIGH/LOW logical level""" | ||
|
||
|
||
class GPioNoOp(GPioIf): | ||
"""GPIO noop""" | ||
|
||
def __init__(self, pins): | ||
self.pins = pins | ||
|
||
@property | ||
def HIGH(self): | ||
return 1 | ||
|
||
@property | ||
def LOW(self): | ||
return 0 | ||
|
||
def input(self, _: int) -> bool: | ||
return False | ||
|
||
def output(self, _: int, __: int): | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters