Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
LIBRARY_VERSION=$(shell cat library/setup.py | grep version | awk -F"'" '{print $$2}')
LIBRARY_NAME=$(shell cat library/setup.py | grep name | awk -F"'" '{print $$2}')
LIBRARY_VERSION=$(shell grep version library/setup.cfg | awk -F" = " '{print $$2}')
LIBRARY_NAME=$(shell grep name library/setup.cfg | awk -F" = " '{print $$2}')

.PHONY: usage install uninstall
usage:
Expand All @@ -9,7 +9,7 @@ usage:
@echo "install: install the library locally from source"
@echo "uninstall: uninstall the local library"
@echo "check: peform basic integrity checks on the codebase"
@echo "python-readme: generate library/README.rst from README.md"
@echo "python-readme: generate library/README.md from README.md + library/CHANGELOG.txt"
@echo "python-wheels: build python .whl files for distribution"
@echo "python-sdist: build python source distribution"
@echo "python-clean: clean python build and dist directories"
Expand All @@ -36,12 +36,14 @@ check:
tag:
git tag -a "v${LIBRARY_VERSION}" -m "Version ${LIBRARY_VERSION}"

python-readme: library/README.rst
python-readme: library/README.md

python-license: library/LICENSE.txt

library/README.rst: README.md
pandoc --from=markdown --to=rst -o library/README.rst README.md
library/README.md: README.md library/CHANGELOG.txt
cp README.md library/README.md
printf "\n\n# Changelog\n\n" >> library/README.md
cat library/CHANGELOG.txt >> library/README.md

library/LICENSE.txt: LICENSE
cp LICENSE library/LICENSE.txt
Expand Down
39 changes: 39 additions & 0 deletions library/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# MCP9600 Thermocouple Temperature Sensor

