1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//! This is a platform agnostic Rust driver for the HRS3300 heart rate sensor
//! using the [`embedded-hal`] traits.
//!
//! [`embedded-hal`]: https://github.com/rust-embedded/embedded-hal
//!
//! This driver allows you to:
//! - Enable/disable heart rate sensor. See: [`enable_hrs()`].
//! - Enable/disable oscillator. See: [`enable_oscillator()`].
//! - Initialize the device. See: [`init()`].
//! - Set the conversion delay. See: [`set_conversion_delay()`].
//! - Set the gain. See: [`set_gain()`].
//! - Set the ambient light sensor resolution. See: [`set_als_resolution()`].
//! - Set the LED current. See: [`set_led_current()`].
//! - Read the device id. See: [`device_id()`].
//! - Read the last heart rate sensor measurement. See: [`read_hrs()`].
//! - Read the last ambient light sensor measurement. See: [`read_als()`].
//! - Write/Read a register with a custom value. See: [`write_register()`].
//!
//! [`enable_hrs()`]: struct.Hrs3300.html#method.enable_hrs
//! [`enable_oscillator()`]: struct.Hrs3300.html#method.enable_oscillator
//! [`init()`]: struct.Hrs3300.html#method.init
//! [`set_conversion_delay()`]: struct.Hrs3300.html#method.set_conversion_delay
//! [`set_gain()`]: struct.Hrs3300.html#method.set_gain
//! [`set_als_resolution()`]: struct.Hrs3300.html#method.set_als_resolution
//! [`set_led_current()`]: struct.Hrs3300.html#method.set_led_current
//! [`device_id()`]: struct.Hrs3300.html#method.device_id
//! [`read_hrs()`]: struct.Hrs3300.html#method.read_hrs
//! [`read_als()`]: struct.Hrs3300.html#method.read_als
//! [`write_register()`]: struct.Hrs3300.html#method.write_register
//!
//! <!-- TODO
//! [Introductory blog post](TODO)
//! -->
//!
//! ## The device
//!
//! HRSS3300 is an optical digital heart rate sensor/monitor featuring a 525nm
//! green LED and a reflection light detector for the PPG signal from the human
//! body.
//! The typical heart rate measurement samples the reflected PPG signal at
//! 25Hz then the results can be read via the I2C bus.
//!
//! Datasheet:
//! - [HRS3300](http://files.pine64.org/doc/datasheet/pinetime/HRS3300%20Heart%20Rate%20Sensor.pdf)
//!
//! ## Usage examples (see also examples folder)
//!
//! To use this driver, import this crate and an `embedded_hal` implementation,
//! then instantiate the appropriate device.
//!
//! ### Initialize the device and take some measurements
//!
//! ```no_run
//! extern crate linux_embedded_hal as hal;
//! extern crate hrs3300;
//! use hrs3300::Hrs3300;
//!
//! # fn main() {
//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap();
//! let mut sensor = Hrs3300::new(dev);
//! sensor.init().unwrap();
//! sensor.enable_hrs().unwrap();
//! sensor.enable_oscillator().unwrap();
//! loop {
//! let hrs = sensor.read_hrs().unwrap();
//! let als = sensor.read_als().unwrap();
//! println!("HRS: {}, ALS: {}", hrs, als);
//! }
//! # }
//! ```
//!
//! ### Change the parameters
//!
//! ```no_run
//! extern crate linux_embedded_hal as hal;
//! extern crate hrs3300;
//! use hrs3300::{ConversionDelay, Gain, Hrs3300, LedCurrent};
//!
//! # fn main() {
//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap();
//! let mut sensor = Hrs3300::new(dev);
//! sensor.init().unwrap();
//! sensor.set_gain(Gain::Four).unwrap();
//! sensor.set_conversion_delay(ConversionDelay::Ms50).unwrap();
//! sensor.set_led_current(LedCurrent::Ma20).unwrap();
//! # }
//! ```
extern crate embedded_hal as hal;
/// HRS3300 device driver
pub use ;