Skip to content

Commit 3791de4

Browse files
committed
2 parents e75696f + 4371949 commit 3791de4

38 files changed

+1609
-448
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Thank you for opening an issue on an Adafruit Python library repository. To
2+
improve the speed of resolution please review the following guidelines and
3+
common troubleshooting steps below before creating the issue:
4+
5+
- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
6+
the forums at http://forums.adafruit.com to ask questions and troubleshoot why
7+
something isn't working as expected. In many cases the problem is a common issue
8+
that you will more quickly receive help from the forum community. GitHub issues
9+
are meant for known defects in the code. If you don't know if there is a defect
10+
in the code then start with troubleshooting on the forum first.
11+
12+
- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
13+
check all of the steps and commands to run have been followed. Consult the
14+
forum if you're unsure or have questions about steps in a guide/tutorial.
15+
16+
- **For Python/Raspberry Pi projects check these very common issues to ensure they don't apply**:
17+
18+
- If you are receiving an **ImportError: No module named...** error then a
19+
library the code depends on is not installed. Check the tutorial/guide or
20+
README to ensure you have installed the necessary libraries. Usually the
21+
missing library can be installed with the `pip` tool, but check the tutorial/guide
22+
for the exact command.
23+
24+
- **Be sure you are supplying adequate power to the board.** Check the specs of
25+
your board and power in an external power supply. In many cases just
26+
plugging a board into your computer is not enough to power it and other
27+
peripherals.
28+
29+
- **Double check all soldering joints and connections.** Flakey connections
30+
cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
31+
32+
If you're sure this issue is a defect in the code and checked the steps above
33+
please fill in the following fields to provide enough troubleshooting information.
34+
You may delete the guideline and text above to just leave the following details:
35+
36+
- Platform/operating system (i.e. Raspberry Pi with Raspbian operating system,
37+
Windows 32-bit, Windows 64-bit, Mac OSX 64-bit, etc.): **INSERT PLATFORM/OPERATING
38+
SYSTEM HERE**
39+
40+
- Python version (run `python -version` or `python3 -version`): **INSERT PYTHON
41+
VERSION HERE**
42+
43+
- Error message you are receiving, including any Python exception traces: **INSERT
44+
ERROR MESAGE/EXCEPTION TRACES HERE***
45+
46+
- List the steps to reproduce the problem below (if possible attach code or commands
47+
to run): **LIST REPRO STEPS BELOW**

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Thank you for creating a pull request to contribute to Adafruit's GitHub code!
2+
Before you open the request please review the following guidelines and tips to
3+
help it be more easily integrated:
4+
5+
- **Describe the scope of your change--i.e. what the change does and what parts
6+
of the code were modified.** This will help us understand any risks of integrating
7+
the code.
8+
9+
- **Describe any known limitations with your change.** For example if the change
10+
doesn't apply to a supported platform of the library please mention it.
11+
12+
- **Please run any tests or examples that can exercise your modified code.** We
13+
strive to not break users of the code and running tests/examples helps with this
14+
process.
15+
16+
Thank you again for contributing! We will try to test and integrate the change
17+
as soon as we can, but be aware we have many GitHub repositories to manage and
18+
can't immediately respond to every request. There is no need to bump or check in
19+
on a pull request (it will clutter the discussion of the request).
20+
21+
Also don't be worried if the request is closed or not integrated--sometimes the
22+
priorities of Adafruit's GitHub code (education, ease of use) might not match the
23+
priorities of the pull request. Don't fret, the open source community thrives on
24+
forks and GitHub makes it easy to keep your changes in a forked repo.
25+
26+
After reviewing the guidelines above you can delete this text from the pull request.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ nosetests.xml
2828

2929
# Translations
3030
*.mo
31+
32+
# Annoying MacOSX files.
33+
.DS_Store
34+
._.DS_Store

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: python
2+
install:
3+
- pip install tox
4+
script:
5+
- tox

Adafruit_I2C.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
# ===========================================================================
66
# Adafruit_I2C Class
7-
# Adafruit_I2C.py is essentially a fork of the Adafruit Raspberry Pi I2C module.
8-
# Any pull requests for this module should be directed to the following, and I
7+
# Adafruit_I2C.py is essentially a fork of the Adafruit Raspberry Pi I2C module.
8+
# Any pull requests for this module should be directed to the following, and I
99
# can pull them. I'd rather not deviate from the original:
1010
# https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/tree/master/Adafruit_I2C
1111
# ===========================================================================
@@ -28,59 +28,59 @@ def reverseByteOrder(self, data):
2828
return val
2929

