Skip to content

Commit b040241

Browse files
authored
Merge pull request #42 from makermelissa/master
Added Temperature + Motion FeatherWing
2 parents af7729e + a0daeca commit b040241

File tree

7 files changed

+145
-1
lines changed

7 files changed

+145
-1
lines changed

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ These drivers depends on:
2929
* `NeoPixel <https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel>`_
3030
* `DS3231 <https://github.com/adafruit/Adafruit_CircuitPython_DS3231>`_
3131
* `ST7735R <https://github.com/adafruit/Adafruit_CircuitPython_ST7735R>`_
32+
* `ADXL34x <https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x>`_
33+
* `ADT7410 <https://github.com/adafruit/Adafruit_CircuitPython_ADT7410>`_
3234

3335
Please ensure all dependencies are available on the CircuitPython filesystem.
3436
This is easily achieved by downloading
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2019 Melissa LeBlanc-Williams for Adafruit Industries LLC
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
"""
23+
`adafruit_featherwing.tempmotion_featherwing`
24+
====================================================
25+
26+
Helper for using the `Adafruit ADXL343 + ADT7410 Sensor FeatherWing
27+
<https://www.adafruit.com/product/4147>`_.
28+
29+
* Author(s): Melissa LeBlanc-Williams
30+
"""
31+
32+
__version__ = "0.0.0-auto.0"
33+
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"
34+
35+
import board
36+
import adafruit_adxl34x
37+
import adafruit_adt7410
38+
39+
class TempMotionFeatherWing:
40+
"""Class helper representing an `Adafruit ADXL343 + ADT7410 Sensor FeatherWing
41+
<https://www.adafruit.com/product/4147>`_.
42+
43+
Automatically uses the feather's I2C bus."""
44+
def __init__(self, adxl343_address=0x53, adt7410_address=0x48, i2c=None):
45+
if i2c is None:
46+
i2c = board.I2C()
47+
self._adxl343 = adafruit_adxl34x.ADXL345(i2c, address=adxl343_address)
48+
self._adt7410 = adafruit_adt7410.ADT7410(i2c, address=adt7410_address)
49+
50+
@property
51+
def temperature(self):
52+
"""Returns ADT7410 Temperature"""
53+
return self._adt7410.temperature
54+
55+
@property
56+
def status(self):
57+
"""Returns the ADT7410 Status"""
58+
return self._adt7410.status
59+
60+
@property
61+
def configuration(self):
62+
"""Returns the ADT7410 Configuration"""
63+
return self._adt7410.configuration
64+
65+
@configuration.setter
66+
def configuration(self, val):
67+
self._adt7410.configuration = val
68+
69+
@property
70+
def acceleration(self):
71+
"""Returns the ADXL343 Acceleration"""
72+
return self._adxl343.acceleration
73+
74+
@property
75+
def events(self):
76+
"""Returns the ADXL343 Enabled Events"""
77+
return self._adxl343.events
78+
79+
def enable_motion_detection(self, **kwargs):
80+
"""Enable motion detection"""
81+
self._adxl343.enable_motion_detection(**kwargs)
82+
83+
def disable_motion_detection(self):
84+
"""Disable motion detection"""
85+
self._adxl343.disable_motion_detection()
86+
87+
def enable_freefall_detection(self, **kwargs):
88+
"""Enable freefall detection"""
89+
self._adxl343.enable_freefall_detection(**kwargs)
90+
91+
def disable_freefall_detection(self):
92+
"""Disable freefall detection"""
93+
self._adxl343.disable_freefall_detection()
94+
95+
def enable_tap_detection(self, **kwargs):
96+
"""Enable freefall detection"""
97+
self._adxl343.enable_tap_detection(**kwargs)
98+
99+
def disable_tap_detection(self):
100+
"""Disable freefall detection"""
101+
self._adxl343.disable_tap_detection()
102+
103+
@property
104+
def data_rate(self):
105+
"""The data rate of the sensor."""
106+
return self._adxl343.data_rate
107+
108+
@data_rate.setter
109+
def data_rate(self, val):
110+
self._adxl343.data_rate = val
111+
112+
@property
113+
def range(self):
114+
"""The measurement range of the sensor."""
115+
return self._adxl343.range
116+
117+
@range.setter
118+
def range(self, val):
119+
self._adxl343.range = val

docs/api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@
2727

2828
.. automodule:: adafruit_featherwing.minitft_featherwing
2929
:members:
30+
31+
.. automodule:: adafruit_featherwing.tempmotion_featherwing
32+
:members:

docs/examples.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ Ensure your device works with this simple test.
4343
:caption: examples/featherwing_minitft_simpletest.py
4444
:linenos:
4545

46+
.. literalinclude:: ../examples/featherwing_tempmotion_simpletest.py
47+
:caption: examples/featherwing_tempmotion_simpletest.py
48+
:linenos:
49+
4650
Other Examples
4751
---------------
4852

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""
2+
This example will show the current temperature in the Serial Console
3+
whenever the FeatherWing senses that it has been tapped
4+
"""
5+
6+
import time
7+
from adafruit_featherwing import tempmotion_featherwing
8+
temp_motion = tempmotion_featherwing.TempMotionFeatherWing()
9+
temp_motion.enable_tap_detection()
10+
while True:
11+
if temp_motion.events['tap']:
12+
print("The temperature is %f"%temp_motion.temperature)
13+
time.sleep(1)

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ adafruit-circuitpython-dotstar
88
adafruit-circuitpython-neopixel
99
adafruit-circuitpython-ds3231
1010
adafruit-circuitpython-gps
11+
adafruit-circuitpython-adxl34x
12+
adafruit-circuitpython-adt7410

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
'adafruit-circuitpython-register', 'adafruit-circuitpython-ina219',
4040
'adafruit-circuitpython-seesaw', 'adafruit-circuitpython-ht16k33',
4141
'adafruit-circuitpython-dotstar', 'adafruit-circuitpython-neopixel',
42-
'adafruit-circuitpython-ds3231', 'adafruit-circuitpython-gps'],
42+
'adafruit-circuitpython-ds3231', 'adafruit-circuitpython-gps',
43+
'adafruit-circuitpython-adxl34x', 'adafruit-circuitpython-adt7410'],
4344

4445
# Choose your license
4546
license='MIT',

0 commit comments

Comments
 (0)