MAX44009 Ambient Light Sensor with ADC library

Fork of MAX44009 by Davy Van Belle

Committer:
lucian@192-168-0-103.rdsnet.ro
Date:
Mon Feb 19 18:35:44 2018 +0200
Revision:
3:b3745ae13d09
Parent:
2:7aa4718b2e2b
Fix raw reading method

Who changed what in which revision?

UserRevisionLine numberNew 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-100.rdsnet.ro 2:7aa4718b2e2b 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 3:b3745ae13d09 58 void getRawReading(char buff[2]);
lucian@192-168-0-103.rdsnet.ro 1:b8240ff9ddc3 59
lucian@192-168-0-100.rdsnet.ro 2:7aa4718b2e2b 60 double getLUXReading();
lucian@192-168-0-100.rdsnet.ro 2:7aa4718b2e2b 61
lucian@192-168-0-100.rdsnet.ro 2:7aa4718b2e2b 62 double getLuxFromBuffReading(char *buff);
lucian@192-168-0-103.rdsnet.ro 1:b8240ff9ddc3 63
lucian@192-168-0-103.rdsnet.ro 1:b8240ff9ddc3 64 void setUpperThreshold(char threshold);
gizmo69the2nd 0:726b77a319d8 65
lucian@192-168-0-103.rdsnet.ro 1:b8240ff9ddc3 66 void setLowerThreshold(char threshold);
lucian@192-168-0-103.rdsnet.ro 1:b8240ff9ddc3 67
lucian@192-168-0-103.rdsnet.ro 1:b8240ff9ddc3 68 void setThresholdTimer(char time);
gizmo69the2nd 0:726b77a319d8 69
gizmo69the2nd 0:726b77a319d8 70 private:
gizmo69the2nd 0:726b77a319d8 71 char _addr;
gizmo69the2nd 0:726b77a319d8 72 I2C *_i2c;
lucian@192-168-0-103.rdsnet.ro 1:b8240ff9ddc3 73
gizmo69the2nd 0:726b77a319d8 74 };
lucian@192-168-0-103.rdsnet.ro 1:b8240ff9ddc3 75
gizmo69the2nd 0:726b77a319d8 76 #endif