1
0
Fork 0

rm heartrate driver, maybe break sim

jebbatime
ml server 2021-06-14 13:13:58 -06:00
parent 4e24fe518a
commit ada48a8715
5 changed files with 2 additions and 142 deletions

View File

@ -11,6 +11,8 @@
* Remove unused bits in general. * Remove unused bits in general.
* Mirrors of all submodules. * Mirrors of all submodules.
* Graphics, e.g. `logo.py`. * Graphics, e.g. `logo.py`.
* Set default time and enable Alarm.
* Multiple alarms.
# Time # Time
* Accurate within a couple seconds. `;)` * Accurate within a couple seconds. `;)`

View File

@ -13,7 +13,6 @@ freeze('../..', manifest_240x240.manifest +
'draw565.py', 'draw565.py',
'drivers/battery.py', 'drivers/battery.py',
'drivers/cst816s.py', 'drivers/cst816s.py',
'drivers/hrs3300.py',
'drivers/nrf_rtc.py', 'drivers/nrf_rtc.py',
'drivers/signal.py', 'drivers/signal.py',
'drivers/st7789.py', 'drivers/st7789.py',

View File

@ -26,7 +26,6 @@ from machine import SPI
from drivers.battery import Battery from drivers.battery import Battery
from drivers.cst816s import CST816S from drivers.cst816s import CST816S
from drivers.hrs3300 import HRS3300
from drivers.signal import Signal from drivers.signal import Signal
from drivers.st7789 import ST7789_SPI from drivers.st7789 import ST7789_SPI
from drivers.vibrator import Vibrator from drivers.vibrator import Vibrator
@ -89,7 +88,6 @@ try:
Signal(Pin('CHARGING', Pin.IN), invert=True), Signal(Pin('CHARGING', Pin.IN), invert=True),
Signal(Pin('USB_PWR', Pin.IN), invert=True)) Signal(Pin('USB_PWR', Pin.IN), invert=True))
i2c = I2C(1, scl='I2C_SCL', sda='I2C_SDA') i2c = I2C(1, scl='I2C_SCL', sda='I2C_SDA')
hrs = HRS3300(i2c)
touch = CST816S(i2c, touch = CST816S(i2c,
Pin('TP_INT', Pin.IN), Pin('TP_RST', Pin.OUT, value=0), Pin('TP_INT', Pin.IN), Pin('TP_RST', Pin.OUT, value=0),
_callback) _callback)

View File

@ -133,47 +133,6 @@ class RTC(object):
def get_uptime_ms(self): def get_uptime_ms(self):
return int(self.uptime * 1000) return int(self.uptime * 1000)
class HRS():
DATA = (
9084,9084,9025,9025,9009,9009,9009,9015,9015,9024,9024,9024,9073,9073,9074,9074,
9074,9100,9100,9097,9097,9097,9045,9045,9023,9023,9023,9035,9035,9039,9039,9039,
9049,9049,9052,9052,9052,9066,9066,9070,9070,9070,9078,9078,9081,9081,9081,9092,
9092,9093,9093,9093,9094,9094,9108,9108,9108,9124,9124,9122,9122,9122,9100,9100,
9110,9110,9110,9112,9112,9118,9118,9118,9127,9127,9136,9136,9136,9147,9147,9154,
9154,9154,9156,9156,9153,9153,9153,9152,9152,9156,9156,9156,9161,9161,9161,9177,
9177,9186,9186,9196,9196,9196,9201,9201,9201,9189,9189,9176,9176,9176,9176,9176,
9175,9175,9175,9175,9175,9180,9180,9180,9189,9189,9202,9202,9202,9207,9207,9181,
9181,9181,9167,9167,9169,9169,9169,9163,9163,9164,9164,9164,9165,9165,9172,9172,
9172,9180,9180,9192,9192,9192,9178,9178,9161,9161,9161,9163,9163,9173,9173,9173,
9170,9170,9179,9179,9183,9183,9183,9196,9196,9207,9207,9207,9208,9208,9186,9186,
9186,9182,9182,9193,9193,9193,9197,9197,9188,9204,9204,9212,9212,9212,9223,9223,
9228,9228,9228,9235,9235,9215,9215,9215,9217,9217,9225,9225,9225,9230,9230,9237,
9237,9237,9246,9246,9260,9260,9260,9270,9270,9269,9269,9269,9256,9256,9256,9256,
9256,9263,9263,9274,9274,9274,9288,9288,9292,9292,9292,9307,9307,9310
)
def __init__(self):
self._i = 0
self._step = 1
def enable(self):
pass
def disable(self):
pass
def read_hrs(self):
d = self.DATA[self._i]
self._i += self._step
if self._i >= len(self.DATA):
self._i -= 1
self._step = -1
elif self._i < 0:
self._i += 1
self._step = 1
return d
backlight = Backlight() backlight = Backlight()
spi = SPI(0) spi = SPI(0)
spi.init(polarity=1, phase=1, baudrate=8000000) spi.init(polarity=1, phase=1, baudrate=8000000)
@ -186,7 +145,6 @@ drawable = draw565.Draw565(display)
accel = Accelerometer() accel = Accelerometer()
battery = Battery() battery = Battery()
button = Pin('BUTTON', Pin.IN, quiet=True) button = Pin('BUTTON', Pin.IN, quiet=True)
hrs = HRS()
rtc = RTC() rtc = RTC()
touch = CST816S(I2C(0), Pin('TP_INT', Pin.IN, quiet=True), Pin('TP_RST', Pin.OUT, quiet=True)) touch = CST816S(I2C(0), Pin('TP_INT', Pin.IN, quiet=True), Pin('TP_RST', Pin.OUT, quiet=True))
vibrator = Vibrator(Pin('MOTOR', Pin.OUT, value=0), active_low=True) vibrator = Vibrator(Pin('MOTOR', Pin.OUT, value=0), active_low=True)

