TSL2561(照度センサ)のライブラリです
Dependents: HYBRYD2018_IZU_ROCKET Hybrid_IZU2019
TSL2561.h
- Committer:
- zebrin1422
- Date:
- 2017-11-16
- Revision:
- 0:40ff41e6257e
- Child:
- 1:4e7b35c8d948
File content as of revision 0:40ff41e6257e:
#ifndef TSL2561 #define TSL2561 #define SLV_WRITE 0b01110010 #define SLV_READ 0b01110011 #define COMMAND 0xA0 #define CONTROL_REG 0x00 #define POWER_UP 0x03 #define POWER_DOWN 0x00 #define RAW_DATA_LOW 0x0C #define RAW_DATA_HIGH 0x0D #define CHECK_REG 0x0A #define TIMING_REG 0x01; #define ID_NUMBER 0x11 #define TIMING 0x10 class myTSL2561 { public: myTSL2561(I2C &i2cBus); void begin(); /******************************************************************* TSL2561を起動させる関数 データをとる前に起動させておく *******************************************************************/ int connect_check(); /******************************************************************* 0が返ってきたらError 1が返ってきたらOK *******************************************************************/ unsigned int get_luminosity(unsigned int wait_time); /******************************************************************* 照度(Lux)を返してくれる関数 引数のwait_timeには下のset_rateが返してくる値を入れてください @example int time; time = myTSL2561.set_rate(0); pc.printf("Lux = %d\r\n",myTSL2561.get_luminosity(time)); *******************************************************************/ unsigned int set_rate(int channel); /******************************************************************* channelに入れる値によってデータの変換時間が変わる 0: 変換時間13.7[ms] 1: 変換時間101[ms] 2: 変換時間402[ms] この時間が返ってくるので、それをget_luminosityの引数に入れる(@exampleを参照) *******************************************************************/ private: I2C *i2c; unsigned int time; char power_up_cmd[2]; char power_down_cmd[2]; char check_cmd; char read_cmd; char timing_cmd[2]; char check_read,buff[2]; int val[2]; unsigned int lux,sekigai; }; #endif