Permalink
Browse files

Convert to modern setuptools packaging, for easy publishing to pypi.

  • Loading branch information...
mmessmore committed Jan 23, 2016
1 parent e98f777 commit e382f4cd06070cf0c3bc758b9e01d9cc8d3e2164
Showing with 103 additions and 41 deletions.
  1. +1 −0 python/INSTALL.txt
  2. +0 −7 python/MANIFEST
  3. +40 −0 python/Makefile
  4. +0 −10 python/PKG-INFO
  5. +2 −2 python/{README.md → README.rst}
  6. +18 −20 python/rrb3.py
  7. +5 −0 python/setup.cfg
  8. +37 −2 python/setup.py
View
@@ -1,3 +1,4 @@
To install the module (only tested on Python2)
$ sudo python setup.py install
View

This file was deleted.

Oops, something went wrong.
View
@@ -0,0 +1,40 @@
.PHONY: clean-pyc clean-build clean
help:
@echo "clean - remove all build, and Python artifacts"
@echo "clean-build - remove build artifacts"
@echo "clean-pyc - remove Python file artifacts"
@echo "lint - check style with flake8"
@echo "release - package and upload to pypi server"
@echo "dist - package"
@echo "install - install the package to the active Python's site-packages"
clean: clean-build clean-pyc
clean-build:
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
lint:
flake8 rrb3.py
release: clean
python setup.py sdist upload
python setup.py bdist_wheel upload
dist: clean
python setup.py sdist
python setup.py bdist_wheel
ls -l dist
install: clean
python setup.py install
View

This file was deleted.

Oops, something went wrong.
@@ -1,7 +1,7 @@
raspirobotboard 2
raspirobotboard 3
=================
Source for the RaspiRobotBoard V3 Python library.
RaspiRobotBoard V3 Python library.
For full instructions for installation and use, see:
View
@@ -1,12 +1,13 @@
#rrb3.py Library
# rrb3.py Library
import RPi.GPIO as GPIO
import time
class RRB3:
MOTOR_DELAY = 0.2
RIGHT_PWM_PIN = 14
RIGHT_1_PIN = 10
RIGHT_2_PIN = 25
@@ -26,17 +27,17 @@ class RRB3:
left_pwm = 0
right_pwm = 0
pwm_scale = 0
old_left_dir = -1
old_right_dir = -1
def __init__(self, battery_voltage=9.0, motor_voltage=6.0, revision=2):
self.pwm_scale = float(motor_voltage) / float(battery_voltage)
if self.pwm_scale > 1:
print("WARNING: Motor voltage is higher than battery votage. Motor may run slow.")
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
@@ -45,8 +46,8 @@ def __init__(self, battery_voltage=9.0, motor_voltage=6.0, revision=2):
self.left_pwm.start(0)
GPIO.setup(self.LEFT_1_PIN, GPIO.OUT)
GPIO.setup(self.LEFT_2_PIN, GPIO.OUT)
GPIO.setup(self.RIGHT_PWM_PIN, GPIO.OUT)
GPIO.setup(self.RIGHT_PWM_PIN, GPIO.OUT)
self.right_pwm = GPIO.PWM(self.RIGHT_PWM_PIN, 500)
self.right_pwm.start(0)
GPIO.setup(self.RIGHT_1_PIN, GPIO.OUT)
@@ -68,24 +69,21 @@ def __init__(self, battery_voltage=9.0, motor_voltage=6.0, revision=2):
GPIO.setup(self.TRIGGER_PIN, GPIO.OUT)
GPIO.setup(self.ECHO_PIN, GPIO.IN)
def set_motors(self, left_pwm, left_dir, right_pwm, right_dir):
if self.old_left_dir != left_dir or self.old_right_dir != right_dir:
self.set_driver_pins(0, 0, 0, 0) # stop motors between sudden changes of direction
time.sleep(self.MOTOR_DELAY)
self.set_driver_pins(left_pwm, left_dir, right_pwm, right_dir)
self.old_left_dir = left_dir
self.old_right_dir = right_dir
def set_driver_pins(self, left_pwm, left_dir, right_pwm, right_dir):
self.left_pwm.ChangeDutyCycle(left_pwm * 100 * self.pwm_scale)
GPIO.output(self.LEFT_1_PIN, left_dir)
GPIO.output(self.LEFT_2_PIN, not left_dir)
self.right_pwm.ChangeDutyCycle(right_pwm * 100 * self.pwm_scale)
GPIO.output(self.RIGHT_1_PIN, right_dir)
GPIO.output(self.RIGHT_2_PIN, not right_dir)
def forward(self, seconds=0, speed=0.5):
self.set_motors(speed, 0, speed, 0)
@@ -95,13 +93,13 @@ def forward(self, seconds=0, speed=0.5):
def stop(self):
self.set_motors(0, 0, 0, 0)
def reverse(self, seconds=0, speed=0.5):
self.set_motors(speed, 1, speed, 1)
if seconds > 0:
time.sleep(seconds)
self.stop()
def left(self, seconds=0, speed=0.5):
self.set_motors(speed, 0, speed, 1)
if seconds > 0:
@@ -113,7 +111,7 @@ def right(self, seconds=0, speed=0.5):
if seconds > 0:
time.sleep(seconds)
self.stop()
def step_forward(self, delay, num_steps):
for i in range(0, num_steps):
self.set_driver_pins(1, 1, 1, 0)
@@ -125,7 +123,7 @@ def step_forward(self, delay, num_steps):
self.set_driver_pins(1, 0, 1, 0)
time.sleep(delay)
self.set_driver_pins(0, 0, 0, 0)
def step_reverse(self, delay, num_steps):
for i in range(0, num_steps):
self.set_driver_pins(1, 0, 1, 0)
@@ -154,7 +152,7 @@ def set_oc1(self, state):
GPIO.output(self.OC1_PIN, state)
def set_oc2(self, state):
GPIO.output(self.OC2_PIN, state)
GPIO.output(self.OC2_PIN, state)
def _send_trigger_pulse(self):
GPIO.output(self.TRIGGER_PIN, True)
@@ -164,7 +162,7 @@ def _send_trigger_pulse(self):
def _wait_for_echo(self, value, timeout):
count = timeout
while GPIO.input(self.ECHO_PIN) != value and count > 0:
count = count - 1
count -= 1
def get_distance(self):
self._send_trigger_pulse()
@@ -175,6 +173,6 @@ def get_distance(self):
pulse_len = finish - start
distance_cm = pulse_len / 0.000058
return distance_cm
def cleanup(self):
GPIO.cleanup()
View
@@ -0,0 +1,5 @@
[wheel]
universal = 1
[flake8]
max-line-length = 120
View
@@ -1,2 +1,37 @@
from distutils.core import setup
setup(name='rrb3', version='1.1', py_modules=['rrb3'])
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
readme = open('README.rst').read()
setup(
name='rrb3',
version='1.1',
description='A library to support the RaspberryRobotBoard Version 3',
long_description=readme,
author='Simon Monk',
author_email='evilgeniusauthor@gmail.com',
url='http://www.raspirobot.com',
py_modules=['rrb3'],
install_requires=[
'RPi.GPIO>=0.5',
],
license='MIT',
zip_safe=False,
keywords='raspirobotboard3 rrb3 raspi robot raspberry pi dc motor stepper',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: Implementation :: PyPy',
],
)

0 comments on commit e382f4c

Please sign in to comment.