API Reference¶
qwiic_proximity¶
Python module for the [SparkFun Qwiic Proximity Sensor Breakout](https://www.sparkfun.com/products/15177)
This python package is a port of the existing [SparkFun VCNL4040 Proximity Sensor Arduino Library](https://github.com/sparkfun/SparkFun_VCNL4040_Arduino_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_proximity.
QwiicProximity
(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 Proximity device object.
Return type: Object
-
ambient
¶ Read the Ambient light value
Returns: The current ambient value value Return type: integer
-
begin
()[source]¶ Initialize the operation of the Proximity module
Returns: Returns true of the initializtion was successful, otherwise False. Return type: bool
-
connected
¶ Determine if a Proximity device is conntected to the system..
Returns: True if the device is connected, otherwise False. Return type: bool
-
disable_prox_logic_mode
()[source]¶ Disable the proximity detection logic output mode
Returns: No return value
-
enable_active_force_mode
()[source]¶ Enable active force mode An extreme power saving way to use PS is to apply PS active force mode. Anytime host would like to request one proximity measurement, enable the active force mode. This triggers a single PS measurement, which can be read from the PS result registers. VCNL4040 stays in standby mode constantly.
Returns: No return value
-
enable_prox_logic_mode
()[source]¶ Enable the proximity detection logic output mode When this mode is selected, the INT pin is pulled low when an object is close to the sensor (value is above high threshold) and is reset to high when the object moves away (value is below low threshold). Register: PS_THDH / PS_THDL define where these threshold levels are set.
Returns: No return value
-
enable_smart_persistance
()[source]¶ Enable smart persistance To accelerate the PS response time, smart persistence prevents the misjudgment of proximity sensing but also keeps a fast response time.
Returns: No return value
-
get_ambient
()[source]¶ Read the Ambient light value
Returns: The current ambient value value Return type: integer
-
get_proximity
()[source]¶ Get the current proximity value
Returns: The current proximity value Return type: integer
-
get_white
()[source]¶ Read the White light value
Returns: The current white value value Return type: integer
-
is_away
¶ Returns true if the prox value drops below the lower threshold
Returns: True if away Return type: boolean
-
is_close
¶ Returns true if the prox value rises above the upper threshold
Returns: True if close Return type: boolean
-
is_connected
()[source]¶ Determine if a Proximity device is conntected to the system..
Returns: True if the device is connected, otherwise False. Return type: bool
-
is_dark
¶ Returns true if the prox value drops below the lower threshold
Returns: True if dark Return type: boolean
-
is_light
¶ Returns true if the prox value rises above the upper threshold
Returns: True if value light Return type: boolean
-
power_off_ambient
()[source]¶ Power off the ambient light sensing portion of the sensor
Returns: No return value
-
power_off_proximity
()[source]¶ Power off the prox sensing portion of the device
Returns: No return value
-
power_on_ambient
()[source]¶ Power on the ambient light sensing portion of the sensor
Returns: No return value
-
power_on_proximity
()[source]¶ Power on the prox sensing portion of the device
Returns: No return value
-
proximity
¶ Get the current proximity value
Returns: The current proximity value Return type: integer
-
sensor_id
¶ Read the sensor ID
Returns: The sensor ID Return type: integer
-
set_als_high_threshold
(threshold)[source]¶ Value that ALS must go above to trigger an interrupt
Parameters: threshold – the new trigger threshold value for ALS Returns: No return value
-
set_als_low_threshold
(threshold)[source]¶ Value that ALS must go below to trigger an interrupt
Parameters: threshold – the new trigger threshold value for ALS Returns: No return value
-
set_ambient_integration_time
(timeValue)[source]¶ Sets the integration time for the ambient light sensor
Parameters: timeValue – The integration time Returns: No return value
-
set_ambient_interrupt_persistance
(persValue)[source]¶ Set the Ambient interrupt persistance value The ALS persistence function (ALS_PERS, 1, 2, 4, 8) helps to avoid false trigger of the ALS INT. It defines the amount of consecutive hits needed in order for a ALS interrupt event to be triggered.
Parameters: persValue – The ambiant interrupt persistance value Returns: No return value
-
set_ir_dutycycle
(dutyValue)[source]¶ Set the duty cycle of the IR LED. The higher the duty ratio, the faster the response time achieved with higher power consumption. For example, PS_Duty = 1/320, peak IRED current = 100 mA, averaged current consumption is 100 mA/320 = 0.3125 mA.
Parameters: dutyValue – The duty cycle value for the IR LED on the sensor Returns: No return value
-
set_led_current
(currentValue)[source]¶ Set the IR LED sink current to one of 8 settings
Parameters: currentValue – The new current value. Valid values are VCNL4040_LED_50MA thru VCNL4040_LED_200MA at 25MA increments Returns: No return value
-
set_prox_cancellation
(cancelValue)[source]¶ Set the proximity sensing cancelation value - helps reduce cross talk with ambient light
Parameters: cancelValue – the new cancelation value Returns: No return value
-
set_prox_high_threshold
(threshold)[source]¶ Value that Proximity Sensing must go above to trigger an interrupt
Parameters: threshold – The new Proximity High Value Returns: No return value
-
set_prox_integration_time
(timeValue)[source]¶ Sets the integration time for the proximity sensor
Parameters: timeValue – The integration time Returns: No return value
-
set_prox_interrupt_persistance
(persValue)[source]¶ Set the Prox interrupt persistance value The PS persistence function (PS_PERS, 1, 2, 3, 4) helps to avoid false trigger of the PS INT. It defines the amount of consecutive hits needed in order for a PS interrupt event to be triggered.
Parameters: persValue – The persistance value Returns: No return value
-
set_prox_interrupt_type
(interruptValue)[source]¶ Sets the proximity interrupt type
Parameters: interruptValue – The interupt type Returns: No return value
-
set_prox_low_threshold
(threshold)[source]¶ Value that Proximity Sensing must go below to trigger an interrupt
Parameters: threshold – The new Proximity Low Value Returns: No return value
-
set_prox_resolution
(resolutionValue)[source]¶ Sets the proximity resolution
Parameters: resolutionValue – The resolution time Returns: No return value
-
take_single_prox_measurement
()[source]¶ Set trigger bit so sensor takes a force mode measurement and returns to standby
Returns: No return value
-
white_light
¶ Read the White light value
Returns: The current white value value Return type: integer