1
0
mirror of https://github.com/xtacocorex/CHIP_IO synced 2025-07-20 04:43:21 +00:00

forgot to update the chip pro detection in Utilties, removed overlay stuff from makefile, cleaned up readme

This commit is contained in:
Robert Wolterman
2017-02-26 14:07:11 -06:00
parent 48d9343dba
commit f7bec3f891
7 changed files with 95 additions and 61 deletions

View File

@ -1,3 +1,8 @@
0.5.2
---
* Updating Utilties to determine CHIP Pro better
* Updating the README to fix things
0.5.0 0.5.0
--- ---
* CHIP Pro Support * CHIP Pro Support

View File

@ -43,53 +43,66 @@ def toggle_debug():
# Set the 1.8V-pin on the CHIP U13-header to given voltage # Set the 1.8V-pin on the CHIP U13-header to given voltage
# Return False on error # Return False on error
def set_1v8_pin_voltage(voltage): def set_1v8_pin_voltage(voltage):
if not isinstance(voltage, int) and not isinstance(voltage, float): if not is_chip_pro():
return False if not isinstance(voltage, int) and not isinstance(voltage, float):
if voltage < 1.8 or voltage > 3.3: return False
return False if voltage < 1.8 or voltage > 3.3:
if DEBUG: return False
print("Setting 1.8V Pin voltage: {0}".format(voltage))
voltage=int(round((voltage - 1.8) / 0.1)) << 4
if subprocess.call(["/usr/sbin/i2cset", "-f", "-y" ,"0", "0x34", "0x90", "0x03"]):
if DEBUG: if DEBUG:
print("Pin enable command failed") print("Setting 1.8V Pin voltage: {0}".format(voltage))
return False voltage=int(round((voltage - 1.8) / 0.1)) << 4
if subprocess.call(["/usr/sbin/i2cset", "-f", "-y", "0", "0x34", "0x91", str(voltage)]): if subprocess.call(["/usr/sbin/i2cset", "-f", "-y" ,"0", "0x34", "0x90", "0x03"]):
if DEBUG: if DEBUG:
print("Pin set voltage command failed") print("Pin enable command failed")
return False return False
return True if subprocess.call(["/usr/sbin/i2cset", "-f", "-y", "0", "0x34", "0x91", str(voltage)]):
if DEBUG:
print("Pin set voltage command failed")
return False
return True
else:
print("Set 1.8V Pin Voltage not supported on the CHIP Pro")
# Get the voltage the 1.8V-pin on the CHIP U13-header has been configured as # Get the voltage the 1.8V-pin on the CHIP U13-header has been configured as
# Return False on error # Return False on error
def get_1v8_pin_voltage(): def get_1v8_pin_voltage():
p=subprocess.Popen(["/usr/sbin/i2cget", "-f", "-y", "0", "0x34", "0x90"], stdout=subprocess.PIPE) if not is_chip_pro():
output=p.communicate()[0].decode("utf-8").strip() p=subprocess.Popen(["/usr/sbin/i2cget", "-f", "-y", "0", "0x34", "0x90"], stdout=subprocess.PIPE)
#Not configured as an output output=p.communicate()[0].decode("utf-8").strip()
if output != "0x03": #Not configured as an output
if output != "0x03":
if DEBUG:
print("1.8V Pin is currently disabled")
return False
p=subprocess.Popen(["/usr/sbin/i2cget", "-f", "-y", "0", "0x34", "0x91"], stdout=subprocess.PIPE)
output=p.communicate()[0].decode("utf-8").strip()
voltage=round((int(output, 16) >> 4) * 0.1 + 1.8, 1)
if DEBUG: if DEBUG:
print("1.8V Pin is currently disabled") print("Current 1.8V Pin voltage: {0}".format(voltage))
return False return voltage
p=subprocess.Popen(["/usr/sbin/i2cget", "-f", "-y", "0", "0x34", "0x91"], stdout=subprocess.PIPE) else:
output=p.communicate()[0].decode("utf-8").strip() print("Get 1.8V Pin Voltage not supported on the CHIP Pro")
voltage=round((int(output, 16) >> 4) * 0.1 + 1.8, 1)
if DEBUG:
print("Current 1.8V Pin voltage: {0}".format(voltage))
return voltage
# Enable 1.8V Pin on CHIP U13 Header # Enable 1.8V Pin on CHIP U13 Header
def enable_1v8_pin(): def enable_1v8_pin():
set_1v8_pin_voltage(1.8) if not is_chip_pro():
set_1v8_pin_voltage(1.8)
else:
print("Enable 1.8V Pin not supported on the CHIP Pro")
# Disable 1.8V Pin on CHIP U13 Header # Disable 1.8V Pin on CHIP U13 Header
def disable_1v8_pin(): def disable_1v8_pin():
if DEBUG:
print("Disabling the 1.8V Pin") if not is_chip_pro():
# CANNOT USE I2C LIB AS WE NEED TO FORCE THE COMMAND DUE TO THE KERNEL OWNING THE DEVICE if DEBUG:
# First we have to write 0x05 to AXP-209 Register 0x91 print("Disabling the 1.8V Pin")
subprocess.call('/usr/sbin/i2cset -f -y 0 0x34 0x91 0x05', shell=True) # CANNOT USE I2C LIB AS WE NEED TO FORCE THE COMMAND DUE TO THE KERNEL OWNING THE DEVICE
# Then we have to write 0x07 to AXP-209 Register 0x90 # First we have to write 0x05 to AXP-209 Register 0x91
subprocess.call('/usr/sbin/i2cset -f -y 0 0x34 0x90 0x07', shell=True) subprocess.call('/usr/sbin/i2cset -f -y 0 0x34 0x91 0x05', shell=True)
# Then we have to write 0x07 to AXP-209 Register 0x90
subprocess.call('/usr/sbin/i2cset -f -y 0 0x34 0x90 0x07', shell=True)
else:
print("Disable 1.8V Pin not supported on the CHIP Pro")
# Unexport All # Unexport All
def unexport_all(): def unexport_all():
@ -107,18 +120,25 @@ def unexport_all():
def is_chip_pro(): def is_chip_pro():
isgr8 = False isgr8 = False
if DEBUG: if DEBUG:
print("Determining if computer has R8 or GR8 SOC") print("Determining if computer is CHIP or CHIP Pro")
files = glob.glob("/boot/*.dtb") # GET FIRST LINE FROM /proc/meminfo
for f in files: f = open("/proc/meminfo","r")
if "gr8" in f.lower(): fline = f.readline()
isgr8 = True f.close()
if DEBUG:
print("Found gr8 SOC")
break
if DEBUG and not isgr8: # FIGURE OUT OUR TOTAL MEMORY SIZE
print("Found r8 SOC") parts = fline.split()
mem = float(parts[1]) / 1024
if mem > 380:
isgr8 = False
if DEBUG:
print("found CHIP!")
else:
isgr8 = True
if DEBUG:
print("found CHIP Pro!")
# Return isgr8 # Return isgr8
return isgr8 return isgr8

