Skip to content

Added Temperature + Motion FeatherWing #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 7, 2019
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
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ These drivers depends on:
* `NeoPixel <https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel>`_
* `DS3231 <https://github.com/adafruit/Adafruit_CircuitPython_DS3231>`_
* `ST7735R <https://github.com/adafruit/Adafruit_CircuitPython_ST7735R>`_
* `ADXL34x <https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x>`_
* `ADT7410 <https://github.com/adafruit/Adafruit_CircuitPython_ADT7410>`_

Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
Expand Down
119 changes: 119 additions & 0 deletions adafruit_featherwing/tempmotion_featherwing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# The MIT License (MIT)
#
# Copyright (c) 2019 Melissa LeBlanc-Williams for Adafruit Industries LLC
#
# 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 the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
"""
`adafruit_featherwing.tempmotion_featherwing`
====================================================

Helper for using the `Adafruit ADXL343 + ADT7410 Sensor FeatherWing
<https://www.adafruit.com/product/4147>`_.

* Author(s): Melissa LeBlanc-Williams
"""

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"

import board
import adafruit_adxl34x
import adafruit_adt7410

class TempMotionFeatherWing:
"""Class helper representing an `Adafruit ADXL343 + ADT7410 Sensor FeatherWing
<https://www.adafruit.com/product/4147>`_.

Automatically uses the feather's I2C bus."""
def __init__(self, adxl343_address=0x53, adt7410_address=0x48, i2c=None):
if i2c is None:
i2c = board.I2C()
self._adxl343 = adafruit_adxl34x.ADXL345(i2c, address=adxl343_address)
self._adt7410 = adafruit_adt7410.ADT7410(i2c, address=adt7410_address)

@property
def temperature(self):
"""Returns ADT7410 Temperature"""
return self._adt7410.temperature

@property
def status(self):
"""Returns the ADT7410 Status"""
return self._adt7410.status

@property
def configuration(self):
"""Returns the ADT7410 Configuration"""
return self._adt7410.configuration

@configuration.setter
def configuration(self, val):
self._adt7410.configuration = val

@property
def acceleration(self):
"""Returns the ADXL343 Acceleration"""
return self._adxl343.acceleration

@property
def events(self):
"""Returns the ADXL343 Enabled Events"""
return self._adxl343.events

def enable_motion_detection(self, **kwargs):
"""Enable motion detection"""
self._adxl343.enable_motion_detection(**kwargs)

def disable_motion_detection(self):
"""Disable motion detection"""
self._adxl343.disable_motion_detection()

def enable_freefall_detection(self, **kwargs):
"""Enable freefall detection"""
self._adxl343.enable_freefall_detection(**kwargs)

def disable_freefall_detection(self):
"""Disable freefall detection"""
self._adxl343.disable_freefall_detection()

def enable_tap_detection(self, **kwargs):
"""Enable freefall detection"""
self._adxl343.enable_tap_detection(**kwargs)

def disable_tap_detection(self):
"""Disable freefall detection"""
self._adxl343.disable_tap_detection()

@property
def data_rate(self):
"""The data rate of the sensor."""
return self._adxl343.data_rate

@data_rate.setter
def data_rate(self, val):
self._adxl343.data_rate = val

@property
def range(self):
"""The measurement range of the sensor."""
return self._adxl343.range

@range.setter
def range(self, val):
self._adxl343.range = val
3 changes: 3 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@

.. automodule:: adafruit_featherwing.minitft_featherwing
:members:

.. automodule:: adafruit_featherwing.tempmotion_featherwing
:members:
4 changes: 4 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Ensure your device works with this simple test.
:caption: examples/featherwing_minitft_simpletest.py
:linenos:

.. literalinclude:: ../examples/featherwing_tempmotion_simpletest.py
:caption: examples/featherwing_tempmotion_simpletest.py
:linenos:

Other Examples
---------------

Expand Down
13 changes: 13 additions & 0 deletions examples/featherwing_tempmotion_simpletest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
This example will show the current temperature in the Serial Console
whenever the FeatherWing senses that it has been tapped
"""

import time
from adafruit_featherwing import tempmotion_featherwing
temp_motion = tempmotion_featherwing.TempMotionFeatherWing()
temp_motion.enable_tap_detection()
while True:
if temp_motion.events['tap']:
print("The temperature is %f"%temp_motion.temperature)
time.sleep(1)
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ adafruit-circuitpython-dotstar
adafruit-circuitpython-neopixel
adafruit-circuitpython-ds3231
adafruit-circuitpython-gps
adafruit-circuitpython-adxl34x
adafruit-circuitpython-adt7410
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
'adafruit-circuitpython-register', 'adafruit-circuitpython-ina219',
'adafruit-circuitpython-seesaw', 'adafruit-circuitpython-ht16k33',
'adafruit-circuitpython-dotstar', 'adafruit-circuitpython-neopixel',
'adafruit-circuitpython-ds3231', 'adafruit-circuitpython-gps'],
'adafruit-circuitpython-ds3231', 'adafruit-circuitpython-gps',
'adafruit-circuitpython-adxl34x', 'adafruit-circuitpython-adt7410'],

# Choose your license
license='MIT',
Expand Down