-
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.
build for mac version 1.5 (works on pedro's 10.14.1 Mojave)
- Loading branch information
1 parent
5e80e2e
commit 670da7a
Showing
4 changed files
with
372 additions
and
0 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,147 @@ | ||
#not your typical python gitignore, be aware that we WANT .so files | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[co] | ||
*$py.class | ||
|
||
# Distribution / packaging | ||
.Python | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk |
Binary file not shown.
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,125 @@ | ||
import rehamovelib | ||
|
||
class Rehamove: | ||
|
||
current_version = "v1.5" | ||
|
||
channel0 = ['r', 'red'] | ||
channel1 = ['b', 'blue'] | ||
channel2 = ['g1', 'gray1', 'grey1', 'black'] | ||
channel3 = ['g2', 'gray2', 'grey2', 'white'] | ||
|
||
def __init__(self, port_name): | ||
self.rehamove = rehamovelib.open_port(port_name) | ||
|
||
def version(self): | ||
c_version = rehamovelib.get_version() | ||
print("Rehamove Version: Python-side " + str(Rehamove.current_version) + ", C-side " + str(c_version)) | ||
return Rehamove.current_version | ||
|
||
def get_channel(self, channel): | ||
chosen_channel = channel | ||
if isinstance(channel, str): | ||
channel = channel.lower() | ||
if channel in Rehamove.channel0: | ||
chosen_channel = 0 | ||
elif channel in Rehamove.channel1: | ||
chosen_channel = 1 | ||
elif channel in Rehamove.channel2: | ||
chosen_channel = 2 | ||
elif channel in Rehamove.channel3: | ||
chosen_channel = 3 | ||
else: | ||
chosen_channel = 0 # Default | ||
elif isinstance(channel, int): | ||
if channel < 0 and channel > 3: | ||
chosen_channel = 0 # Default | ||
else: | ||
chosen_channel = 0 | ||
return chosen_channel | ||
|
||
def pulse(self, channel, current, pulse_width): | ||
if self.rehamove == None: | ||
print("python Rehamove pulse() ERROR! Rehamove object does not exist.") | ||
return -1 | ||
chosen_channel = self.get_channel(channel) | ||
result = rehamovelib.pulse(self.rehamove, chosen_channel, current, pulse_width) | ||
if result != 0: | ||
print("python Rehamove pulse() ERROR!") | ||
return -1 | ||
else: | ||
print("python Rehamove pulse() sent.") | ||
return 0 | ||
|
||
def custom_pulse(self, channel, points_array): | ||
if self.rehamove == None: | ||
print("python Rehamove custom_pulse() ERROR! Rehamove object does not exist.") | ||
return -1 | ||
chosen_channel = self.get_channel(channel) | ||
original_length = len(points_array) | ||
num_points = len(points_array) | ||
# Error handling (warning) if too many points. | ||
if num_points > 16: | ||
print("python Rehamove custom_pulse() WARNING! Maximum of 16 points allowed, truncating points array.") | ||
num_points = 16 | ||
|
||
# Error handling (exception) if malformed points. | ||
try: | ||
for i in range(0, num_points): | ||
current = points_array[i][0] | ||
pulse_width = points_array[i][1] | ||
except: | ||
print("python Rehamove custom_pulse() ERROR! Malformed points array, should be: [ (current0, pulse_width0), (current1, pulse_width1), ... ]") | ||
return -1 | ||
|
||
# Handle if the user supplies less than 16 points: fill up empty points in the array. | ||
remaining_points = 16 - num_points | ||
for _ in range(0, remaining_points): | ||
points_array.append((0.0, 0)) | ||
|
||
# Get all of our point data. | ||
c0, w0 = points_array[0][0], points_array[0][1] | ||
c1, w1 = points_array[1][0], points_array[1][1] | ||
c2, w2 = points_array[2][0], points_array[2][1] | ||
c3, w3 = points_array[3][0], points_array[3][1] | ||
c4, w4 = points_array[4][0], points_array[4][1] | ||
c5, w5 = points_array[5][0], points_array[5][1] | ||
c6, w6 = points_array[6][0], points_array[6][1] | ||
c7, w7 = points_array[7][0], points_array[7][1] | ||
c8, w8 = points_array[8][0], points_array[8][1] | ||
c9, w9 = points_array[9][0], points_array[9][1] | ||
c10, w10 = points_array[10][0], points_array[10][1] | ||
c11, w11 = points_array[11][0], points_array[11][1] | ||
c12, w12 = points_array[12][0], points_array[12][1] | ||
c13, w13 = points_array[13][0], points_array[13][1] | ||
c14, w14 = points_array[14][0], points_array[14][1] | ||
c15, w15 = points_array[15][0], points_array[15][1] | ||
|
||
result = rehamovelib.custom_pulse(self.rehamove, chosen_channel, original_length, c0, w0, c1, w1, c2, w2, c3, w3, c4, w4, c5, w5, c6, w6, c7, w7, c8, w8, c9, w9, c10, w10, c11, w11, c12, w12, c13, w13, c14, w14, c15, w15) | ||
if result != 0: | ||
print("python Rehamove custom_pulse() ERROR!") | ||
return -1 | ||
else: | ||
print("python Rehamove custom_pulse() sent.") | ||
return 0 | ||
|
||
def battery(self): | ||
if self.rehamove == None: | ||
print("python Rehamove ERROR! Rehamove object does not exist.") | ||
return -1 | ||
result = rehamovelib.battery_request(self.rehamove) | ||
if result != 0: | ||
print("python Rehamove battery() ERROR!") | ||
return -1 | ||
else: | ||
battery_level = rehamovelib.get_battery(self.rehamove) | ||
print("python Rehamove battery(): " + str(battery_level) + "%") | ||
return battery_level | ||
|
||
def __del__(self): | ||
# Only close the port if we have a Rehamove object to close | ||
if self.rehamove != None: | ||
result = rehamovelib.close_port(self.rehamove) | ||
if result != 0: | ||
print("python Rehamove close_port() ERROR!") | ||
|
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,100 @@ | ||
# This file was automatically generated by SWIG (http://www.swig.org). | ||
# Version 4.0.1 | ||
# | ||
# Do not make changes to this file unless you know what you are doing--modify | ||
# the SWIG interface file instead. | ||
|
||
from sys import version_info as _swig_python_version_info | ||
if _swig_python_version_info < (2, 7, 0): | ||
raise RuntimeError("Python 2.7 or later required") | ||
|
||
# Import the low-level C/C++ module | ||
if __package__ or "." in __name__: | ||
from . import _rehamovelib | ||
else: | ||
import _rehamovelib | ||
|
||
try: | ||
import builtins as __builtin__ | ||
except ImportError: | ||
import __builtin__ | ||
|
||
def _swig_repr(self): | ||
try: | ||
strthis = "proxy of " + self.this.__repr__() | ||
except __builtin__.Exception: | ||
strthis = "" | ||
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) | ||
|
||
|
||
def _swig_setattr_nondynamic_instance_variable(set): | ||
def set_instance_attr(self, name, value): | ||
if name == "thisown": | ||
self.this.own(value) | ||
elif name == "this": | ||
set(self, name, value) | ||
elif hasattr(self, name) and isinstance(getattr(type(self), name), property): | ||
set(self, name, value) | ||
else: | ||
raise AttributeError("You cannot add instance attributes to %s" % self) | ||
return set_instance_attr | ||
|
||
|
||
def _swig_setattr_nondynamic_class_variable(set): | ||
def set_class_attr(cls, name, value): | ||
if hasattr(cls, name) and not isinstance(getattr(cls, name), property): | ||
set(cls, name, value) | ||
else: | ||
raise AttributeError("You cannot add class attributes to %s" % cls) | ||
return set_class_attr | ||
|
||
|
||
def _swig_add_metaclass(metaclass): | ||
"""Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" | ||
def wrapper(cls): | ||
return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) | ||
return wrapper | ||
|
||
|
||
class _SwigNonDynamicMeta(type): | ||
"""Meta class to enforce nondynamic attributes (no new attributes) for a class""" | ||
__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) | ||
|
||
|
||
class Rehamove(object): | ||
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") | ||
__repr__ = _swig_repr | ||
port_name = property(_rehamovelib.Rehamove_port_name_get, _rehamovelib.Rehamove_port_name_set) | ||
device = property(_rehamovelib.Rehamove_device_get, _rehamovelib.Rehamove_device_set) | ||
battery = property(_rehamovelib.Rehamove_battery_get, _rehamovelib.Rehamove_battery_set) | ||
|
||
def __init__(self): | ||
_rehamovelib.Rehamove_swiginit(self, _rehamovelib.new_Rehamove()) | ||
__swig_destroy__ = _rehamovelib.delete_Rehamove | ||
|
||
# Register Rehamove in _rehamovelib: | ||
_rehamovelib.Rehamove_swigregister(Rehamove) | ||
|
||
|
||
def get_version(): | ||
return _rehamovelib.get_version() | ||
|
||
def open_port(port_name): | ||
return _rehamovelib.open_port(port_name) | ||
|
||
def pulse(r, channel, current, pulse_width): | ||
return _rehamovelib.pulse(r, channel, current, pulse_width) | ||
|
||
def close_port(r): | ||
return _rehamovelib.close_port(r) | ||
|
||
def get_battery(r): | ||
return _rehamovelib.get_battery(r) | ||
|
||
def battery_request(r): | ||
return _rehamovelib.battery_request(r) | ||
|
||
def custom_pulse(r, channel, num_points, c0, w0, c1, w1, c2, w2, c3, w3, c4, w4, c5, w5, c6, w6, c7, w7, c8, w8, c9, w9, c10, w10, c11, w11, c12, w12, c13, w13, c14, w14, c15, w15): | ||
return _rehamovelib.custom_pulse(r, channel, num_points, c0, w0, c1, w1, c2, w2, c3, w3, c4, w4, c5, w5, c6, w6, c7, w7, c8, w8, c9, w9, c10, w10, c11, w11, c12, w12, c13, w13, c14, w14, c15, w15) | ||
|
||
|