max30100 icon indicating copy to clipboard operation
max30100 copied to clipboard

Bug in setting the pulse width

Open nonnullish opened this issue 2 years ago • 0 comments

When setting the pulse width, the value is passed as follows: https://github.com/mfitzp/max30100/blob/242c781a02c2571287687ae134487021d828e39c/max30100.py#L135

This value is in microseconds (1600 by default), instead of the corresponding LED_PW register value.

I believe it is supposed to be set like with the LED current: https://github.com/mfitzp/max30100/blob/242c781a02c2571287687ae134487021d828e39c/max30100.py#L124

which would make the whole function set_spo_config something more like:

def set_spo_config(self, sample_rate=100, pulse_width=1600):
    reg = self.i2c.read_byte_data(I2C_ADDRESS, SPO2_CONFIG)
    reg = reg & 0xFC  # Set LED pulsewidth to 00
    pulse_width_value = _get_valid(PULSE_WIDTH, pulse_width)
    self.i2c.write_byte_data(I2C_ADDRESS, SPO2_CONFIG, reg | pulse_width_value)

nonnullish avatar Nov 19 '22 12:11 nonnullish