PebbleOS v4.47.0-512-g5285d4236
Loading...
Searching...
No Matches
accel.h File Reference
#include <stdint.h>
#include <pbl/device.h>
#include <pbl/kernel/mutex.h>
#include <pbl/services/imu/units.h>

Data Structures

struct  pbl_accel_sample
 Accelerometer sample. More...
 
struct  AccelRawBatch
 Batch of raw samples in a driver-owned buffer. More...
 
struct  pbl_accel_event
 Accelerometer event. More...
 
struct  pbl_accel_listener
 Consumer of an accelerometer's samples and events. More...
 
struct  pbl_accel_ops
 Driver operations. More...
 
struct  pbl_accel_state
 Class runtime state. More...
 
struct  pbl_accel
 An accelerometer. More...
 
struct  AccelRawBatch.axis
 Per-axis source, indexed by IMUCoordinateAxis; encodes axis remapping and direction. More...
 

Macros

#define PBL_ACCEL_STATE_DEFINE(sym)
 Define the class state of accelerometer sym, for the PBL_*_DEFINE() macro of a driver.
 
#define PBL_ACCEL_INIT(sym, _name, _parent, _ops)
 Initializer for the struct pbl_accel of accelerometer sym.
 

Enumerations

enum  pbl_accel_event_type { PBL_ACCEL_EVENT_SHAKE , PBL_ACCEL_EVENT_DOUBLE_TAP }
 Accelerometer event type. More...
 

Functions

int pbl_accel_dev_init (const struct pbl_device *dev)
 Device init of every accelerometer: calls the driver's init with the lock held.
 
void pbl_accel_lock (const struct pbl_accel *accel)
 Take the device lock.
 
void pbl_accel_unlock (const struct pbl_accel *accel)
 Release the device lock.
 
int pbl_accel_set_listener (const struct pbl_accel *accel, const struct pbl_accel_listener *listener)
 Set the listener of samples and events.
 
int pbl_accel_set_rotated (const struct pbl_accel *accel, bool rotated)
 Set whether the axes are rotated by 180 degrees.
 
int pbl_accel_set_sampling_interval (const struct pbl_accel *accel, uint32_t interval_us, uint32_t *actual_us)
 Set the sampling interval.
 
uint32_t pbl_accel_get_sampling_interval (const struct pbl_accel *accel)
 Get the sampling interval.
 
int pbl_accel_set_num_samples (const struct pbl_accel *accel, uint32_t num_samples)
 Set the maximum number of samples the driver may batch.
 
uint32_t pbl_accel_get_max_num_samples (const struct pbl_accel *accel)
 Get the maximum number of samples the driver can batch.
 
int pbl_accel_peek (const struct pbl_accel *accel, struct pbl_accel_sample *sample)
 Read the most recent sample.
 
int pbl_accel_set_shake_detection (const struct pbl_accel *accel, bool on)
 Enable or disable shake detection.
 
bool pbl_accel_get_shake_detection (const struct pbl_accel *accel)
 Check whether shake detection is enabled.
 
int pbl_accel_set_double_tap_detection (const struct pbl_accel *accel, bool on)
 Enable or disable double tap detection.
 
bool pbl_accel_get_double_tap_detection (const struct pbl_accel *accel)
 Check whether double tap detection is enabled.
 
int pbl_accel_set_shake_sensitivity_high (const struct pbl_accel *accel, bool high)
 Select high or normal shake sensitivity.
 
int pbl_accel_set_shake_sensitivity_percent (const struct pbl_accel *accel, uint8_t percent)
 Set the normal shake sensitivity.
 
void pbl_accel_report_samples (const struct pbl_accel *accel, const AccelRawBatch *batch)
 Report a batch of samples to the listener.
 
void pbl_accel_report_sample (const struct pbl_accel *accel, const struct pbl_accel_sample *sample)
 Report a single sample to the listener, as a one-sample batch.
 
void pbl_accel_report_event (const struct pbl_accel *accel, const struct pbl_accel_event *event)
 Report an event to the listener.
 

Variables

const struct pbl_accel *const ACCEL
 The board's accelerometer.