parent
d1472b11ea
commit
b6f85dda36
1
Makefile
1
Makefile
|
@ -31,7 +31,6 @@ submodules :
|
|||
(cd bootloader; git submodule update --init)
|
||||
(cd micropython/ports/nrf; $(MAKE) submodules)
|
||||
(cd reloader; git submodule update --init)
|
||||
(cd wasp/modules/bma42x-upy; git submodule update --init)
|
||||
|
||||
bootloader: build-$(BOARD_SAFE)
|
||||
$(RM) bootloader/_build-$(BOARD)_nrf52832//$(BOARD)_nrf52832_bootloader-*-nosd.hex
|
||||
|
|
|
@ -11,7 +11,6 @@ freeze('../..', manifest_240x240.manifest +
|
|||
(
|
||||
'boot.py',
|
||||
'draw565.py',
|
||||
'drivers/bma421.py',
|
||||
'drivers/battery.py',
|
||||
'drivers/cst816s.py',
|
||||
'drivers/hrs3300.py',
|
||||
|
|
|
@ -25,7 +25,6 @@ from machine import Pin
|
|||
from machine import SPI
|
||||
|
||||
from drivers.battery import Battery
|
||||
from drivers.bma421 import BMA421
|
||||
from drivers.cst816s import CST816S
|
||||
from drivers.hrs3300 import HRS3300
|
||||
from drivers.signal import Signal
|
||||
|
@ -90,7 +89,6 @@ try:
|
|||
Signal(Pin('CHARGING', Pin.IN), invert=True),
|
||||
Signal(Pin('USB_PWR', Pin.IN), invert=True))
|
||||
i2c = I2C(1, scl='I2C_SCL', sda='I2C_SDA')
|
||||
accel = BMA421(i2c)
|
||||
hrs = HRS3300(i2c)
|
||||
touch = CST816S(i2c,
|
||||
Pin('TP_INT', Pin.IN), Pin('TP_RST', Pin.OUT, value=0),
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
# Copyright (C) 2020 Daniel Thompson
|
||||
|
||||
"""Bosch BMA421 accelerometer driver
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
"""
|
||||
|
||||
import bma42x
|
||||
import time
|
||||
|
||||
class BMA421:
|
||||
"""BMA421 driver
|
||||
|
||||
.. automethod:: __init__
|
||||
"""
|
||||
def __init__(self, i2c):
|
||||
"""Configure the driver.
|
||||
|
||||
:param machine.I2C i2c: I2C bus used to access the sensor.
|
||||
"""
|
||||
self._dev = bma42x.BMA42X(i2c)
|
||||
|
||||
def reset(self):
|
||||
"""Reset and reinitialize the sensor."""
|
||||
dev = self._dev
|
||||
|
||||
# Init, reset, wait for reset, enable I2C watchdog
|
||||
dev.init()
|
||||
dev.set_command_register(0xb6)
|
||||
time.sleep(0.05)
|
||||
dev.set_reg(bma42x.NV_CONFIG_ADDR, 6);
|
||||
|
||||
# Configure the sensor for basic step counting
|
||||
dev.write_config_file()
|
||||
dev.set_accel_enable(True)
|
||||
dev.set_accel_config(odr=bma42x.OUTPUT_DATA_RATE_100HZ,
|
||||
range=bma42x.ACCEL_RANGE_2G,
|
||||
bandwidth=bma42x.ACCEL_NORMAL_AVG4,
|
||||
perf_mode=bma42x.CIC_AVG_MODE)
|
||||
dev.feature_enable(bma42x.STEP_CNTR, True)
|
||||
|
||||
@property
|
||||
def steps(self):
|
||||
"""Report the number of steps counted."""
|
||||
return self._dev.step_counter_output()
|
||||
|
||||
@steps.setter
|
||||
def steps(self, value):
|
||||
if value != 0:
|
||||
raise ValueError()
|
||||
self._dev.reset_step_counter()
|
Loading…
Reference in New Issue