text stringlengths 1 93.6k |
|---|
)
|
return tilt
|
@memoized
|
def _zero_sphere_helper(D):
|
xx = np.linspace(-1, 1, D, endpoint=True if D % 2 == 1 else False)
|
z, y, x = np.meshgrid(xx, xx, xx)
|
coords = np.stack((x, y, z), -1)
|
r = np.sum(coords**2, axis=-1) ** 0.5
|
return np.where(r > 1)
|
def zero_sphere(vol):
|
"""Zero values of @vol outside the sphere"""
|
assert len(set(vol.shape)) == 1, "volume must be a cube"
|
D = vol.shape[0]
|
tmp = _zero_sphere_helper(D)
|
vlog("Zeroing {} pixels".format(len(tmp[0])))
|
vol[tmp] = 0
|
return vol
|
def assert_pkl_close(pkl_a, pkl_b, atol=1e-4):
|
a = pickle.load(open(pkl_a, "rb"))
|
b = pickle.load(open(pkl_b, "rb"))
|
if isinstance(a, tuple):
|
for _a, _b in zip(a, b):
|
assert np.linalg.norm(_a - _b) < atol
|
else:
|
assert np.linalg.norm(a - b) < atol
|
# <FILESEP>
|
'''
|
'''
|
# Power Modes
|
from machine import I2C, Pin
|
from micropython import const
|
from ustruct import unpack as unp
|
import utime
|
NORMAL = const(0)
|
BMX280_TEMP_OS_SKIP = const(0)
|
BMX280_TEMP_OS_1 = const(1)
|
BMX280_TEMP_OS_2 = const(2)
|
BMX280_TEMP_OS_4 = const(3)
|
BMX280_TEMP_OS_8 = const(4)
|
BMX280_TEMP_OS_16 = const(5)
|
BMX280_PRES_OS_SKIP = const(0)
|
BMX280_PRES_OS_1 = const(1)
|
BMX280_PRES_OS_2 = const(2)
|
BMX280_PRES_OS_4 = const(3)
|
BMX280_PRES_OS_8 = const(4)
|
BMX280_PRES_OS_16 = const(5)
|
# BMP280 Temperature Registers
|
BMX280_REGISTER_DIG_T1 = const(0x88)
|
BMX280_REGISTER_DIG_T2 = const(0x8A)
|
BMX280_REGISTER_DIG_T3 = const(0x8C)
|
# BMP280 Pressure Registers
|
BMX280_REGISTER_DIG_P1 = const(0x8E)
|
BMX280_REGISTER_DIG_P2 = const(0x90)
|
BMX280_REGISTER_DIG_P3 = const(0x92)
|
BMX280_REGISTER_DIG_P4 = const(0x94)
|
BMX280_REGISTER_DIG_P5 = const(0x96)
|
BMX280_REGISTER_DIG_P6 = const(0x98)
|
BMX280_REGISTER_DIG_P7 = const(0x9A)
|
BMX280_REGISTER_DIG_P8 = const(0x9C)
|
BMX280_REGISTER_DIG_P9 = const(0x9E)
|
BME280_REGISTER_DIG_H1 = const(0xA1)
|
BME280_REGISTER_DIG_H2 = const(0xE1)
|
BME280_REGISTER_DIG_H3 = const(0xE3)
|
BME280_REGISTER_DIG_H4 = const(0xE4)
|
BME280_REGISTER_DIG_H5 = const(0xE5)
|
BME280_REGISTER_DIG_H6 = const(0xE6)
|
BME280_REGISTER_DIG_H7 = const(0xE7)
|
BMX280_REGISTER_ID = const(0xD0)
|
BMX280_REGISTER_RESET = const(0xE0)
|
BMX280_REGISTER_STATUS = const(0xF3)
|
BMX280_REGISTER_CONTROL = const(0xF4)
|
BMX280_REGISTER_CONFIG = const(0xF5) # IIR filter config
|
BMX280_REGISTER_DATA = const(0xF7)
|
BMX280_I2C_ADDR = const(0x76)
|
class MPUException(OSError):
|
'''
|
Exception for MPU devices
|
'''
|
pass
|
class BMX280():
|
_I2Cerror = "I2C failure when communicating with the BMP/E"
|
# BMP280 = 0x58, BME280 = 0x60, BME680 = 0x61
|
_chip_id = 0x58
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.