PebbleOS
Loading...
Searching...
No Matches

W1160 Ambient light sensor driver. More...

Data Structures

struct  pbl_w1160_state
 W1160 driver state, owned by the driver. More...
 
struct  pbl_w1160
 W1160 ambient light sensor. More...
 

Macros

#define PBL_W1160_DEFINE(sym, _bus, _addr, _scale)
 Define a W1160.
 

Detailed Description

W1160 Ambient light sensor driver.

While primed the sensor samples continuously and reads are plain register reads; otherwise each read is a one-shot conversion.

static const struct pbl_als_scale s_w1160_scale = {.num = 100, .den = 483};
PBL_W1160_DEFINE(s_w1160, &s_i2c.bus, 0x47, &s_w1160_scale);
const struct pbl_als *const ALS = &s_w1160.als;
#define PBL_W1160_DEFINE(sym, _bus, _addr, _scale)
Define a W1160.
Definition w1160.h:67
uint32_t num
Numerator.
Definition als.h:61
Ambient light sensor.
Definition als.h:90
Raw count to lux calibration: lux = (raw - offset) * num / den.
Definition als.h:57
const struct pbl_als *const ALS
The board's ambient light sensor.

Data Structure Documentation

◆ pbl_w1160_state

struct pbl_w1160_state

W1160 driver state, owned by the driver.

Data Fields
bool active Primed.
bool cache_valid cached_level holds a reading from the current window.
uint16_t cached_level Last level read.
bool sampling Continuous sampling enabled.
RtcTicks sampling_started_ticks Time continuous sampling was enabled.

◆ pbl_w1160

struct pbl_w1160

W1160 ambient light sensor.

Data Fields
struct pbl_als als Ambient light sensor, child of the I2C bus.
struct pbl_i2c_dev i2c I2C device.
struct pbl_w1160_state * state Driver state.

Macro Definition Documentation

◆ PBL_W1160_DEFINE

#define PBL_W1160_DEFINE (   sym,
  _bus,
  _addr,
  _scale 
)
Value:
static struct pbl_w1160_state sym##_w1160_state; \
const struct pbl_w1160 sym = { \
.als = PBL_ALS_INIT(sym, "w1160", &(_bus)->dev, &pbl_w1160_ops, (_scale)), \
.state = &sym##_w1160_state, \
.i2c = PBL_I2C_DEV(_bus, _addr), \
}; \
PBL_DEVICE_REGISTER(sym, &sym.als.dev)
struct pbl_i2c_dev i2c
I2C device.
Definition w1160.h:52
struct pbl_als als
Ambient light sensor, child of the I2C bus.
Definition w1160.h:48
W1160 driver state, owned by the driver.
Definition w1160.h:32
W1160 ambient light sensor.
Definition w1160.h:46
struct pbl_als_state * state
Runtime state.
Definition als.h:96
struct pbl_device dev
Device.
Definition als.h:92
#define PBL_ALS_INIT(sym, _name, _parent, _ops, _scale)
Initialize a struct pbl_als.
Definition als.h:122
#define PBL_ALS_STATE_DEFINE(sym)
Define the class state of an ambient light sensor.
Definition als.h:109
#define PBL_I2C_DEV(_bus, _addr)
Initializer for a struct pbl_i2c_dev.
Definition i2c.h:135

Define a W1160.

Parameters
symSymbol of the instance; the sensor is sym.als.
_busI2C bus.
_addr7-bit I2C address.
_scaleLux calibration (const struct pbl_als_scale *), or nullptr.