API Reference¶
-
group
group_board_libs
Basic set of APIs for interacting with the light sensor.
Functions
-
cy_rslt_t
mtb_light_sensor_init
(mtb_light_sensor_t *light_sensor, cyhal_adc_t *adc_obj, cyhal_gpio_t pin)¶ Initialize the ADC communication with the light sensor.
note
The ADC initialization function, cyhal_adc_init(), must be called before this function is called.
- Return
CY_RSLT_SUCCESS if properly initialized, else an error indicating what went wrong.
- Parameters
[out] light_sensor
: Pointer to a Light Sensor object. The caller must allocate the memory for this object but the init function will initialize its contents.[in] adc_obj
: ADC instance to use for communicating with the light sensor.[in] pin
: The pin connected to the light sensor.
-
uint8_t
mtb_light_sensor_light_level
(mtb_light_sensor_t *light_sensor)¶ Returns the current light level.
- Return
A percentage - a value between 0 (no light) and 100 (maximum measurable light).
- Parameters
[in] light_sensor
: Light sensor instance.
-
void
mtb_light_sensor_free
(mtb_light_sensor_t *light_sensor)¶ Frees up any resources allocated by the light sensor as part of mtb_light_sensor_init().
- Parameters
[in] light_sensor
: Light sensor instance.
-
struct
mtb_light_sensor_t
¶ - #include <mtb_light_sensor.h>
Structure defining the pin and ADC channel used to interact with the light sensor.
-
cy_rslt_t