PebbleOS
Loading...
Searching...
No Matches
als.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include <pbl/device.h>
#include <pbl/kernel/mutex.h>

Data Structures

struct  pbl_als_scale
 Raw count to lux calibration: lux = (raw - offset) * num / den. More...
 
struct  pbl_als_ops
 Ambient light sensor driver operations, called with the device lock held. More...
 
struct  pbl_als_state
 Ambient light sensor runtime state. More...
 
struct  pbl_als
 Ambient light sensor. More...
 

Macros

#define PBL_ALS_STATE_DEFINE(sym)
 Define the class state of an ambient light sensor.
 
#define PBL_ALS_INIT(sym, _name, _parent, _ops, _scale)
 Initialize a struct pbl_als.
 

Functions

int pbl_als_read (const struct pbl_als *als, uint32_t *level)
 Read the light level.
 
void pbl_als_prime (const struct pbl_als *als)
 Announce that readings will be wanted soon.
 
void pbl_als_release (const struct pbl_als *als)
 Drop a reference taken with pbl_als_prime().
 
void pbl_als_suspend (const struct pbl_als *als)
 Stop sampling until the matching pbl_als_resume().
 
void pbl_als_resume (const struct pbl_als *als)
 Drop a reference taken with pbl_als_suspend().
 
bool pbl_als_has_lux (const struct pbl_als *als)
 Check whether the sensor is calibrated to lux.
 
uint32_t pbl_als_to_lux (const struct pbl_als *als, uint32_t level)
 Convert a light level to lux.
 

Variables

static const uint32_t AMBIENT_LIGHT_LEVEL_MAX = (1U << CONFIG_AMBIENT_LIGHT_BITS)
 Upper bound of the raw light level scale (CONFIG_AMBIENT_LIGHT_BITS bits).
 
const struct pbl_als *const ALS
 The board's ambient light sensor.