AS7265x functions for setting integration time, LEDs, collecting/reading data
Dependents: IntegratingSphereController LaunchDay
AS7265xfunctions.h@0:3699cacb5a93, 2019-01-24 (annotated)
- Committer:
- nthompson22
- Date:
- Thu Jan 24 01:27:45 2019 +0000
- Revision:
- 0:3699cacb5a93
- Child:
- 1:4d4e07dcc694
AS7265x functions for setting integration time, LEDs, collecting/reading data
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nthompson22 | 0:3699cacb5a93 | 1 | #ifndef AS7265XFUNCTIONS_H |
nthompson22 | 0:3699cacb5a93 | 2 | #define AS7265XFUNCTIONS_H |
nthompson22 | 0:3699cacb5a93 | 3 | #include <mbed.h> |
nthompson22 | 0:3699cacb5a93 | 4 | class AS7265x { |
nthompson22 | 0:3699cacb5a93 | 5 | public: |
nthompson22 | 0:3699cacb5a93 | 6 | char getDeviceType(); // used for testing, should give 0x40 |
nthompson22 | 0:3699cacb5a93 | 7 | char getHardwareVersion(); // used for testing, should give 0x41 |
nthompson22 | 0:3699cacb5a93 | 8 | void ledSwitch(int, int); //first number 0, 1, or 2 says which LED, second number either 0 or 1 turns it on or off |
nthompson22 | 0:3699cacb5a93 | 9 | void setIntegTime(int); //sets integration time in milliseconds |
nthompson22 | 0:3699cacb5a93 | 10 | void setAllLeds(int); //enter either 0 or 1 to set all LEDs on or off |
nthompson22 | 0:3699cacb5a93 | 11 | AS7265x(I2C i2c, int addr); //constructor function |
nthompson22 | 0:3699cacb5a93 | 12 | uint16_t readData(int); //enter a number 1 through 18 to read the data from one of the channels |
nthompson22 | 0:3699cacb5a93 | 13 | void collectData(void); //run this function to collect one set of data from all channels |
nthompson22 | 0:3699cacb5a93 | 14 | private: |
nthompson22 | 0:3699cacb5a93 | 15 | void selectDevice(int); //selects one of the 3 sensors, used in ledSwitch() and collectData() |
nthompson22 | 0:3699cacb5a93 | 16 | uint16_t getData(int); //gets data from one channel, used in collectData() to set up the _channels array with all of the data |
nthompson22 | 0:3699cacb5a93 | 17 | uint16_t _channels[18]; //stores data from collectData() |
nthompson22 | 0:3699cacb5a93 | 18 | void regWrite(char reg, char data); |
nthompson22 | 0:3699cacb5a93 | 19 | char regRead(char reg); |
nthompson22 | 0:3699cacb5a93 | 20 | I2C _i2c; |
nthompson22 | 0:3699cacb5a93 | 21 | int _addr; |
nthompson22 | 0:3699cacb5a93 | 22 | int _integTime; |
nthompson22 | 0:3699cacb5a93 | 23 | int _set; |
nthompson22 | 0:3699cacb5a93 | 24 | }; |
nthompson22 | 0:3699cacb5a93 | 25 | #endif |