Library which provides functions to control a TAOS TSL2561 Light-To-Digital Converter via I2C.

Dependents:   TweetTest NetworkThermometer GR-PEACH_TAMORI mDot_LoRa_Connect_ABPA_Lux ... more

Committer:
karlmaxwell67
Date:
Thu Mar 20 16:56:56 2014 +0000
Revision:
3:6a89ac4a1979
Parent:
2:38d5187a4e7b
Child:
4:5d1f8d7d81ff
Added more functions to increase the functionality of the class.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
karlmaxwell67 0:453a43c8bf2b 1 #ifndef TCS3472_I2C_H
karlmaxwell67 0:453a43c8bf2b 2 #define TCS3472_I2C_H
karlmaxwell67 0:453a43c8bf2b 3 #include "mbed.h"
karlmaxwell67 0:453a43c8bf2b 4
karlmaxwell67 1:70d7d9f1af01 5 //Defines
karlmaxwell67 1:70d7d9f1af01 6 #define SLAVE_ADDRESS 0x29
karlmaxwell67 2:38d5187a4e7b 7
karlmaxwell67 3:6a89ac4a1979 8 #define ENABLE 0x00
karlmaxwell67 2:38d5187a4e7b 9 #define ATIME 0x01
karlmaxwell67 2:38d5187a4e7b 10 #define WTIME 0x03
karlmaxwell67 3:6a89ac4a1979 11 #define AILTL 0x04
karlmaxwell67 3:6a89ac4a1979 12 #define AIHTL 0x06
karlmaxwell67 3:6a89ac4a1979 13 #define PERS 0x0C
karlmaxwell67 3:6a89ac4a1979 14 #define CONFIG 0x0D
karlmaxwell67 3:6a89ac4a1979 15 #define CONTROL 0x0F
karlmaxwell67 3:6a89ac4a1979 16 #define ID 0x12
karlmaxwell67 3:6a89ac4a1979 17 #define STATUS 0x13
karlmaxwell67 1:70d7d9f1af01 18 #define CDATA 0x14
karlmaxwell67 1:70d7d9f1af01 19 #define RDATA 0x16
karlmaxwell67 1:70d7d9f1af01 20 #define GDATA 0x18
karlmaxwell67 1:70d7d9f1af01 21 #define BDATA 0x1A
karlmaxwell67 1:70d7d9f1af01 22
karlmaxwell67 0:453a43c8bf2b 23 class TCS3472_I2C {
karlmaxwell67 0:453a43c8bf2b 24 public:
karlmaxwell67 0:453a43c8bf2b 25 TCS3472_I2C( PinName sda, PinName scl );
karlmaxwell67 1:70d7d9f1af01 26
karlmaxwell67 1:70d7d9f1af01 27 int getAllColours( int* readings );
karlmaxwell67 1:70d7d9f1af01 28 int getClearData();
karlmaxwell67 1:70d7d9f1af01 29 int getRedData();
karlmaxwell67 1:70d7d9f1af01 30 int getGreenData();
karlmaxwell67 1:70d7d9f1af01 31 int getBlueData();
karlmaxwell67 3:6a89ac4a1979 32
karlmaxwell67 3:6a89ac4a1979 33 int enablePower();
karlmaxwell67 3:6a89ac4a1979 34 int disablePower();
karlmaxwell67 3:6a89ac4a1979 35 int enableRGBC();
karlmaxwell67 3:6a89ac4a1979 36 int disableRGBC();
karlmaxwell67 3:6a89ac4a1979 37 int enablePowerAndRGBC();
karlmaxwell67 3:6a89ac4a1979 38 int disablePowerAndRGBC();
karlmaxwell67 2:38d5187a4e7b 39 int enableWait();
karlmaxwell67 2:38d5187a4e7b 40 int disableWait();
karlmaxwell67 2:38d5187a4e7b 41 int enableInterrupt();
karlmaxwell67 2:38d5187a4e7b 42 int disableInterrupt();
karlmaxwell67 2:38d5187a4e7b 43 int setWaitTime( const float wtime ); // wtime (in ms) should be in the range 2.4 - 7400ms.
karlmaxwell67 3:6a89ac4a1979 44 int setIntegrationTime( const float itime ); // itime (in ms) should be in the range 2.4 - 614.4ms.
karlmaxwell67 3:6a89ac4a1979 45
karlmaxwell67 3:6a89ac4a1979 46 char readEnableRegister();
karlmaxwell67 3:6a89ac4a1979 47 int readLowInterruptThreshold();
karlmaxwell67 3:6a89ac4a1979 48 int readHighInterruptThreshold();
karlmaxwell67 3:6a89ac4a1979 49 int setLowInterruptThreshold( const int threshold );
karlmaxwell67 3:6a89ac4a1979 50 int setHighInterruptThreshold( const int threshold );
karlmaxwell67 3:6a89ac4a1979 51 int readInterruptPersistence();
karlmaxwell67 3:6a89ac4a1979 52 int setInterruptPersistence( const int persistence ); // persistence must be 0, 1, 2, 3, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55 or 60
karlmaxwell67 3:6a89ac4a1979 53 int clearInterrupt();
karlmaxwell67 3:6a89ac4a1979 54 int readRGBCGain();
karlmaxwell67 3:6a89ac4a1979 55 int setRGBCGain( const int gain ); // gain must be 1, 4, 16 or 60
karlmaxwell67 3:6a89ac4a1979 56 char getDeviceID();
karlmaxwell67 3:6a89ac4a1979 57 char readStatusRegister();
karlmaxwell67 0:453a43c8bf2b 58
karlmaxwell67 0:453a43c8bf2b 59 private:
karlmaxwell67 3:6a89ac4a1979 60 I2C i2c;
karlmaxwell67 1:70d7d9f1af01 61
karlmaxwell67 1:70d7d9f1af01 62 int writeSingleRegister( char address, char data );
karlmaxwell67 3:6a89ac4a1979 63 int writeMultipleRegisters( char address, char* data, int quantity );
karlmaxwell67 1:70d7d9f1af01 64 char readSingleRegister( char address );
karlmaxwell67 1:70d7d9f1af01 65 int readMultipleRegisters( char address, char* output, int quantity );
karlmaxwell67 0:453a43c8bf2b 66 };
karlmaxwell67 0:453a43c8bf2b 67
karlmaxwell67 1:70d7d9f1af01 68 #endif