Microchip® Advanced Software Framework

common/applications/sensors/lightprox_demo/main.c File Reference

Common Sensor Service Light and Proximity Sensor Example.

Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.

#include <stdio.h>
#include <asf.h>
#include <led.h>

Macros

#define ACTIVITY_LED   (LED1) /* Which LED to blink to show activity */
 
#define LIGHT_SAMPLE_RATE   (10) /* Light sensor sample rate (Hz) */
 
#define PRINT_BANNER
 
#define PROX_CURRENT_mA   (50) /* Current for proximity sensor LEDs (mA) */
 
#define PROX_SAMPLE_RATE   (10) /* Proximity sensor sample rate (Hz) */
 
#define PROX_THRESHOLD   (100) /* Manual prox sensor threshold for "near" */
 
#define SCALED_DATA
 
#define SET_PROX_CURRENT   (true) /* If true, manually set proximity current */
 
#define SET_PROX_THRESHOLD
 

Functions

int main (void)
 Light & proximity sensor demo application entry. More...
 

Variables

static const char *const prox_labels [4]
 Strings to display based on proximity values. More...
 

#define ACTIVITY_LED   (LED1) /* Which LED to blink to show activity */

Referenced by main().

#define LIGHT_SAMPLE_RATE   (10) /* Light sensor sample rate (Hz) */

Referenced by main().

#define PRINT_BANNER
Value:
(true) /* If true, print sensor config
* information */

Referenced by main().

#define PROX_CURRENT_mA   (50) /* Current for proximity sensor LEDs (mA) */

Referenced by main().

#define PROX_SAMPLE_RATE   (10) /* Proximity sensor sample rate (Hz) */

Referenced by main().

#define PROX_THRESHOLD   (100) /* Manual prox sensor threshold for "near" */

Referenced by main().

#define SCALED_DATA
Value:
(true) /* If true, convert sensor data to standard
* units. */

Referenced by main().

#define SET_PROX_CURRENT   (true) /* If true, manually set proximity current */
#define SET_PROX_THRESHOLD
Value:
(true) /* If true, manually set proximity
* threshold */

int main ( void  )

Light & proximity sensor demo application entry.

After initializing the Xplained platform and sensor boards, this application attaches descriptors to the ambient light and proximity sensor devices on an Xplained inertial sensor board. The sensor data, which is formatted and printed via printf() after being read, can be viewed with a serial terminal application on a machine attached to the USB interface on the Xplained board.

References ACTIVITY_LED, sensor_device_t::caps, delay_ms, sensor_desc::drv, sensor_desc::err, sensor_data_t::light, light_data, light_dev, LIGHT_SAMPLE_RATE, sensor_caps_t::name, PRINT_BANNER, PROX_CURRENT_mA, prox_data, prox_dev, prox_labels, PROX_SAMPLE_RATE, PROX_THRESHOLD, sensor_data_t::proximity, sensor_data_t::scaled, SCALED_DATA, sensor_attach(), SENSOR_CHANNEL_ALL, sensor_device_id(), sensor_get_bandwidth(), sensor_get_light(), sensor_get_proximity(), sensor_get_range(), sensor_platform_init(), sensor_set_channel(), sensor_set_current(), sensor_set_sample_rate(), sensor_set_threshold(), SENSOR_THRESHOLD_NEAR_PROXIMITY, SENSOR_TYPE_LIGHT, and SENSOR_TYPE_PROXIMITY.

const char* const prox_labels[4]
static
Initial value:
= {
"none ",
"FAR ",
"MEDIUM",
"NEAR "
}

Strings to display based on proximity values.

Referenced by main().