Library for MAX3010x optical sensors
Diff: MAX30105.h
- Revision:
- 1:411eb3796949
- Parent:
- 0:62bc11b5bc43
--- a/MAX30105.h Wed Feb 08 00:22:28 2017 +0000 +++ b/MAX30105.h Thu Feb 16 22:01:02 2017 +0000 @@ -52,6 +52,41 @@ #define MAX30105_DEFAULT_LED_PA 0x20 #define MAX30105_DEFAULT_PILOT_PA 0x40 +/** + * MAX30105 Optical Sensor + * + * @code + * #include "mbed.h" + * #include "MAX30105.h" + * + * I2C i2c(I2C_SDA, I2C_SCL); + * MAX30105 max30105(&i2c); + * + * int main(void) { + * int lastPrx = 0; + * + * max30105.softReset(); // reset the MAX30105 + * max30105.shutDown(); // shut down while configuring + * max30105.enableIntr(MAX30105::INTR_PROX); // enable proximity interrupt + * max30105.setProx(0x40, 0x10); // set proximity pulse amplitude and threshold + * max30105.setSingleLED(); // configure single LED mode to initiate proximity detection + * max30105.wakeUp(); // exit shutdown to start sensing + * + * while(1) { + * if (max30105.getIntr1() & MAX30105::INTR_PROX) { // if the proximity interrupt occurs + * if (!lastPrx) { + * printf("Temperature = %02f\n", max30105.readTemperature()); + * } + * max30105.writeReg(MAX30105::REG_MODE_CONFIG, MAX30105::MODE_1LED); // go back into proximity detection + * lastPrx = 1; + * } else { + * lastPrx = 0; + * } + * wait_ms(100); + * } + * } + * @endcode + */ class MAX30105 { public: