Skip to content

Commit

Permalink
Version 0.5.2
Browse files Browse the repository at this point in the history
Implemented temperature module and added examples for it.
Added new contributor.
Adaptations to fit pygatt 3.0.0
Made Windows building possible; still not runnable on Windows due to missing BLE lib in Python.
Updated documentation and some docstrings.
Fixes #21
  • Loading branch information
hbldh committed Oct 13, 2016
1 parent d701ac2 commit 0e7080b
Show file tree
Hide file tree
Showing 25 changed files with 509 additions and 302 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Created by .ignore support plugin (hsz.mobi)

libmetawear.so*
MetaWear.*.dll
# Never add potentially built elements of submodule either.
pymetawear/mbientlab/

Expand Down
7 changes: 6 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ PyMetaWear contributors (sorted alphabetically)

* [Jonas Böer](https://github.com/morgil) (Kinemic GmbH)
- Magnetometer module


* [Thibaud Mathieu](https://github.com/enlight3d)
- Raw example for temperature module

* [Eric Tsai](https://github.com/scaryghost) (mbientlab)
- 64-bit datasignal address handling and typecasting


6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v0.5.2 (2016-10-13)
===================
- Temperature Module
- Using Pygatt 3.0.0 (including PR from PyMetaWear contributors)
- Builds on Windows

v0.5.1 (2016-09-15)
===================
- Corrections to make it distributable via PyPI.
Expand Down
9 changes: 5 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ Python packages for Bluetooth Low Energy communication:
- `bluepy <https://github.com/IanHarvey/bluepy>`_ (not completely functional yet)

PyMetaWear can be run with Python 2 or 3 with both backends,
but only with the `pygatt` backend for Python 3.5. It is currently a
Linux only package.
but only with the `pygatt` backend for Python 3.5. It builds and runs on Linux systems,
and can be built on Windows, given that Visual Studio Community 2015 has been installed first,
but there is no working backend for Windows BLE yet.

Installation
------------
Expand All @@ -43,8 +44,8 @@ or
$ pip install pymetawear[bluepy]
Requirements for ``pymetawear``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Debian requirements for ``pymetawear``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* ``build-essential``
* ``python-dev``
Expand Down
6 changes: 4 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ Python packages for Bluetooth Low Energy communication:
- `bluepy <https://github.com/IanHarvey/bluepy>`_ (not completely functional yet)

PyMetaWear can be run with Python 2 or 3 with both backends,
but only with the `pygatt` backend for Python 3.5. It is currently a
Linux only package.
but only with the `pygatt` backend for Python 3.5. It builds and runs on Linux systems,
and can be built on Windows, given that Visual Studio Community 2015 has been installed first,
but there is no working backend for Windows BLE yet.



Contents
Expand Down
8 changes: 4 additions & 4 deletions docs/source/modules/accelerometer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ Example usage:
# Set data rate to 200 Hz and measureing range to +/- 8g
c.accelerometer.set_settings(data_rate=200.0, data_range=8)
def handle_acc_notification(data):
"""Handle a (x,y,z) accelerometer tuple."""
print("X: {0}, Y: {1}, Z: {2}".format(*data))
def acc_callback(data):
"""Handle a (epoch, (x,y,z)) accelerometer tuple."""
print("Epoch time: [{0}] - X: {1}, Y: {2}, Z: {3}".format(data[0], *data[1]))
# Enable notifications and register a callback for them.
c.accelerometer.notifications(handle_acc_notifications)
c.accelerometer.notifications(acc_callback)
API
---
Expand Down
4 changes: 2 additions & 2 deletions docs/source/modules/barometer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ Example usage:
# Set a large oversampling value.
c.barometer.set_settings(oversampling='ultra_high')
def handle_barometer_notification(data):
def barometer_callback(data):
"""Handle a (epoch, altitude) barometer tuple."""
print("[{0}]: Altitude: {1} m".format(*data))
# Enable notifications and register a callback for them.
c.barometer.notifications(handle_barometer_notification)
c.barometer.notifications(barometer_callback)
API
---
Expand Down
8 changes: 4 additions & 4 deletions docs/source/modules/gyroscope.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ Example usage:
# Set data rate to 200 Hz and measuring range to +/- 1000 DPS
c.gyroscope.set_settings(data_rate=200.0, data_range=1000.0)
def handle_notification(data):
"""Handle a (x,y,z) gyroscope tuple."""
print("X: {0}, Y: {1}, Z: {2}".format(*data))
def gyro_callback(data):
"""Handle a (epoch, (x,y,z)) gyroscope tuple."""
print("Epoch time: [{0}] - X: {1}, Y: {2}, Z: {3}".format(data[0], *data[1]))
# Enable notifications and register a callback for them.
c.gyroscope.notifications(handle_notifications)
c.gyroscope.notifications(gyro_callback)
API
---
Expand Down
2 changes: 2 additions & 0 deletions docs/source/modules/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ MetaWear modules
base
accelerometer
gyroscope
magnetometer
barometer
led
settings
haptic
switch
temperature
4 changes: 2 additions & 2 deletions docs/source/modules/magnetometer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ Example usage:
# Set Power preset to low power.
c.magnetometer.set_settings(power_preset='low_power')
def handle_mag_notification(data):
def magnetometer_callback(data):
"""Handle a (epoch_time, (x,y,z)) magnetometer tuple."""
epoch = data[0]
xyz = data[1]
print("[{0}] X: {1}, Y: {2}, Z: {3}".format(epoch, *xyz))
# Enable notifications and register a callback for them.
c.magnetometer.notifications(handle_mag_notification)
c.magnetometer.notifications(magnetometer_callback)
API
---
Expand Down
7 changes: 4 additions & 3 deletions docs/source/modules/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ Example usage:
"""Handle a battery status tuple."""
print("Voltage: {0}, Charge: {1}".format(
data[0], data[1]))
# Enable notifications and register a callback for them.
mwclient.battery.notifications(battery_callback)
# Trigger battery status notification.
mwclient.battery.read_battery_state()
# Enable notifications and register a callback for them.
c.switch.notifications(handle_switch_notification)
API
~~~
Expand Down
2 changes: 1 addition & 1 deletion docs/source/modules/switch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Example usage:
print("Switch released!")
# Enable notifications and register a callback for them.
c.switch.notifications(handle_switch_notification)
c.switch.notifications(switch_callback)
API
---
Expand Down
36 changes: 36 additions & 0 deletions docs/source/modules/temperature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.. _modules_temperature:

Temperature module
==================

The PyMetaWear implementation of the ``libmetawear``
temperature module.

It is initialized at the creation of the :py:class:`~MetaWearClient`
client and can then be accessed in the ``temperature``
attribute of the client.

Example usage:

.. code-block:: python
from pymetawear.client import MetaWearClient
c = MetaWearClient('DD:3A:7D:4D:56:F0')
def temperature_callback(data):
"""Handle a temperature notification data."""
epoch = data[0]
temp = data[1]
print("[{0}] Temperature {1} C".format(epoch, temp))
# Enable notifications and register a callback for them.
c.temperature.notifications(temperature_callback)
# Trigger temperature notification.
c.temperature.read_temperature()
API
---

.. automodule:: pymetawear.modules.temperature
:members:
2 changes: 1 addition & 1 deletion examples/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ def scan_and_select_le_device(timeout=3):
elif len(ble_devices) == 1:
address = ble_devices[0][0]
else:
raise ValueError("DId not detect any BLE devices.")
raise ValueError("Did not detect any BLE devices.")
return address
114 changes: 0 additions & 114 deletions examples/log_acc.py

This file was deleted.

Loading

0 comments on commit 0e7080b

Please sign in to comment.