[![Build Status](https://travis-ci.com/pimoroni/mcp9600-python.svg?branch=master)](https://travis-ci.com/pimoroni/mcp9600-python)
[![Coverage Status](https://coveralls.io/repos/github/pimoroni/mcp9600-python/badge.svg?branch=master)](https://coveralls.io/github/pimoroni/mcp9600-python?branch=master)
[![PyPi Package](https://img.shields.io/pypi/v/mcp9600.svg)](https://pypi.python.org/pypi/mcp9600)
[![Python Versions](https://img.shields.io/pypi/pyversions/mcp9600.svg)](https://pypi.python.org/pypi/mcp9600)


# Installing

Stable library from PyPi:

* Just run `sudo pip install mcp9600`

Latest/development library from GitHub:

* `git clone https://github.com/pimoroni/mcp9600-python`
* `cd mcp9600-python`
* `sudo ./install.sh`



# Changelog

0.0.3
-----

* Port to i2cdevice>=0.0.6 set/get API

0.0.2
-----

* Added `get_altitude` method
* Corrected pressure to hPa

0.0.1
-----

* Initial Release
26 changes: 0 additions & 26 deletions library/README.rst

This file was deleted.

16 changes: 16 additions & 0 deletions library/mcp9600/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,22 @@ def __init__(self, i2c_addr=I2C_ADDRESS_DEFAULT, i2c_dev=None):
def setup(self):
pass

def set_thermocouple_type(self, thermocouple_type):
"""Set the type of thermocouple connected to the MCP9600.

:param thermocouple_type: One of 'K', 'J', 'T', 'N', 'S', 'E', 'B' or 'R'

"""
self._mcp9600.set('THERMOCOUPLE_CONFIG', type_select=thermocouple_type)

def get_thermocouple_type(self):
"""Get the type of thermocouple connected to the MCP9600.

Returns one of 'K', 'J', 'T', 'N', 'S', 'E', 'B' or 'R'

"""
return self._mcp9600.get('THERMOCOUPLE_CONFIG').type_select

def get_hot_junction_temperature(self):
"""Return the temperature measured by the attached thermocouple."""
return self._mcp9600.get('HOT_JUNCTION').temperature
Expand Down
41 changes: 40 additions & 1 deletion library/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
# -*- coding: utf-8 -*-
[metadata]
name = mcp9600
version = 0.0.3
author = Philip Howard
author_email = phil@pimoroni.com
description = Python library for the MCP9600 thermocouple temperature sensor
long_description = file: README.md
long_description_content_type = text/markdown
keywords = Raspberry Pi
url = https://www.pimoroni.com
project_urls =
GitHub=https://github.com/pimoroni/mcp9600-pytho
license = MIT
# This includes the license file(s) in the wheel.
# https://wheel.readthedocs.io/en/stable/user_guide.html#including-license-files-in-the-generated-wheel-file
license_files = LICENSE.txt
classifiers =
Development Status :: 4 - Beta
Operating System :: POSIX :: Linux
License :: OSI Approved :: MIT License
Intended Audience :: Developers
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Topic :: Software Development
Topic :: Software Development :: Libraries
Topic :: System :: Hardware

[options]
python_requires = >= 2.7
packages = mcp9600
install_requires =
i2cdevice >= 0.0.6

[flake8]
exclude =
test.py
.tox,
.eggs,
.git,
Expand All @@ -9,3 +42,9 @@ exclude =
dist
ignore =
E501

[pimoroni]
py2deps =
py3deps =
configtxt =
commands =
38 changes: 9 additions & 29 deletions library/setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

# -*- coding: utf-8 -*-
"""
Copyright (c) 2016 Pimoroni
Copyright (c) 2020 Pimoroni

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand All @@ -22,32 +22,12 @@
SOFTWARE.
"""

try:
from setuptools import setup
except ImportError:
from distutils.core import setup
from setuptools import setup, __version__
from pkg_resources import parse_version

minimum_version = parse_version('30.4.0')

classifiers = ['Development Status :: 4 - Beta',
'Operating System :: POSIX :: Linux',
'License :: OSI Approved :: MIT License',
'Intended Audience :: Developers',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Topic :: Software Development',
'Topic :: System :: Hardware']
if parse_version(__version__) < minimum_version:
raise RuntimeError("Package setuptools must be at least version {}".format(minimum_version))

setup(
name='mcp9600',
version='0.0.3',
author='Philip Howard',
author_email='phil@pimoroni.com',
description="""Python library for the MCP9600 thermocouple temperature sensor""",
long_description=open('README.rst').read() + '\n' + open('CHANGELOG.txt').read(),
license='MIT',
keywords='Raspberry Pi',
url='http://www.pimoroni.com',
classifiers=classifiers,
packages=['mcp9600'],
install_requires=['i2cdevice>=0.0.6']
)
setup()
24 changes: 24 additions & 0 deletions library/tests/test_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,27 @@ def test_alert_clear():
device.clear_alert(1)

assert smbus.regs[0x08] & 0b10000000 == 0b10000000


def test_set_thermocouple_type():
import mcp9600
smbus = MockSMBus(1, default_registers={
0x04: 0b00000101,
0x05: 0b00000000,
0x20: 0x40})
device = mcp9600.MCP9600(i2c_dev=smbus)

device.set_thermocouple_type('N')

assert (smbus.regs[0x05] >> 4) & 0b111 == 0b011


def test_get_thermocouple_type():
import mcp9600
smbus = MockSMBus(1, default_registers={
0x04: 0b00000101,
0x05: 0b00110000,
0x20: 0x40})
device = mcp9600.MCP9600(i2c_dev=smbus)

assert device.get_thermocouple_type() == 'N'
11 changes: 7 additions & 4 deletions library/tox.ini
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
[tox]
envlist = py{27,35},qa
envlist = py{27,35,37},qa
skip_missing_interpreters = True

[testenv]
commands =
python setup.py install
coverage run -m py.test -v -r wsx
coverage report
coverage report -m
deps =
mock
pytest>=3.1
pytest-cov

[testenv:qa]
commands =
check-manifest --ignore tox.ini,tests*,.coveragerc
python setup.py sdist bdist_wheel
twine check dist/*
flake8 --ignore E501
rstcheck README.rst
deps =
check-manifest
flake8
rstcheck
twine