|
| 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 |
0 commit comments