1
0
mirror of https://github.com/xtacocorex/CHIP_IO synced 2025-07-19 12:23:22 +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
---
* 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
# Return False on error
def set_1v8_pin_voltage(voltage):
if not isinstance(voltage, int) and not isinstance(voltage, float):
return False
if voltage < 1.8 or voltage > 3.3:
return False
if DEBUG:
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 not is_chip_pro():
if not isinstance(voltage, int) and not isinstance(voltage, float):
return False
if voltage < 1.8 or voltage > 3.3:
return False
if DEBUG:
print("Pin enable command failed")
return False
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
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:
print("Pin enable command failed")
return False
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
# Return False on error
def get_1v8_pin_voltage():
p=subprocess.Popen(["/usr/sbin/i2cget", "-f", "-y", "0", "0x34", "0x90"], stdout=subprocess.PIPE)
output=p.communicate()[0].decode("utf-8").strip()
#Not configured as an output
if output != "0x03":
if not is_chip_pro():
p=subprocess.Popen(["/usr/sbin/i2cget", "-f", "-y", "0", "0x34", "0x90"], stdout=subprocess.PIPE)
output=p.communicate()[0].decode("utf-8").strip()
#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:
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:
print("Current 1.8V Pin voltage: {0}".format(voltage))
return voltage
print("Current 1.8V Pin voltage: {0}".format(voltage))
return voltage
else:
print("Get 1.8V Pin Voltage not supported on the CHIP Pro")
# Enable 1.8V Pin on CHIP U13 Header
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
def disable_1v8_pin():
if DEBUG:
print("Disabling the 1.8V Pin")
# CANNOT USE I2C LIB AS WE NEED TO FORCE THE COMMAND DUE TO THE KERNEL OWNING THE DEVICE
# First we have to write 0x05 to AXP-209 Register 0x91
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)
if not is_chip_pro():
if DEBUG:
print("Disabling the 1.8V Pin")
# CANNOT USE I2C LIB AS WE NEED TO FORCE THE COMMAND DUE TO THE KERNEL OWNING THE DEVICE
# First we have to write 0x05 to AXP-209 Register 0x91
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
def unexport_all():
@ -107,18 +120,25 @@ def unexport_all():
def is_chip_pro():
isgr8 = False
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")
for f in files:
if "gr8" in f.lower():
isgr8 = True
if DEBUG:
print("Found gr8 SOC")
break
# GET FIRST LINE FROM /proc/meminfo
f = open("/proc/meminfo","r")
fline = f.readline()
f.close()
if DEBUG and not isgr8:
print("Found r8 SOC")
# FIGURE OUT OUR TOTAL MEMORY SIZE
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

View File

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

View File

@ -2,19 +2,12 @@ CHIP_IO
============================
A CHIP GPIO library
NOTE: Now requires the custom DTC to install the library
Manual::
Manual 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
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
cd CHIP_IO
sudo python setup.py install
@ -24,16 +17,25 @@ For Python3::
sudo apt-get update
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
cd CHIP_IO
sudo python3 setup.py install
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**
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 Pro support for PWM1, reduced GPIO capability

View File

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

View File

@ -85,6 +85,6 @@ void define_constants(PyObject *module)
bcm = Py_BuildValue("i", 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);
}