Documentation ¶
Index ¶
- Constants
- Variables
- type Device
- func (d *Device) Calibrate() error
- func (d *Device) Close()
- func (d *Device) IRRed() (ir, red float64, err error)
- func (d *Device) IRRedBatch() (ir, red []float64, err error)
- func (d *Device) Options(options ...Option) (Option, error)
- func (d *Device) Read(reg byte) (byte, error)
- func (d *Device) ReadBytes(reg byte, n int) ([]byte, error)
- func (d *Device) Reset() error
- func (d *Device) RevID() (byte, error)
- func (d *Device) Shutdown() error
- func (d *Device) Startup() error
- func (d *Device) Temperature() (float64, error)
- func (d *Device) Write(reg, data byte) error
- type Option
Constants ¶
const ( IntStat1 = 0x00 IntStat2 = 0x01 IntEna1 = 0x02 IntEna2 = 0x03 FIFOWrPtr = 0x04 OvfCount = 0x05 FIFORdPtr = 0x06 FIFOData = 0x07 FIFOCfg = 0x08 ModeCfg = 0x09 SpO2Cfg = 0x0A Led1PA = 0x0C Led2PA = 0x0D MultiLedModeS2S1 = 0x11 MultiLedModeS4S3 = 0x12 TempInt = 0x1F TempFrac = 0x20 TempCfg = 0x21 RegRevID = 0xFE RegPartID = 0xFF )
Register addresses
const ( // Status 1 AlmostFull byte = (1 << 7) NewFIFOData byte = (1 << 6) AmbientLightCancelOvf byte = (1 << 5) PowerReady byte = (1 << 0) // Status 2 DieTempReady byte = (1 << 1) )
Interrupt flags
const ( Addr = 0x57 PartID = 0x15 )
Device constants
const ( TempEna byte = 0b0000_0001 ModeHR byte = 0b010 ModeSpO2 byte = 0b011 ModeMultiLed byte = 0b111 ResetControl = 0b0100_0000 )
Settings
const ( SR50 = (iota << 2) SR100 SR200 SR400 SR800 SR1000 SR1600 SR3200 )
SpO2 Sample Rate Control
const ( PW69 = iota PW118 PW215 PW411 )
LED Pulse Width Control
Variables ¶
var ( // ErrNotDevice throws an error when the device part ID does not match a // MAX30102 signature (0x15). ErrNotDevice error = errors.New("max30102: part ID does not match (0x15)") )
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device defines a MAX30102 device.
func New ¶
New returns a new MAX30102 device. By default, this sets the LED pulse amplitude to 2.4mA, with a pulse width of 411us and a sample rate of 100 samples/s.
Argument "busName" can be used to specify the exact bus to use ("/dev/i2c-2", "I2C2", "2"). Argument "addr" can be used to specify alternative address if default (0x57) is unavailable and changed. If "busName" argument is specified as an empty string "" the first available bus will be used.
func (*Device) IRRed ¶
IRRed returns the value of the red LED and IR LED. The values are normalized from 0.0 to 1.0.
func (*Device) IRRedBatch ¶
IRRedBatch returns a batch of IR and red LED values based on the AlmostFull flag. The amount of data returned can be configured by setting the AlmostFullValue leftover value, which is set to 0 by default. Therefore, this function returns 32 samples by default.
func (*Device) Options ¶
Options sets different configuration options and returns the previous value of the last option passed.
func (*Device) Reset ¶
Reset resets the device. All configurations, thresholds, and data registers are reset to their power-on state.
func (*Device) Temperature ¶
Temperature returns the current temperature of the device.
type Option ¶
Option defines a functional option for the device.
func AlmostFullValue ¶
AlmostFullValue sets when the AlmostFull interrupt should be triggered. It can take values from 0 to 15.
func IRPulseAmp ¶
IRPulseAmp sets the pulse amplitude of the red LED. It accepts values from 0.0 to 51.0 mA and the value is rounded down to the nearest multiple of 0.2.
func RedPulseAmp ¶
RedPulseAmp sets the pulse amplitude of the red LED. It accepts values from 0.0 to 51.0 mA and the value is rounded down to the nearest multiple of 0.2.
func SampleRate ¶
SampleRate sets the SpO2 sample rate control of the device.