Skip to content

Commit

Permalink
Accept unit classes in motor groups (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
WasabiFan authored Jul 29, 2018
1 parent ecfbc29 commit caa01ad
Show file tree
Hide file tree
Showing 7 changed files with 220 additions and 113 deletions.
1 change: 1 addition & 0 deletions docs/motors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Most methods which run motors with accept a ``speed`` or ``speed_pct`` argument.

.. autoclass:: SpeedInteger
.. autoclass:: SpeedPercent
.. autoclass:: SpeedNativeUnits
.. autoclass:: SpeedRPS
.. autoclass:: SpeedRPM
.. autoclass:: SpeedDPS
Expand Down
3 changes: 3 additions & 0 deletions ev3dev2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ def matches(attribute, pattern):
yield f


def library_load_warning_message(library_name, dependent_class):
return 'Import warning: Failed to import "{}". {} will be unusable!'.format(library_name, dependent_class)

class DeviceNotFound(Exception):
pass

Expand Down
18 changes: 14 additions & 4 deletions ev3dev2/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,26 @@

import array
import time
import evdev
from . import get_current_platform
import logging
from . import get_current_platform, library_load_warning_message

log = logging.getLogger(__name__)

try:
# This is a linux-specific module.
# It is required by the Button() class, but failure to import it may be
# It is required by the Button class, but failure to import it may be
# safely ignored if one just needs to run API tests on Windows.
import fcntl
except ImportError:
print("WARNING: Failed to import fcntl. Button class will be unuseable!")
log.warning(library_load_warning_message("fcntl", "Button"))

try:
# This is a linux-specific module.
# It is required by the Button class, but failure to import it may be
# safely ignored if one just needs to run API tests on Windows.
import evdev
except ImportError:
log.warning(library_load_warning_message("evdev", "Button"))


# Import the button filenames, this is platform specific
Expand Down
7 changes: 5 additions & 2 deletions ev3dev2/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,21 @@
import os
import mmap
import ctypes
import logging
from PIL import Image, ImageDraw
from . import fonts
from . import get_current_platform
from . import get_current_platform, library_load_warning_message
from struct import pack

log = logging.getLogger(__name__)

try:
# This is a linux-specific module.
# It is required by the Display class, but failure to import it may be
# safely ignored if one just needs to run API tests on Windows.
import fcntl
except ImportError:
print("WARNING: Failed to import fcntl. Display class will be unusable!")
log.warning(library_load_warning_message("fcntl", "Display"))

class FbMem(object):

Expand Down
Loading

0 comments on commit caa01ad

Please sign in to comment.