isl29020.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
26 #include <stdint.h>
27 #include "periph/i2c.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
45 #ifndef CONFIG_ISL29020_DEFAULT_ADDRESS
46 #define CONFIG_ISL29020_DEFAULT_ADDRESS 0x44
47 #endif
53 typedef enum {
55  ISL29020_MODE_IR = 1
57 
61 typedef enum {
67 
71 typedef struct {
73  uint8_t addr;
77 
81 typedef struct {
83  float lux_fac;
84 } isl29020_t;
85 
95 int isl29020_init(isl29020_t *dev, const isl29020_params_t *params);
96 
105 int isl29020_read(const isl29020_t *dev);
106 
115 int isl29020_enable(const isl29020_t *dev);
116 
125 int isl29020_disable(const isl29020_t *dev);
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
int isl29020_init(isl29020_t *dev, const isl29020_params_t *params)
Initialize a new ISL29020 device.
isl29020_mode_t
Possible modes for the ISL29020 sensor.
Definition: isl29020.h:53
int isl29020_disable(const isl29020_t *dev)
Disable the given sensor.
int isl29020_enable(const isl29020_t *dev)
Enable the given sensor.
int isl29020_read(const isl29020_t *dev)
Read a lighting value from the sensor, the result is given in lux.
isl29020_range_t
Possible range values for the ISL29020 sensor.
Definition: isl29020.h:61
@ ISL29020_MODE_AMBIENT
set sensor to detect ambient light
Definition: isl29020.h:54
@ ISL29020_MODE_IR
set sensor to detect infrared light
Definition: isl29020.h:55
@ ISL29020_RANGE_64K
set range to 0-64000 lux
Definition: isl29020.h:65
@ ISL29020_RANGE_16K
set range to 0-16000 lux
Definition: isl29020.h:64
@ ISL29020_RANGE_1K
set range to 0-1000 lux
Definition: isl29020.h:62
@ ISL29020_RANGE_4K
set range to 0-4000 lux
Definition: isl29020.h:63
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition: i2c.h:144
Low-level I2C peripheral driver interface definition.
Data structure holding the full set of configuration parameters.
Definition: isl29020.h:71
isl29020_range_t range
range setting to use
Definition: isl29020.h:74
uint8_t addr
address on that bus
Definition: isl29020.h:73
isl29020_mode_t mode
measurement mode to use
Definition: isl29020.h:75
i2c_t i2c
I2C bus the device is connected to.
Definition: isl29020.h:72
Device descriptor for ISL29020 sensors.
Definition: isl29020.h:81
isl29020_params_t params
device initialization parameters
Definition: isl29020.h:82
float lux_fac
factor to calculate actual lux value
Definition: isl29020.h:83