MAX44009 Ambient Light Sensor with ADC library
Fork of MAX44009 by
MAX44009.h@1:b8240ff9ddc3, 2018-02-08 (annotated)
- Committer:
- lucian@192-168-0-103.rdsnet.ro
- Date:
- Thu Feb 08 19:53:35 2018 +0200
- Revision:
- 1:b8240ff9ddc3
- Parent:
- 0:726b77a319d8
- Child:
- 2:7aa4718b2e2b
Add method to get raw readings
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gizmo69the2nd | 0:726b77a319d8 | 1 | /* |
gizmo69the2nd | 0:726b77a319d8 | 2 | * MAX44009 Ambient Light Sensor with ADC library |
gizmo69the2nd | 0:726b77a319d8 | 3 | * |
gizmo69the2nd | 0:726b77a319d8 | 4 | * |
gizmo69the2nd | 0:726b77a319d8 | 5 | * Copyright (c) 2013 Davy Van Belle, MIT License |
gizmo69the2nd | 0:726b77a319d8 | 6 | * |
gizmo69the2nd | 0:726b77a319d8 | 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
gizmo69the2nd | 0:726b77a319d8 | 8 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
gizmo69the2nd | 0:726b77a319d8 | 9 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
gizmo69the2nd | 0:726b77a319d8 | 10 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
gizmo69the2nd | 0:726b77a319d8 | 11 | * furnished to do so, subject to the following conditions: |
gizmo69the2nd | 0:726b77a319d8 | 12 | * |
gizmo69the2nd | 0:726b77a319d8 | 13 | * The above copyright notice and this permission notice shall be included in all copies or |
gizmo69the2nd | 0:726b77a319d8 | 14 | * substantial portions of the Software. |
gizmo69the2nd | 0:726b77a319d8 | 15 | * |
gizmo69the2nd | 0:726b77a319d8 | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
gizmo69the2nd | 0:726b77a319d8 | 17 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
gizmo69the2nd | 0:726b77a319d8 | 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
gizmo69the2nd | 0:726b77a319d8 | 19 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
gizmo69the2nd | 0:726b77a319d8 | 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
gizmo69the2nd | 0:726b77a319d8 | 21 | */ |
gizmo69the2nd | 0:726b77a319d8 | 22 | |
gizmo69the2nd | 0:726b77a319d8 | 23 | /** @file |
gizmo69the2nd | 0:726b77a319d8 | 24 | * @brief MAX44009 I2C |
gizmo69the2nd | 0:726b77a319d8 | 25 | */ |
lucian@192-168-0-103.rdsnet.ro | 1:b8240ff9ddc3 | 26 | |
gizmo69the2nd | 0:726b77a319d8 | 27 | #ifndef MAX44009_H |
gizmo69the2nd | 0:726b77a319d8 | 28 | #define MAX44009_H |
gizmo69the2nd | 0:726b77a319d8 | 29 | |
gizmo69the2nd | 0:726b77a319d8 | 30 | #include "mbed.h" |
gizmo69the2nd | 0:726b77a319d8 | 31 | |
gizmo69the2nd | 0:726b77a319d8 | 32 | #define INT_STATUS 0x00 |
gizmo69the2nd | 0:726b77a319d8 | 33 | #define INT_ENABLE 0x01 |
gizmo69the2nd | 0:726b77a319d8 | 34 | |
gizmo69the2nd | 0:726b77a319d8 | 35 | #define CONFIG 0x02 |
gizmo69the2nd | 0:726b77a319d8 | 36 | |
gizmo69the2nd | 0:726b77a319d8 | 37 | #define LUX_HIGH_B 0x03 |
gizmo69the2nd | 0:726b77a319d8 | 38 | #define LUX_LOW_B 0x04 |
gizmo69the2nd | 0:726b77a319d8 | 39 | |
gizmo69the2nd | 0:726b77a319d8 | 40 | #define UP_THRESH_HIGH_B 0x05 |
gizmo69the2nd | 0:726b77a319d8 | 41 | #define LOW_THRESH_HIGH_B 0x06 |
gizmo69the2nd | 0:726b77a319d8 | 42 | |
gizmo69the2nd | 0:726b77a319d8 | 43 | #define THRESH_TIMER 0x07 |
lucian@192-168-0-103.rdsnet.ro | 1:b8240ff9ddc3 | 44 | |
gizmo69the2nd | 0:726b77a319d8 | 45 | |
gizmo69the2nd | 0:726b77a319d8 | 46 | /** MAX44009 class |
gizmo69the2nd | 0:726b77a319d8 | 47 | */ |
gizmo69the2nd | 0:726b77a319d8 | 48 | class MAX44009 { |
gizmo69the2nd | 0:726b77a319d8 | 49 | public: |
lucian@192-168-0-103.rdsnet.ro | 1:b8240ff9ddc3 | 50 | MAX44009(I2C *i2c, char addr); |
gizmo69the2nd | 0:726b77a319d8 | 51 | |
lucian@192-168-0-103.rdsnet.ro | 1:b8240ff9ddc3 | 52 | void setConfig(char config); |
lucian@192-168-0-103.rdsnet.ro | 1:b8240ff9ddc3 | 53 | |
gizmo69the2nd | 0:726b77a319d8 | 54 | char getIntStatus(); |
gizmo69the2nd | 0:726b77a319d8 | 55 | |
gizmo69the2nd | 0:726b77a319d8 | 56 | void setIntEnable(bool Enable); |
gizmo69the2nd | 0:726b77a319d8 | 57 | |
lucian@192-168-0-103.rdsnet.ro | 1:b8240ff9ddc3 | 58 | char * getRawReading(); |
lucian@192-168-0-103.rdsnet.ro | 1:b8240ff9ddc3 | 59 | |
gizmo69the2nd | 0:726b77a319d8 | 60 | float getLUXReading(); |
lucian@192-168-0-103.rdsnet.ro | 1:b8240ff9ddc3 | 61 | |
lucian@192-168-0-103.rdsnet.ro | 1:b8240ff9ddc3 | 62 | void setUpperThreshold(char threshold); |
gizmo69the2nd | 0:726b77a319d8 | 63 | |
lucian@192-168-0-103.rdsnet.ro | 1:b8240ff9ddc3 | 64 | void setLowerThreshold(char threshold); |
lucian@192-168-0-103.rdsnet.ro | 1:b8240ff9ddc3 | 65 | |
lucian@192-168-0-103.rdsnet.ro | 1:b8240ff9ddc3 | 66 | void setThresholdTimer(char time); |
gizmo69the2nd | 0:726b77a319d8 | 67 | |
gizmo69the2nd | 0:726b77a319d8 | 68 | private: |
gizmo69the2nd | 0:726b77a319d8 | 69 | char _addr; |
gizmo69the2nd | 0:726b77a319d8 | 70 | I2C *_i2c; |
lucian@192-168-0-103.rdsnet.ro | 1:b8240ff9ddc3 | 71 | |
gizmo69the2nd | 0:726b77a319d8 | 72 | }; |
lucian@192-168-0-103.rdsnet.ro | 1:b8240ff9ddc3 | 73 | |
gizmo69the2nd | 0:726b77a319d8 | 74 | #endif |