Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ LED_POWER = MAX30105_PULSEAMP_MEDIUM
# MAX30105_PULSE_AMP_MEDIUM = 0x7F # 25.4mA - Presence detection of ~8 inch
# MAX30105_PULSE_AMP_HIGH = 0xFF # 50.0mA - Presence detection of ~12 inch
sensor.set_pulse_amplitude_red(LED_POWER)
sensor.set_pulse_amplitude_it(LED_POWER)
sensor.set_pulse_amplitude_ir(LED_POWER)
sensor.set_pulse_amplitude_green(LED_POWER)

# Set the LED brightness of all the active LEDs
Expand Down Expand Up @@ -288,6 +288,17 @@ resolution of 0.0625°C, but be aware that the accuracy is ±1°C.

## Changelog

- v0.5.0
- **Breaking:** `set_pulse_amplitude_it()` renamed to `set_pulse_amplitude_ir()` to match the
actual LED (IR, not "IT"). Callers using the old name must update to the new one.
- **Breaking:** Fixed the bit-shift direction in `fifo_bytes_to_int()` (now `>> (3 - pulse_width)`
instead of `>> pulse_width`). Raw sample magnitudes will change whenever `pulse_width` is not 0;
downstream calibration (SpO2, HR thresholds) may need to be re-tuned.
- Fixed `check()` so it drains the entire sensor FIFO per call instead of returning after the
first sample. Callers polling `check()` in a tight loop should now iterate `pop_*_from_storage()`
with `while sensor.available()` instead of `if sensor.available()` to avoid leaving samples
queued between polls. The bundled examples have been updated accordingly.
- Thanks to @sakluk for the fixes (PR #26).
- v0.4.2
- Added an heartrate estimation example.
- Issued a new release to update the PyPi docs.
Expand Down
6 changes: 3 additions & 3 deletions examples/basic_usage/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ def main():
while True:
# The check() method has to be continuously polled, to check if
# there are new readings into the sensor's FIFO queue. When new
# readings are available, this function will put them into the storage.
# readings are available, this function will put them into the storage queue.
sensor.check()

# Check if the storage contains available samples
if sensor.available():
# Drain all queued samples from the queue
while sensor.available():
# Access the storage FIFO and gather the readings (integers)
red_reading = sensor.pop_red_from_storage()
ir_reading = sensor.pop_ir_from_storage()
Expand Down
6 changes: 3 additions & 3 deletions examples/heart_rate/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ def main():
while True:
# The check() method has to be continuously polled, to check if
# there are new readings into the sensor's FIFO queue. When new
# readings are available, this function will put them into the storage.
# readings are available, this function will put them into the storage queue.
sensor.check()

# Check if the storage contains available samples
if sensor.available():
# Drain all queued samples from the queue
while sensor.available():
# Access the storage FIFO and gather the readings (integers)
red_reading = sensor.pop_red_from_storage()
ir_reading = sensor.pop_ir_from_storage()
Expand Down
10 changes: 5 additions & 5 deletions max30102/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def setup_sensor(self, led_mode=2, adc_range=16384, sample_rate=400,

# Set the LED brightness to the default value of 'low'
self.set_pulse_amplitude_red(led_power)
self.set_pulse_amplitude_it(led_power)
self.set_pulse_amplitude_ir(led_power)
self.set_pulse_amplitude_green(led_power)
self.set_pulse_amplitude_proximity(led_power)

Expand Down Expand Up @@ -400,14 +400,14 @@ def set_active_leds_amplitude(self, amplitude):
if self._active_leds > 0:
self.set_pulse_amplitude_red(amplitude)
if self._active_leds > 1:
self.set_pulse_amplitude_it(amplitude)
self.set_pulse_amplitude_ir(amplitude)
if self._active_leds > 2:
self.set_pulse_amplitude_green(amplitude)

def set_pulse_amplitude_red(self, amplitude):
self.i2c_set_register(MAX30105_LED1_PULSE_AMP, amplitude)

def set_pulse_amplitude_it(self, amplitude):
def set_pulse_amplitude_ir(self, amplitude):
self.i2c_set_register(MAX30105_LED2_PULSE_AMP, amplitude)

def set_pulse_amplitude_green(self, amplitude):
Expand Down Expand Up @@ -580,7 +580,7 @@ def bitmask(self, reg, slotMask, thing):

def fifo_bytes_to_int(self, fifo_bytes):
value = unpack(">i", b'\x00' + fifo_bytes)
return (value[0] & 0x3FFFF) >> self._pulse_width
return (value[0] & 0x3FFFF) >> (3 - self._pulse_width)

# Returns how many samples are available
def available(self):
Expand Down Expand Up @@ -681,7 +681,7 @@ def check(self):
self.fifo_bytes_to_int(fifo_bytes[6:9])
)

return True
return True

else:
return False
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
],
"deps": [
],
"version": "0.4.2"
"version": "0.5.0"
}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name="micropython-max30102",
version="0.4.2",
version="0.5.0",
description="MAX30102 driver for micropython.",
long_description=open("README.md").read(),
long_description_content_type='text/markdown',
Expand Down
Loading