API Reference¶
qwiic_max3010x¶
Python module for the [SparkFun Photodetector Breakout - MAX30101 (Qwiic)](https://www.sparkfun.com/products/16474)
This python package is a port of the existing [SparkFun MAX3010x Sensor Arduino Library](https://github.com/sparkfun/SparkFun_MAX3010x_Sensor_Library)
This package can be used in conjunction with the overall [SparkFun qwiic Python Package](https://github.com/sparkfun/Qwiic_Py)
New to qwiic? Take a look at the entire [SparkFun qwiic ecosystem](https://www.sparkfun.com/qwiic).
-
class
qwiic_max3010x.
QwiicMax3010x
(address=None, i2c_driver=None)[source]¶ Parameters: - address – The I2C address to use for the device. If not provided, the default address is used.
- i2c_driver – An existing i2c driver object. If not provided a driver object is created.
Returns: The QwiicMax3010x device object.
Return type: Object
-
available
()[source]¶ Tell caller how many samples are available
Returns: number of samples available Return type: integer
-
begin
()[source]¶ Initialize the operation of the Qwiic MAX3010x module
Returns: Returns true of the initializtion was successful, otherwise False. Return type: bool
-
bit_mask
(reg, mask, thing)[source]¶ Given a register, read it, mask it, and then set the thing
Parameters: - reg – the register you’d like to effect
- mask – the mask needed to zero-out the portion of the register we’re interested in
- thing – the thing we are affecting aka the control bits of the register
Returns: Returns true of the register write was successful, otherwise False.
Return type: bool
-
check
()[source]¶ Polls the sensor for new data Call regularly If new data is available, it updates the head and tail in the main lists of data
Returns: number of new samples obtained Return type: integer
-
checkForBeat
(sample)[source]¶ Wrapper function to allow access to function within supporting heart_rate.py file
Parameters: sample – IR sample Returns: True if a beat is detected, otherwise False Return type: boolean
-
connected
¶ Determine if a device is conntected to the system..
Returns: True if the device is connected, otherwise False. Return type: bool
-
enableSlot
(slotNumber, device)[source]¶ Given a slot number assign a thing to it Devices are SLOT_RED_LED or SLOT_RED_PILOT (proximity) Assigning a SLOT_RED_LED will pulse LED Assigning a SLOT_RED_PILOT will ??
Parameters: - slotNumber – slot number as int 1,2,3,4
- device – which device (aka led) you’d like to assign to the given slot
Returns: Whether or not the configuration write was successful
Return type: bool
-
getFIFOGreen
()[source]¶ Report the next Green value in the FIFO
Returns: the next Green value in the FIFO Return type: integer
-
getFIFOIR
()[source]¶ Report the next IR value in the FIFO
Returns: the next IR value in the FIFO Return type: integer
-
getFIFORed
()[source]¶ Report the next Red value in the FIFO
Returns: the next Red value in the FIFO Return type: integer
-
getGreen
()[source]¶ Report the most recent GREEN value
Returns: value of GREEN light sensor from most recent sample Return type: integer
-
getINT1
()[source]¶ Returns the value of the INTSTAT1 Register
Returns: value of the INTSTAT1 Register Return type: integer
-
getINT2
()[source]¶ Returns the value of the INTSTAT2 Register
Returns: value of the INTSTAT2 Register Return type: integer
-
getIR
()[source]¶ Report the most recent IR value
Returns: value of IR light sensor from most recent sample Return type: integer
-
getReadPointer
()[source]¶ Read the FIFO Read Pointer
Returns: FIFO read pointer value Return type: integer
-
getRed
()[source]¶ Report the most recent red value
Returns: value of RED light sensor from most recent sample Return type: integer
-
getRevisionID
()[source]¶ Report Revision ID from current variable in this class
Returns: Revision ID Return type: integer
-
getWritePointer
()[source]¶ Read the FIFO Write Pointer
Returns: FIFO write pointer value Return type: integer
-
is_connected
()[source]¶ Determine if a device is conntected to the system..
Returns: True if the device is connected, otherwise False. Return type: bool
-
millis
()[source]¶ Returns the current time in milliseconds
Returns: Returns current system time in milliseconds Return type: int32_t
-
readRevisionID
()[source]¶ Report Revision ID from the sensor
Returns: Revision ID Return type: integer
-
safeCheck
(maxTimeToCheck)[source]¶ Check for new data but give up after a certain amount of time Returns true if new data was found Returns false if new data was not found
Parameters: maxTimeToCheck – milliseconds to timeout Returns: True if new data was found, otherwise False Return type: boolean
-
setADCRange
(adcRange)[source]¶ Set adcRange: one of MAX30105_ADCRANGE_2048, _4096, _8192, _16384
Parameters: adcRange – MAX30105_ADCRANGE_2048, _4096, _8192, _16384 Returns: no return value
-
setFIFOAlmostFull
(numberOfSamples)[source]¶ Set number of samples to trigger the almost full interrupt
Parameters: numberOfSamples – default is 32 samples. Note it’s reverse (0x00 is 32 samples, 0x0F is 17 samples) Returns: no return value
-
setFIFOAverage
(numberOfSamples)[source]¶ Set sample average
Parameters: numberOfSamples – MAX30105_SAMPLEAVG_1, _2, _4, _8, _16, _32 Returns: no return value
-
setLEDMode
(mode)[source]¶ Set which LEDs are used for sampling - Red only, RED+IR only, or custom
Parameters: mode – Red only, RED+IR only, or custom Returns: no return value
-
setProximityThreshold
(threshMSB)[source]¶ Set the IR ADC count that will trigger the beginning of particle-sensing mode. The threshMSB signifies only the 8 most significant-bits of the ADC count. Note, this is specific to the MAX30105, and not included in the MAX30101
Parameters: threshMSB – threshold of ADC count to cause trigger Returns: no return value
-
setPulseAmplitudeGreen
(amplitude)[source]¶ Set pulse amplitude (mA) of green LED
Parameters: amplitude – 0x00 = 0mA, 0x7F = 25.4mA, 0xFF = 50mA (typical) Returns: no return value
-
setPulseAmplitudeIR
(amplitude)[source]¶ Set pulse amplitude (mA) of IR LED
Parameters: amplitude – 0x00 = 0mA, 0x7F = 25.4mA, 0xFF = 50mA (typical) Returns: no return value
-
setPulseAmplitudeProximity
(amplitude)[source]¶ Set pulse aplitude while in proximity mode (only MAX30105) Note, this is specific to the MAX30105, and not included in the MAX30101
Parameters: amplitude – amplitude Returns: no return value
-
setPulseAmplitudeRed
(amplitude)[source]¶ Set pulse amplitude (mA) of red LED
Parameters: amplitude – 0x00 = 0mA, 0x7F = 25.4mA, 0xFF = 50mA (typical) Returns: no return value
-
setPulseWidth
(pulseWidth)[source]¶ Set pulseWidth: one of MAX30105_PULSEWIDTH_69, _188, _215, _411
Parameters: pulseWidth – MAX30105_PULSEWIDTH_69, _188, _215, _411 Returns: no return value
-
setSampleRate
(sampleRate)[source]¶ Set sampleRate: one of MAX30105_SAMPLERATE_50, _100, _200, _400, _800, _1000, _1600, _3200
Parameters: sampleRate – MAX30105_SAMPLERATE_50, _100, _200, _400, _800, _1000, _1600, _3200 Returns: no return value
-
setup
(powerLevel=31, sampleAverage=4, ledMode=3, sampleRate=400, pulseWidth=411, adcRange=4096)[source]¶ Setup the MAX3010x with default or custom settings
Parameters: - powerLevel – 0x00 = 0mA, 0x7F = 25.4mA, 0xFF = 50mA
- sampleAverage – int, 1,2,4,8,16,32, default is 4
- ledMode – 1 = RED, 2=RED+IR , 3=RED+IR+GREEN
- sampleRate – 0-3200
- pulseWidth – 0-411 (microseconds)
- adcRange – 2048,4096,8192,16384
Returns: no return value