3030
def errMsg(self):
31-
print "Error accessing 0x%02X: Check your I2C address" % self.address
31+
print("Error accessing 0x%02X: Check your I2C address" % self.address)
3232
return -1
3333

3434
def write8(self, reg, value):
3535
"Writes an 8-bit value to the specified register/address"
3636
try:
3737
self.bus.write_byte_data(self.address, reg, value)
3838
if self.debug:
39-
print "I2C: Wrote 0x%02X to register 0x%02X" % (value, reg)
40-
except IOError, err:
39+
print("I2C: Wrote 0x%02X to register 0x%02X" % (value, reg))
40+
except IOError as err:
4141
return self.errMsg()
4242

4343
def write16(self, reg, value):
4444
"Writes a 16-bit value to the specified register/address pair"
4545
try:
4646
self.bus.write_word_data(self.address, reg, value)
4747
if self.debug:
48-
print ("I2C: Wrote 0x%02X to register pair 0x%02X,0x%02X" %
48+
print("I2C: Wrote 0x%02X to register pair 0x%02X,0x%02X" %
4949
(value, reg, reg+1))
50-
except IOError, err:
50+
except IOError as err:
5151
return self.errMsg()
5252

5353
def writeList(self, reg, list):
5454
"Writes an array of bytes using I2C format"
5555
try:
5656
if self.debug:
57-
print "I2C: Writing list to register 0x%02X:" % reg
58-
print list
57+
print("I2C: Writing list to register 0x%02X:" % reg)
58+
print(list)
5959
self.bus.write_i2c_block_data(self.address, reg, list)
60-
except IOError, err:
60+
except IOError as err:
6161
return self.errMsg()
6262

6363
def readList(self, reg, length):
6464
"Read a list of bytes from the I2C device"
6565
try:
6666
results = self.bus.read_i2c_block_data(self.address, reg, length)
6767
if self.debug:
68-
print ("I2C: Device 0x%02X returned the following from reg 0x%02X" %
68+
print("I2C: Device 0x%02X returned the following from reg 0x%02X" %
6969
(self.address, reg))
70-
print results
70+
print(results)
7171
return results
72-
except IOError, err:
72+
except IOError as err:
7373
return self.errMsg()
7474

7575
def readU8(self, reg):
7676
"Read an unsigned byte from the I2C device"
7777
try:
7878
result = self.bus.read_byte_data(self.address, reg)
7979
if self.debug:
80-
print ("I2C: Device 0x%02X returned 0x%02X from reg 0x%02X" %
80+
print("I2C: Device 0x%02X returned 0x%02X from reg 0x%02X" %
8181
(self.address, result & 0xFF, reg))
8282
return result
83-
except IOError, err:
83+
except IOError as err:
8484
return self.errMsg()
8585

8686
def readS8(self, reg):
@@ -89,35 +89,35 @@ def readS8(self, reg):
8989
result = self.bus.read_byte_data(self.address, reg)
9090
if result > 127: result -= 256
9191
if self.debug:
92-
print ("I2C: Device 0x%02X returned 0x%02X from reg 0x%02X" %
92+
print("I2C: Device 0x%02X returned 0x%02X from reg 0x%02X" %
9393
(self.address, result & 0xFF, reg))
9494
return result
95-
except IOError, err:
95+
except IOError as err:
9696
return self.errMsg()
9797

9898
def readU16(self, reg):
9999
"Reads an unsigned 16-bit value from the I2C device"
100100
try:
101101
result = self.bus.read_word_data(self.address,reg)
102102
if (self.debug):
103-
print "I2C: Device 0x%02X returned 0x%04X from reg 0x%02X" % (self.address, result & 0xFFFF, reg)
103+
print("I2C: Device 0x%02X returned 0x%04X from reg 0x%02X" % (self.address, result & 0xFFFF, reg))
104104
return result
105-
except IOError, err:
105+
except IOError as err:
106106
return self.errMsg()
107107

108108
def readS16(self, reg):
109109
"Reads a signed 16-bit value from the I2C device"
110110
try:
111111
result = self.bus.read_word_data(self.address,reg)
112112
if (self.debug):
113-
print "I2C: Device 0x%02X returned 0x%04X from reg 0x%02X" % (self.address, result & 0xFFFF, reg)
113+
print("I2C: Device 0x%02X returned 0x%04X from reg 0x%02X" % (self.address, result & 0xFFFF, reg))
114114
return result
115-
except IOError, err:
115+
except IOError as err:
116116
return self.errMsg()
117117

118118
if __name__ == '__main__':
119119
try:
120120
bus = Adafruit_I2C(address=0)
121-
print "Default I2C bus is accessible"
121+
print("Default I2C bus is accessible")
122122
except:
123-
print "Error accessing default I2C bus"
123+
print("Error accessing default I2C bus")

CHANGELOG.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
1.0.0
2+
----
3+
* Merge pull request #108 from MatthewWest for PWM support in Linux kernel 4.1+
4+
* Merge pull request #96 from PeteLawler for ADC support in Linux kernel 4.1+
5+
* Finally publish new version to PyPi
6+
* Bump major version number to signify long duration since last release
7+
8+
0.0.30
9+
-----
10+
* Merge Python 3 compatibility fixes from Github user westphahl.
11+
* Moved old Angstrom build fix for missing py_compile from setup.py to separate file.
12+
13+
0.0.20
14+
----
15+
* Fix for SPI not loading spidevX.X correctly based on load order
16+
* Initialize ctrl_dir in unload_device_tree #63
17+
* Clean up unused/dead code
18+
119
0.0.19
220
----
321
* Fix for SPI.xfer crashes python after 3 calls

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,16 @@ build:
1717

1818
install: build
1919
python setup.py install --force
20+
21+
build2:
22+
python2 setup.py build --force
23+
24+
install2: build2
25+
python2 setup.py install --force
26+
27+
build3:
28+
python3 setup.py build --force
29+
30+
install3: build3
31+
python3 setup.py install --force
32+

README.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,28 @@ Setup the pin for output, and write GPIO.HIGH or GPIO.LOW. Or you can use 1 or 0
7070

7171
import Adafruit_BBIO.GPIO as GPIO
7272
GPIO.setup("P8_14", GPIO.OUT) GPIO.output("P8_14", GPIO.HIGH)
73+
74+
**On-Board LEDs**
75+
76+
On-board LEDs (USR0-USR3) are handled by LED class driver rather than the GPIO pin driver.
77+
78+
They have a different path in the /sys/ filesystem.
79+
80+
Setup the pin for output and write GPIO.HIGH or GPIO.LOW::
81+
82+
import Adafruit_BBIO.GPIO as GPIO
83+
import time
84+
85+
for i in range(4):
86+
GPIO.setup("USR%d" % i, GPIO.OUT)
87+
88+
while True:
89+
for i in range(4):
90+
GPIO.output("USR%d" % i, GPIO.HIGH)
91+
time.sleep(1)
92+
for i in range(4):
93+
GPIO.output("USR%d" % i, GPIO.LOW)
94+
time.sleep(1)
7395
7496
**GPIO Input**
7597

fix_py_compile.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python2
2+
# Some Angstrom images are missing the py_compile module; get it if not
3+
# present:
4+
# Fix credit:https://github.com/alexanderhiam/PyBBIO/blob/master/setup.py
5+
import random, os
6+
python_lib_path = random.__file__.split('random')[0]
7+
if not os.path.exists(python_lib_path + 'py_compile.py'):
8+
print "py_compile module missing; installing to %spy_compile.py" %\
9+
python_lib_path
10+
import urllib2
11+
url = "http://hg.python.org/cpython/raw-file/4ebe1ede981e/Lib/py_compile.py"
12+
py_compile = urllib2.urlopen(url)
13+
with open(python_lib_path+'py_compile.py', 'w') as f:
14+
f.write(py_compile.read())
15+
print "testing py_compile..."
16+
try:
17+
import py_compile
18+
print "py_compile installed successfully"
19+
except Exception, e:
20+
print "*py_compile install failed, could not import"
21+
print "*Exception raised:"
22+
raise e

overlays/ADAFRUIT-SPI0-00A0.dts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
/* version */
1111
version = "00A0";
1212

13+
exclusive-use =
14+
/* the pin header uses */
15+
"P9.17",
16+
"P9.18",
17+
"P9.21",
18+
"P9.22",
19+
"spi0";
20+
1321
fragment@0 {
1422
target = <&am33xx_pinmux>;
1523
__overlay__ {

0 commit comments

Comments
 (0)