View File

@ -1,97 +0,0 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
# Copyright (C) 2020 Daniel Thompson
"""HRS3300 driver
~~~~~~~~~~~~~~~~~
"""
from micropython import const
_I2CADDR = const(0x44)
_ID = const(0x00)
_ENABLE = const(0x01)
_ENABLE_HEN = const(0x80)
_C1DATAM = const(0x08)
_C0DATAM = const(0x09)
_C0DATAH = const(0x0a)
_PDRIVER = const(0x0c)
_C1DATAH = const(0x0d)
_C1DATAL = const(0x0e)
_C0DATAL = const(0x0f)
_RES = const(0x16)
_HGAIN = const(0x17)
class HRS3300:
def __init__(self, i2c):
self._i2c = i2c
def init(self):
w = self.write_reg
# HRS disabled, 12.5 ms wait time between cycles, (partly) 20mA drive
w(_ENABLE, 0x60)
# (partly) 20mA drive, power on, "magic" (datasheet says both
# "reserved" and "set low nibble to 8" but 0xe gives better results
# and is used by at least two other HRS3300 drivers
w(_PDRIVER, 0x6e)
# HRS and ALS both in 16-bit mode
w(_RES, 0x88)
# 64x gain
w(_HGAIN, 0x10)
def read_reg(self, addr):
return self._i2c.readfrom_mem(_I2CADDR, addr, 1)[0]
def write_reg(self, addr, val):
self._i2c.writeto_mem(_I2CADDR, addr, bytes((val,)))
def enable(self):
self.init()
enable = self.read_reg(_ENABLE)
enable |= _ENABLE_HEN
self.write_reg(_ENABLE, enable)
def disable(self):
enable = self.read_reg(_ENABLE)
enable &= ~_ENABLE_HEN
self.write_reg(_ENABLE, enable)
def read_hrs(self):
# TODO: Try fusing the read of H & L
m = self.read_reg(_C0DATAM)
h = self.read_reg(_C0DATAH)
l = self.read_reg(_C0DATAL)
return (m << 8) | ((h & 0x0f) << 4) | (l & 0x0f) | ((l & 0x30) << 12)
def read_als(self):
# TODO: Try fusing the read of H & L
m = self.read_reg(_C1DATAM)
h = self.read_reg(_C1DATAH)
l = self.read_reg(_C1DATAL)
return (m << 3) | ((h & 0x3f) << 11) | (l & 0x07)
def set_gain(self, gain):
if gain > 64:
gain = 64
hgain = 0
while (1 << hgain) < gain:
hgain += 1
self.write_reg(_HGAIN, hgain << 2)
def set_drive(self, drive):
en = self.read_reg(_ENABLE)
pd = self.read_reg(_PDRIVER)
en = (en & 0xf7) | ((drive & 2) << 2)
pd = (pd & 0xbf) | ((drive & 1) << 6)
self.write_reg(_ENABLE, en)
self.write_reg(_PDRIVER, pd)