We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2019-03-28
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Optical
Downloaded: 3844 times
Not followed.
License: MIT license
Proximity 7 Click is an advanced proximity and ambient light sensing Click board. It features the ADPS9930, a digital sensor IC equipped with two photodiodes (PD) and an IR LED, driven by a proprietary LED driver circuit.
Do you want to subscribe in order to receive notifications regarding "Proximity 7 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Proximity 7 click" changes.
Do you want to report abuse regarding "Proximity 7 click".
Library Description
Library contains functions for setting and getting register content Library contains functions for setting proximity and als integraton times as well as wait time Library contains functions for setting proximity and als channel 0 low and high thresholds Library contains functions for setting proximity and asl interrupt persistances Library contains functions for setting proximity pulse count and proximity offset Library contains function for setting constants for Lux calculation Library contains functions for getting Lux level and Int pin status Library contains functions for getting Als data from channels 0 and 1 Library contains function for getting proximity data.
Key functions:
void proximity7_setRegister( uint8_t *writeBuffer_, uint8_t nRegisters_ )
- sets register(s) content.float proximity7_getLuxLevel( void )
- calculates LUX level based on Ch0 and Ch1 data and constants set by setConstants(); - function.void proximity7_setConstants( float glassAttenuation, float constantB, float constantC, float constantD, float deviceFactor )
- sets constants for LUX calculation.Examples description
The application is composed of the three sections :
Note:
void applicationTask( )
{
proximity7_getRegister( &readBuffer[0], _PROXIMITY7_STATUS, _PROXIMITY7_REPEATED_BYTE, 1 );
alsValid = readBuffer[0] & _PROXIMITY7_ALS_VALID_MASK;
proximityValid = readBuffer[0] & _PROXIMITY7_PROXIMITY_VALID_MASK;
if (alsValid != 0 && proximityValid != 0)
{
mikrobus_logWrite( " ", _LOG_LINE );
luxLevel = proximity7_getLuxLevel( );
FloatToStr( luxLevel, text );
mikrobus_logWrite( "> > > Lux level : ", _LOG_TEXT );
mikrobus_logWrite( text, _LOG_TEXT );
mikrobus_logWrite( " lx", _LOG_LINE );
proximity = proximity7_getProximityData( );
FloatToStr( proximity, text );
mikrobus_logWrite( "> > > Proximity : ", _LOG_TEXT );
mikrobus_logWrite( text, _LOG_TEXT );
writeBuffer[0] = _PROXIMITY7_SPECIAL_FUNCTION | _PROXIMITY7_PROXIMITY_AND_ALS_INT_CLEAR;
proximity7_setRegister( &writeBuffer[0], 1 );
}
Delay_ms(300);
}
Other mikroE Libraries used in the example:
I2C
UART
Conversions
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.