View File

@ -8,7 +8,6 @@ clean:
rm -rf CHIP_IO.* build dist rm -rf CHIP_IO.* build dist
rm -f *.pyo *.pyc rm -f *.pyo *.pyc
rm -f *.egg rm -f *.egg
rm -f overlays/*.pyo overlays/*.pyc
rm -rf __pycache__ rm -rf __pycache__
rm -rf debian/python-chip-io* rm -rf debian/python-chip-io*
rm -rf debian/python3-chip-io* rm -rf debian/python3-chip-io*

View File

@ -2,19 +2,12 @@ CHIP_IO
============================ ============================
A CHIP GPIO library A CHIP GPIO library
NOTE: Now requires the custom DTC to install the library Manual Installation::
Manual::
For Python2.7:: For Python2.7::
sudo apt-get update sudo apt-get update
sudo apt-get install git build-essential python-dev python-pip flex bison chip-dt-overlays -y sudo apt-get install git build-essential python-dev python-pip flex bison chip-dt-overlays -y
git clone https://github.com/atenart/dtc.git
cd dtc
make
sudo make install PREFIX=/usr
cd ..
git clone git://github.com/xtacocorex/CHIP_IO.git git clone git://github.com/xtacocorex/CHIP_IO.git
cd CHIP_IO cd CHIP_IO
sudo python setup.py install sudo python setup.py install
@ -24,16 +17,25 @@ For Python3::
sudo apt-get update sudo apt-get update
sudo apt-get install git build-essential python3-dev python3-pip flex bison chip-dt-overlays -y sudo apt-get install git build-essential python3-dev python3-pip flex bison chip-dt-overlays -y
git clone https://github.com/atenart/dtc.git
cd dtc
make
sudo make install PREFIX=/usr
cd ..
git clone git://github.com/xtacocorex/CHIP_IO.git git clone git://github.com/xtacocorex/CHIP_IO.git
cd CHIP_IO cd CHIP_IO
sudo python3 setup.py install sudo python3 setup.py install
cd .. cd ..
PyPi Installation::
For Python2.7::
sudo apt-get update
sudo apt-get install git build-essential python-dev python-pip flex bison chip-dt-overlays -y
sudo pip install CHIP-IO
For Python3::
sudo apt-get update
sudo apt-get install git build-essential python3-dev python3-pip flex bison chip-dt-overlays -y
sudo pip3 install CHIP-IO
**Usage** **Usage**
Using the library is very similar to the excellent RPi.GPIO library used on the Raspberry Pi. Below are some examples. Using the library is very similar to the excellent RPi.GPIO library used on the Raspberry Pi. Below are some examples.

8
debian/changelog vendored
View File

@ -1,3 +1,11 @@
chip-io (0.5.2-1) unstable; urgency=low
* Updating Utilities to determine CHIP Pro better
* Updating Utilities to only run CHIP appropriate code on the CHIP and not CHIP Pro
* Updated README
-- Robert Wolterman <robert.wolterman@gmail.com> Sun, 26 Feb 2017 13:56:00 -0600
chip-io (0.5.0-1) unstable; urgency=low chip-io (0.5.0-1) unstable; urgency=low
* CHIP Pro support for PWM1, reduced GPIO capability * CHIP Pro support for PWM1, reduced GPIO capability

View File

@ -13,7 +13,7 @@ classifiers = ['Development Status :: 3 - Alpha',
'Topic :: System :: Hardware'] 'Topic :: System :: Hardware']
setup(name = 'CHIP_IO', setup(name = 'CHIP_IO',
version = '0.5.0', version = '0.5.2',
author = 'Robert Wolterman', author = 'Robert Wolterman',
author_email = 'robert.wolterman@gmail.com', author_email = 'robert.wolterman@gmail.com',
description = 'A module to control CHIP IO channels', description = 'A module to control CHIP IO channels',

View File

@ -85,6 +85,6 @@ void define_constants(PyObject *module)
bcm = Py_BuildValue("i", BCM); bcm = Py_BuildValue("i", BCM);
PyModule_AddObject(module, "BCM", bcm); PyModule_AddObject(module, "BCM", bcm);
version = Py_BuildValue("s", "0.5.0"); version = Py_BuildValue("s", "0.5.2");
PyModule_AddObject(module, "VERSION", version); PyModule_AddObject(module, "VERSION", version);
} }