forked from platypush/platypush
LINT fixes for LCD plugins
This commit is contained in:
parent
40269ddaad
commit
5d2e74eb97
3 changed files with 6 additions and 18 deletions
|
@ -1,16 +1,9 @@
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from enum import Enum
|
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from platypush.plugins import Plugin, action
|
from platypush.plugins import Plugin, action
|
||||||
|
|
||||||
|
|
||||||
class PinMode(Enum):
|
|
||||||
import RPi.GPIO
|
|
||||||
BOARD = RPi.GPIO.BOARD
|
|
||||||
BCM = RPi.GPIO.BCM
|
|
||||||
|
|
||||||
|
|
||||||
class LcdPlugin(Plugin, ABC):
|
class LcdPlugin(Plugin, ABC):
|
||||||
"""
|
"""
|
||||||
Abstract class for plugins to communicate with LCD displays.
|
Abstract class for plugins to communicate with LCD displays.
|
||||||
|
@ -21,23 +14,20 @@ class LcdPlugin(Plugin, ABC):
|
||||||
* **RPi.GPIO** (``pip install RPi.GPIO``)
|
* **RPi.GPIO** (``pip install RPi.GPIO``)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import RPLCD.lcd
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.lcd = None
|
self.lcd = None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_pin_mode(pin_mode: str) -> int:
|
def _get_pin_mode(pin_mode: str) -> int:
|
||||||
|
import RPi.GPIO
|
||||||
|
pin_modes = ['BOARD', 'BCM']
|
||||||
pin_mode = pin_mode.upper()
|
pin_mode = pin_mode.upper()
|
||||||
assert hasattr(PinMode, pin_mode), \
|
assert pin_mode in pin_modes, 'Invalid pin_mode: {}. Supported modes: {}'.format(pin_mode, pin_modes)
|
||||||
'Invalid pin_mode: {}. Supported modes: {}'.format(
|
return getattr(RPi.GPIO, pin_mode).value
|
||||||
pin_mode, list([mode.name for mode in PinMode if mode.name != 'RPi']))
|
|
||||||
|
|
||||||
return getattr(PinMode, pin_mode).value
|
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def _get_lcd(self) -> RPLCD.lcd.BaseCharLCD:
|
def _get_lcd(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _init_lcd(self):
|
def _init_lcd(self):
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from platypush.plugins import action
|
|
||||||
from platypush.plugins.lcd import LcdPlugin
|
from platypush.plugins.lcd import LcdPlugin
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from typing import List, Optional
|
from typing import Optional
|
||||||
|
|
||||||
from platypush.plugins import action
|
|
||||||
from platypush.plugins.lcd import LcdPlugin
|
from platypush.plugins.lcd import LcdPlugin
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue